profile
viewpoint
Luciano Almeida LucianoPAlmeida @aisdigital Brasília, Brazil https://medium.com/@lucianoalmeida1 Software Engineer at @aisdigital 🇧🇷 Trying to learn about compilers on the free time

apple/swift 54004

The Swift Programming Language

GitHawkApp/GitHawk 2729

The (second) best iOS app for GitHub.

AppCivicoPlataforma/AppCivico 130

Documentação de Endpoints para acesso à plataforma de AppCivicos do TCU.

LucianoPAlmeida/-Distributed-Systems- 1

Project for college discipline of Distributed Systems

aisdigital/pagarme-ios 0

Pagar.me's iOS API

Guilhermo-42/KtCoroutines 0

Kotlin Coroutines project example for forum presentation

Pull request review commentapple/swift

[DiagnosticsQol] Modify diagnostic macro into single DIAG

 static_assert(sizeof(storedDiagnosticInfos) / sizeof(StoredDiagnosticInfo) ==               "array size mismatch");  static constexpr const char * const diagnosticStrings[] = {-#define ERROR(ID, Options, Text, Signature) Text,-#define WARNING(ID, Options, Text, Signature) Text,-#define NOTE(ID, Options, Text, Signature) Text,-#define REMARK(ID, Options, Text, Signature) Text,+#define DIAG(KIND, ID, Options, Text, Signature) Text,

I think if you do a text seach for something like #define WARNING using a text editor you find some other places :)

so5462

comment created time in 15 hours

PullRequestReviewEvent

Pull request review commentapple/swift

[DiagnosticsQol] Modify diagnostic macro into single DIAG

 static_assert(sizeof(storedDiagnosticInfos) / sizeof(StoredDiagnosticInfo) ==               "array size mismatch");  static constexpr const char * const diagnosticStrings[] = {-#define ERROR(ID, Options, Text, Signature) Text,-#define WARNING(ID, Options, Text, Signature) Text,-#define NOTE(ID, Options, Text, Signature) Text,-#define REMARK(ID, Options, Text, Signature) Text,+#define DIAG(KIND, ID, Options, Text, Signature) Text,

Based on the description of the issue, seems like there are other places where this can also be done :) Or is this the only place @HassanElDesouky?

so5462

comment created time in 15 hours

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13776][Sema] Adjusting diagnose conflicting generic to handle generic mismatches

 std::string swift::describeGenericType(ValueDecl *GP, bool includeName) { static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,                                                 const SolutionDiff &diff,                                                 ArrayRef<Solution> solutions) {-  if (!diff.overloads.empty())+  // Also attempt to detect and diagnose conflicting generic arguments across+  // multiple solutions and overloads when all fixes are generic mismatches.+  bool allGenericMismatch =+      llvm::all_of(solutions, [](const Solution &solution) -> bool {

Seems like even if we manage to get all argument mismatch by tweaking the score a bit(also not sure if we can do that), we still fail to diagnose that in diagnoseConflictingGenericArguments because we have two distinct overloads on the overload diff

(lldb) p diff.overloads.size()
(size_t) $2 = 2
(lldb) p (*(diff.overloads.begin())).locator->getAnchor().dump()
(unresolved_dot_expr type='<null>' field 'map' function_ref=single
  (declref_expr type='<null>' decl=main.(file).SR1377f(_:_:).c2@file.swift:6:58 function_ref=unapplied))
(lldb) p (*(diff.overloads.begin() + 1)).locator->getAnchor().dump()
(unresolved_dot_expr type='<null>' field 'map' function_ref=single
  (declref_expr type='<null>' decl=main.(file).SR1377f(_:_:).c1@/file.swift:6:48 function_ref=unapplied))(lldb) 
LucianoPAlmeida

comment created time in 16 hours

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13776][Sema] Adjusting diagnose conflicting generic to handle generic mismatches

 std::string swift::describeGenericType(ValueDecl *GP, bool includeName) { static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,                                                 const SolutionDiff &diff,                                                 ArrayRef<Solution> solutions) {-  if (!diff.overloads.empty())+  // Also attempt to detect and diagnose conflicting generic arguments across+  // multiple solutions and overloads when all fixes are generic mismatches.+  bool allGenericMismatch =+      llvm::all_of(solutions, [](const Solution &solution) -> bool {

Right, so we are not recording the argument mismatch because of unhandled GenericArgument on repairFailures for arg to param locator elt. But even if we try to lift this restriction and record the argument fix, what is happening is that when solving two distinct disjunctions are formed: bind to [C2.Element] and arg conv [C2.Element], the former failing and recording the generic mismatch and later the argument mismatch. But the reason we end up always with all solutions generic mismatches when attempting to diagnose the ambiguity is that the later disjunction is always considered the worst. Solver output ...

(solving component #0
                          (attempting disjunction choice [$T52] bind [C2.Element] [deep equality] [[locator@0x11f82b990 [Call@file.swift:7:5 -> apply argument -> comparing call argument #0 to parameter #0]]];
                            (attempting fix [fix: fix generic argument mismatch] @ locator@0x11f82b990 [Call@file.swift:7:5 -> apply argument -> comparing call argument #0 to parameter #0])
                            (increasing score due to attempting to fix the source)
                            (found solution 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
                          )
                          (attempting disjunction choice [$T52] arg conv [C2.Element] [array-upcast] [[locator@0x11f82b990 [Call@file.swift:7:5 -> apply argument -> comparing call argument #0 to parameter #0]]];
                            (increasing score due to collection upcast conversion)
                            (attempting fix [fix: allow argument to parameter type conversion mismatch] @ locator@0x11f82b990 [Call@file.swift:7:5 -> apply argument -> comparing call argument #0 to parameter #0])
                            (increasing score due to attempting to fix the source)
                            (solution is worse than the best solution)
                            (failed constraint [$T52] arg conv [C2.Element] [array-upcast] [[locator@0x11f82b990 [Call@file.swift:7:5 -> apply argument -> comparing call argument #0 to parameter #0]]];)
                          )
                        finished component #0)
                          (composed solution 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0)

I'm trying to see if is possible to detect this and tweak the score in order to invert that and get the argument mismatch as the best solution.

LucianoPAlmeida

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13776][Sema] Adjusting diagnose conflicting generic to handle generic mismatches

 std::string swift::describeGenericType(ValueDecl *GP, bool includeName) { static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,                                                 const SolutionDiff &diff,                                                 ArrayRef<Solution> solutions) {-  if (!diff.overloads.empty())+  // Also attempt to detect and diagnose conflicting generic arguments across+  // multiple solutions and overloads when all fixes are generic mismatches.+  bool allGenericMismatch =+      llvm::all_of(solutions, [](const Solution &solution) -> bool {+        return llvm::all_of(+            solution.Fixes, [](const ConstraintFix *fix) -> bool {+              return fix->getKind() == FixKind::GenericArgumentsMismatch;+            });+      });++  if (!(diff.overloads.empty() || allGenericMismatch))     return false;    bool noFixes = llvm::all_of(solutions, [](const Solution &solution) -> bool {      const auto score = solution.getFixedScore();      return score.Data[SK_Fix] == 0 && solution.Fixes.empty();   }); -  bool allMismatches =-      llvm::all_of(solutions, [](const Solution &solution) -> bool {-        return llvm::all_of(-            solution.Fixes, [](const ConstraintFix *fix) -> bool {-              return fix->getKind() == FixKind::AllowArgumentTypeMismatch ||-                     fix->getKind() == FixKind::AllowFunctionTypeMismatch ||-                     fix->getKind() == FixKind::AllowTupleTypeMismatch;-            });-      });+  bool allMismatches = false;+  if (!allGenericMismatch) {+    allMismatches =+        llvm::all_of(solutions, [](const Solution &solution) -> bool {+          // Special casing situations where a type mismatch maybe followed by a+          // conformance requirement fix on each solution e.g.+          //    func f<E: Equatable>(_ e1: E, _ e2: E) {}+          //+          //    struct A {}+          //    struct B {}+          //+          //    f(A(), B())+          //+          // We also have to make sure that we diagnose the generic argument+          // mismatch in those situations.

There is a small problem with the ordering of the fixes are recorded (at least in this case), it seems like the conformance fix is recorded before argument mismatch ... so do you think we should go for not recording the argument mismatch instead if there is a recorded requirement fix for this argument?

LucianoPAlmeida

comment created time in 2 days

PullRequestReviewEvent

pull request commentapple/swift

Fix typos in comments and docs

@swift-ci Please smoke test

upbooo

comment created time in 2 days

push eventSwifterSwift/SwifterSwift

Marat.Ibragimov

commit sha 3c62399c3dc4b1eead06b057de7cccaf1d742a32

Added/dictionary filter using multiple keys (#911) * Added a extension method to Dicitonary * Iterate over the keys * Lint warning fix * Removed spaces * Swift lint fix #2 * PR fixes * Added changelog entry * PR fixes * PR fixes #3 * PR fix #4 * PR fix #5 * PR fixes Co-authored-by: Marat <marat.ibragimov@nl.abnamro.com> Co-authored-by: Luciano Almeida <passos.luciano@outlook.com>

view details

push time in 2 days

PR merged SwifterSwift/SwifterSwift

Reviewers
Added/dictionary filter using multiple keys

<!--- Provide a general summary of your changes in the Title above -->

Checklist

<!--- Please go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] I checked the Contributing Guidelines before creating this request.
  • [x] New extensions are written in Swift 5.0.
  • [x] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
  • [x] I have added tests for new extensions, and they passed.
  • [x] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
  • [x] All extensions are declared as public.
  • [x] I have added a changelog entry describing my changes.
+44 -0

4 comments

3 changed files

MaratIbragimov

pr closed time in 2 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13776][Sema] Adjusting diagnose conflicting generic to handle generic mismatches

 std::string swift::describeGenericType(ValueDecl *GP, bool includeName) { static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,                                                 const SolutionDiff &diff,                                                 ArrayRef<Solution> solutions) {-  if (!diff.overloads.empty())+  // Also attempt to detect and diagnose conflicting generic arguments across+  // multiple solutions and overloads when all fixes are generic mismatches.+  bool allGenericMismatch =+      llvm::all_of(solutions, [](const Solution &solution) -> bool {+        return llvm::all_of(+            solution.Fixes, [](const ConstraintFix *fix) -> bool {+              return fix->getKind() == FixKind::GenericArgumentsMismatch;+            });+      });++  if (!(diff.overloads.empty() || allGenericMismatch))     return false;    bool noFixes = llvm::all_of(solutions, [](const Solution &solution) -> bool {      const auto score = solution.getFixedScore();      return score.Data[SK_Fix] == 0 && solution.Fixes.empty();   }); -  bool allMismatches =-      llvm::all_of(solutions, [](const Solution &solution) -> bool {-        return llvm::all_of(-            solution.Fixes, [](const ConstraintFix *fix) -> bool {-              return fix->getKind() == FixKind::AllowArgumentTypeMismatch ||-                     fix->getKind() == FixKind::AllowFunctionTypeMismatch ||-                     fix->getKind() == FixKind::AllowTupleTypeMismatch;-            });-      });+  bool allMismatches = false;+  if (!allGenericMismatch) {+    allMismatches =+        llvm::all_of(solutions, [](const Solution &solution) -> bool {+          // Special casing situations where a type mismatch maybe followed by a+          // conformance requirement fix on each solution e.g.+          //    func f<E: Equatable>(_ e1: E, _ e2: E) {}+          //+          //    struct A {}+          //    struct B {}+          //+          //    f(A(), B())+          //+          // We also have to make sure that we diagnose the generic argument+          // mismatch in those situations.

I thought about that but was a bit worried that do not record the fix could cause unexpected results. But right let's try that!

LucianoPAlmeida

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13776][Sema] Adjusting diagnose conflicting generic to handle generic mismatches

 std::string swift::describeGenericType(ValueDecl *GP, bool includeName) { static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,                                                 const SolutionDiff &diff,                                                 ArrayRef<Solution> solutions) {-  if (!diff.overloads.empty())+  // Also attempt to detect and diagnose conflicting generic arguments across+  // multiple solutions and overloads when all fixes are generic mismatches.+  bool allGenericMismatch =+      llvm::all_of(solutions, [](const Solution &solution) -> bool {

Humm, the only case affected was acceptUnaryFn(unaryFnOvl) we can see on diff ... but now you mention, I'm thinking that the new example should have an argument mismatch fix recorded, sorry for that, let me take another look :)

LucianoPAlmeida

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/swift

Fix snippet in OptimizationTips.rst

Thanks for looking @varungandhi-apple :) I found this blog post https://www.jessesquires.com/blog/2018/07/05/swifts-new-calling-convention/ and also a gist from @gottesmm https://gist.github.com/gottesmm/524fca6a4e9fb3d5736a1b9d6686c5e8 It seems like it is indeed the case, so this statement probably needs updating

valeriyvan

comment created time in 3 days

PR opened apple/swift

Reviewers
[SR-13776][Sema] Adjusting diagnose conflicting generic to handle generic mismatches

Attempt to diagnose conflict generic arguments from generic mismatches fixes on diagnoseConflictingGenericArguments. Also, attempt to handle situations where the is an extra conformance fix causing an ambiguity.

<!-- If this pull request resolves any bugs in the Swift bug tracker, provide a link: --> Resolves SR-13776.

<!-- Before merging this pull request, you must run the Swift continuous integration tests. For information about triggering CI builds via @swift-ci, see: https://github.com/apple/swift/blob/master/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift! -->

+66 -15

0 comment

2 changed files

pr created time in 3 days

push eventLucianoPAlmeida/swift

Luciano Almeida

commit sha 9c85834a671473a8ae964ee5bb8489bcedcdc2a0

[Sema] Adjusting diagnose conflicting generic to handle generic mismatches and type mismatches with missing conformance

view details

push time in 3 days

create barnchLucianoPAlmeida/swift

branch : SR-13776-generic-conflicting-args

created branch time in 3 days

Pull request review commentapple/swift

[SR-13503] [Sema] Special InsertExplicitCall for nominal callable types

 ConstraintSystem::simplifyApplicableFnConstraint(       type1, origType2, subflags, locator);    if (shouldAttemptFixes() && result == SolutionKind::Error) {+    // Skip those fixes in case we are only attempting to check if it's possible+    // to insert an explicit call in an anchor expr that produces a callable+    // value.+    if (locator.isForImplicitApplyCallableValue())

Ahh great, thank you @xedin :) I will get back to this soon

LucianoPAlmeida

comment created time in 3 days

PullRequestReviewEvent

pull request commentapple/swift

Fix snippet in OptimizationTips.rst

Not related to the PR itself, but the block above the change states "In Swift, all parameters are passed in at +1, i.e. the parameters are retained before a callsite, and then are released at the end of the callee." Is this still correct? As far as I remember calling convention changed since Swift 4.2 and the release was no longer done in the callee right ... cc @CodaFi @varungandhi-apple

valeriyvan

comment created time in 5 days

PullRequestReviewEvent

pull request commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

I think I agree, actually. Sequence has a first(where:), but that would be better named any(where:). I'm happy to deprecate this.

Great, let's do this \o/ About first(where:) do we have that? I thought it was from stdlib ... although to me it will make more sense a find(where:)

guykogus

comment created time in 6 days

PullRequestReviewEvent

pull request commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

Better thinking about it today, a last(where:) for Sequence kinda don't make sense in semantic terms, because the protocol as in general is a protocol that doesn't guarantee Ordering so last will not produce an "expected" result. Point is that we asking the last of a Sequence ... but what is exactly the last in the sense of the protocol? The best example of this is the Set one, it feels a little weird to call set.last { ... }

Maybe we should think about deprecating this one.

guykogus

comment created time in 6 days

Pull request review commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

 final class SequenceExtensionsTests: XCTestCase {         XCTAssertEqual(tuple.1, [1, 3, 5])     } -    func testContains() {+    func testContainsEquatable() {+        struct Foo: Equatable, ExpressibleByIntegerLiteral {

Seems swiftlint is complaining about nesting here ...

guykogus

comment created time in 6 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

startedgao-sun/eul

started time in 7 days

push eventJayxiang/SwifterSwift

Luciano Almeida

commit sha 2cdfb492067b20b20f838d265d6120895a7c0eba

[CI] Updating brew version (#914) * [CI] Updating brew version * [CI] Test * [CI] Updating versions

view details

Luciano Almeida

commit sha 8c5b43e3cd0f54e7beb406f7482c9cdefde98481

Merge branch 'master' into master

view details

push time in 7 days

push eventthisIsTheFoxe/SwifterSwift

Luciano Almeida

commit sha 2cdfb492067b20b20f838d265d6120895a7c0eba

[CI] Updating brew version (#914) * [CI] Updating brew version * [CI] Test * [CI] Updating versions

view details

Luciano Almeida

commit sha 0584ee336381fed5de56c491430139a40cc3ceda

Merge branch 'master' into issue-907

view details

push time in 7 days

push eventMaratIbragimov/SwifterSwift

Luciano Almeida

commit sha 2cdfb492067b20b20f838d265d6120895a7c0eba

[CI] Updating brew version (#914) * [CI] Updating brew version * [CI] Test * [CI] Updating versions

view details

Luciano Almeida

commit sha 9503c00c573b5ea513f61bebb694be59386d4ff0

Merge branch 'master' into Added/Dictionary_filter_using_multiple_keys

view details

push time in 7 days

delete branch SwifterSwift/SwifterSwift

delete branch : ci-fix

delete time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 2cdfb492067b20b20f838d265d6120895a7c0eba

[CI] Updating brew version (#914) * [CI] Updating brew version * [CI] Test * [CI] Updating versions

view details

push time in 7 days

PR merged SwifterSwift/SwifterSwift

[CI] Updating brew version

<!--- Provide a general summary of your changes in the Title above -->

Checklist

<!--- Please go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] I checked the Contributing Guidelines before creating this request.
  • [ ] New extensions are written in Swift 5.0.
  • [ ] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
  • [ ] I have added tests for new extensions, and they passed.
  • [ ] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
  • [ ] All extensions are declared as public.
  • [ ] I have added a changelog entry describing my changes.
+20 -20

2 comments

2 changed files

LucianoPAlmeida

pr closed time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha e0de16ff754213770048148fb489475c4dbe6574

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 0130415c5d94d08d9268937d2b3da8c4171951c8

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 0029f05dd551f3b82a46863ec8406fb6545b4ce1

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha e4042d0f193ee7c9e30f3c6ebca95b43375fff09

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 1df52f3f3d15f22653373d3ab33ed7b413fdd547

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 31f11e95e4cca46f6a4064cac712e0badbb533c8

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha a1bdab828770fe5d520aa08bf0419846def16755

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 646a73f67e595fb50afe1392e85ab1b9d7015168

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 7ad5c6949645c423acb00a944509a9aed69fed39

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 8a87519df71d236f9f83f8ea84336eb3cbdeeae8

[CI] Updating versions

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha a6fcc5371f3b7a4935f6d0f0d76ea00aa30dbca6

[CI] Test

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha ebc196b9be036353aad8c9f57e83b9b060afbe10

[CI] Test

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 2b721f2312d616cbabe5a63b5bc362197d7563a5

[CI] Test

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 449ae382df5d3d70add1a6c183d7900660e21d93

[CI] Test

view details

push time in 7 days

push eventSwifterSwift/SwifterSwift

Luciano Almeida

commit sha 6fbb90d05ee04013d4d537da640dc6d691e44965

[CI] Test

view details

push time in 7 days

PR opened SwifterSwift/SwifterSwift

[CI] Updating brew version

<!--- Provide a general summary of your changes in the Title above -->

Checklist

<!--- Please go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] I checked the Contributing Guidelines before creating this request.
  • [ ] New extensions are written in Swift 5.0.
  • [ ] New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
  • [ ] I have added tests for new extensions, and they passed.
  • [ ] All extensions have a clear comments explaining their functionality, all parameters and return type in English.
  • [ ] All extensions are declared as public.
  • [ ] I have added a changelog entry describing my changes.
+16 -16

0 comment

1 changed file

pr created time in 7 days

create barnchSwifterSwift/SwifterSwift

branch : ci-fix

created branch time in 7 days

pull request commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

No, the order when iterating isn't fixed because the hash values are randomised. Maybe we could have a fixed hashed value object...

I think even then ordering is not guaranteed ... so perhaps we have no choice with this case then

guykogus

comment created time in 7 days

pull request commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

@LucianoPAlmeida it turns out that last(where:) wasn't actually being tested because it was running on an Array, which already has a built-in definition (thanks for pointing that out).

Nice!

I created a LinkedList, which is ordered and only conforms to Sequence, so that we could test it. A little overkill, I know... 😅

I believe we don't need this, we can test it with a Set<> because it is a Sequence but not a collection, so a believe it will be able to handle this :)

guykogus

comment created time in 7 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

We have to check what is going on with the CI, seems like all PRs are failing

guykogus

comment created time in 7 days

Pull request review commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

 public extension Sequence {     /// - Parameter condition: condition to evaluate each element against.     /// - Returns: the last element in the array matching the specified condition. (optional)     func last(where condition: (Element) throws -> Bool) rethrows -> Element? {-        for element in reversed() {-            if try condition(element) { return element }-        }-        return nil+        return try reversed().first(where: condition)

Yeah, but I think the only other version we have of reversed that is a lazy view is down to BidirectionalCollection ... in the case of this function the selected overload will always be this copy one of Sequence... but for this case is fine since BidirectionalCollection has it's own version of last(where:) which is index based and can iterate backwards.

guykogus

comment created time in 7 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

 public extension Sequence where Element: Hashable {     } } -// MARK: - Methods (Numeric)+// MARK: - Methods (AdditiveArithmetic) -public extension Sequence where Element: Numeric {+public extension Sequence where Element: AdditiveArithmetic {     /// SwifterSwift: Sum of all elements in array.     ///     ///        [1, 2, 3, 4, 5].sum() -> 15     ///     /// - Returns: sum of the array's elements.     func sum() -> Element {-        return reduce(into: 0, +=)+        return reduce(.zero, +)

Yeah, it shouldn't be a huge problem in this case I think

guykogus

comment created time in 7 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Added/dictionary filter using multiple keys

 public extension Dictionary {     func compactMapKeysAndValues<K, V>(_ transform: ((key: Key, value: Value)) throws -> (K, V)?) rethrows -> [K: V] {         return [K: V](uniqueKeysWithValues: try compactMap(transform))     }++    /// SwifterSwift: Creates a new dictionary using specified keys+    ///+    ///        var dict =  ["key1": 1, "key2": 2, "key3": 3, "key4": 4]+    ///        dict.pick(keys: ["key1", "key3", "key4"]) -> ["key1": 1, "key3": 3, "key4": 4]+    ///        dict.pick(keys: ["key2"]) -> ["key2": 2]+    ///+    /// - Complexity: O(K), where _K_  is the length of the keys array and O(K) space.+    ///+    /// - Parameter keys: Parameter keys: An array of keys of the entries that will be in the resulting dictionary.
    /// - Parameter keys: An array of keys of the entries that will be in the resulting dictionary.
MaratIbragimov

comment created time in 8 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13503] [Sema] Special InsertExplicitCall for nominal callable types

 ConstraintSystem::simplifyApplicableFnConstraint(       type1, origType2, subflags, locator);    if (shouldAttemptFixes() && result == SolutionKind::Error) {+    // Skip those fixes in case we are only attempting to check if it's possible+    // to insert an explicit call in an anchor expr that produces a callable+    // value.+    if (locator.isForImplicitApplyCallableValue())

But at this point, before addOverloadSet we already have a member set right? Since a member lookup is performed right before it ... or do you mean we should do when repairing the mismatch instead of simplifyApplicableFnConstraint? Sorry for all the questions, I'll probably have to give think a bit more about to understand the idea of this approach :)

LucianoPAlmeida

comment created time in 8 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13503] [Sema] Special InsertExplicitCall for nominal callable types

 ConstraintSystem::TypeMatchResult constraints::matchCallArguments(     if (!callArgumentMatch)       return cs.getTypeMatchFailure(locator); +    // When checking to see if the callable value can be explicit called to+    // produce the expected type, we need to make sure that we fail here for+    // missing argument (which normally have fix recorded in argument tracker)+    // except if all parameters have a default values.

Yeah, I was also thinking about some other cases where we should give a good thought about like

struct S {
   func callAsFunction(a: Int) -> Int { 0 } 
   func callAsFunction(b: String) -> Int { 0 } 
}

What we should do in a mismatchS and Int like suggest one or another doesn't feel right... So offer two fix-its? In that case, diagnostic wording should probably change in those situations.

LucianoPAlmeida

comment created time in 8 days

PullRequestReviewEvent

startedcplusplus/draft

started time in 8 days

startedapple/swift-service-discovery

started time in 8 days

Pull request review commentapple/swift

[SR-13503] [Sema] Special InsertExplicitCall for nominal callable types

 ConstraintSystem::simplifyApplicableFnConstraint(       type1, origType2, subflags, locator);    if (shouldAttemptFixes() && result == SolutionKind::Error) {+    // Skip those fixes in case we are only attempting to check if it's possible+    // to insert an explicit call in an anchor expr that produces a callable+    // value.+    if (locator.isForImplicitApplyCallableValue())

Hum, when trying to do this I was struggling because as my understanding we would have to Constraint::createFixedChoice but didn't know what would be the "fallback" overload choice?

do a lookup as part of a fix

Sorry, not sure I understand this part, that means we have to do a lookup in order to create the fallback fixed choice constraint?

LucianoPAlmeida

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13503] [Sema] Special InsertExplicitCall for nominal callable types

 ConstraintSystem::TypeMatchResult constraints::matchCallArguments(     if (!callArgumentMatch)       return cs.getTypeMatchFailure(locator); +    // When checking to see if the callable value can be explicit called to+    // produce the expected type, we need to make sure that we fail here for+    // missing argument (which normally have fix recorded in argument tracker)+    // except if all parameters have a default values.

Ahh, I thought about this at the beginning, but as I was looking at the existing InsertExplicitCall fix for function types and since it didn't have this, I figure it would be something more simple to maintain this behavior here. Do you think is worth introducing this here for both? Also, in the beginning, I was trying to think from the user perspective that to insert a () call in value mismatch is more likely to be an expected fix than a call with parameters, so the more generic mismatch fix would fit better in this 'with params' case? I'm not sure, just trying to think if insert explicit call would be a better diagnostic in this case :)

LucianoPAlmeida

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Added/dictionary filter using multiple keys

 final class DictionaryExtensionsTests: XCTestCase {             [6: ["Bryant"], 5: ["James"], 4: ["Wade", "John"], 0: ["", ""]])         XCTAssertEqual(Dictionary(grouping: array3, by: \String.count), [:])     }++    func testGetByKeys() {+        let dict = ["James": 100,+                    "Wade": 200,+                    "Bryant": 500,+                    "John": 600,+                    "Jack": 1000]+        let picked = dict.pick(keys: ["James", "Wade", "Jack"])+        XCTAssertEqual(picked, ["James": 100, "Wade": 200, "Jack": 1000])+        let noResults = dict.pick(keys: ["Michael", "Joe", "Christian"])+        XCTAssertTrue(noResults.isEmpty)++        let optionalValuesDict = ["James": 100,+                                  "Wade": nil,+                                  "Bryant": 500,+                                  "John": nil,+                                  "Jack": 1000]++        let pickedWithOptioanls = optionalValuesDict.pick(keys: ["James", "Bryant", "John"])

Can you just add an additional test with a key that doesn't exist in the original dictionary?

MaratIbragimov

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Added/dictionary filter using multiple keys

 public extension Dictionary {     func compactMapKeysAndValues<K, V>(_ transform: ((key: Key, value: Value)) throws -> (K, V)?) rethrows -> [K: V] {         return [K: V](uniqueKeysWithValues: try compactMap(transform))     }++    /// SwifterSwift: Creates a new dictionary using specified keys+    ///+    ///        var dict =  ["key1": 1, "key2": 2, "key3": 3, "key4": 4]+    ///        dict.pick(keys: ["key1", "key3", "key4"]) -> ["key1": 1, "key3": 3, "key4": 4]+    ///        dict.pick(keys: ["key2"]) -> ["key2": 2]+    ///+    /// - Complexity: O(K), where _K_  is the length of the keys array and O(K) space.+    ///+    /// - Parameter keys: An array of keys to the desired value.
    /// - Parameter keys: An array of keys of the entries that will be in the resulting dictionary.
MaratIbragimov

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Added/dictionary filter using multiple keys

 public extension Dictionary {     func compactMapKeysAndValues<K, V>(_ transform: ((key: Key, value: Value)) throws -> (K, V)?) rethrows -> [K: V] {         return [K: V](uniqueKeysWithValues: try compactMap(transform))     }++    /// SwifterSwift: Creates a new dictionary using specified keys+    ///+    ///        var dict =  ["key1": 1, "key2": 2, "key3": 3, "key4": 4]+    ///        dict.pick(keys: ["key1", "key3", "key4"]) -> ["key1": 1, "key3": 3, "key4": 4]+    ///        dict.pick(keys: ["key2"]) -> ["key2": 2]+    ///+    /// - Complexity: O(K), where _K_  is the length of the keys array and O(K) space.+    ///+    /// - Parameter keys: An array of keys to the desired value.+    ///+    /// - Returns: A new dictionary that contains specified  keys only . if none of the keys exists an empty dictioanry will be returned.
    /// - Returns: A new dictionary that contains specified keys only. If none of the keys exists an empty dictionary will be returned.
MaratIbragimov

comment created time in 9 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

 public extension Sequence where Element: Hashable {     } } -// MARK: - Methods (Numeric)+// MARK: - Methods (AdditiveArithmetic) -public extension Sequence where Element: Numeric {+public extension Sequence where Element: AdditiveArithmetic {     /// SwifterSwift: Sum of all elements in array.     ///     ///        [1, 2, 3, 4, 5].sum() -> 15     ///     /// - Returns: sum of the array's elements.     func sum() -> Element {-        return reduce(into: 0, +=)+        return reduce(.zero, +)

Why this? To me, this seems like a regression in performance, minor but still ...

guykogus

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

 public extension Sequence {     ///   - transform: transform element function to evaluate every element.     /// - Returns: Return an filtered and mapped array.     func filtered<T>(_ isIncluded: (Element) throws -> Bool, map transform: (Element) throws -> T) rethrows -> [T] {-        return try compactMap {-            if try isIncluded($0) {-                return try transform($0)-            }-            return nil-        }+        return try lazy.filter(isIncluded).map(transform)

Nice!

guykogus

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentSwifterSwift/SwifterSwift

Improve `Sequence` extensions with cleaner code and performance improvements

 public extension Sequence {     /// - Parameter condition: condition to evaluate each element against.     /// - Returns: the last element in the array matching the specified condition. (optional)     func last(where condition: (Element) throws -> Bool) rethrows -> Element? {-        for element in reversed() {-            if try condition(element) { return element }-        }-        return nil+        return try reversed().first(where: condition)

Seems like there's no much we could do here to avoid the copy of reversed() the only other implementation I could think of would be iterate forward over all items ... so we would basically trade avoid copy for a slower version ...

guykogus

comment created time in 9 days

PullRequestReviewEvent
PullRequestReviewEvent

push eventLucianoPAlmeida/swift

Butta

commit sha 69d04aad08da3245f87c6a2df35869126d48b55e

[linux] remove absolute rpath of /usr/lib/swift/linux added to many shared libraries This was presumably added as a backup, in case the libraries in a toolchain couldn't be found, but will not work well, so take it out.

view details

Dave Lee

commit sha 27330f169df5d2dcb018ab2c6615d66be91d04e2

[build] Remove unused lldb cmake

view details

Keith Smiley

commit sha ae0c380f1b0f37e11b111a06634dd4c64e67b96c

Improve -*prefix-map help text Before: ``` -coverage-prefix-map <value> -debug-prefix-map <value> ``` After: ``` -coverage-prefix-map <prefix=replacement> -debug-prefix-map <prefix=replacement> ```

view details

Joe Groff

commit sha 3364c51b1d53fd22a3adbaf3d406bd6685535221

SIL: Verify invariants of async_continuation instructions. - Enforce types of continuations and resume/error BBargs for await - Can't access the continuation again or exit the function mid-suspend

view details

Pavel Yaskevich

commit sha 9239692d00eb7a5362fe18f42dfcd9ddc687f45c

[unittests] Add a fixture for Sema unit tests

view details

Pavel Yaskevich

commit sha 0b22d91c9416e57a37829a6c471770e53f96fee2

[unittests] Extend Sema testing fixture to load stdlib (+ shims) Setup module importers, load stdlib, establish separate testing module and load a single main file there which imports standard library.

view details

Pavel Yaskevich

commit sha b2c31c394b02c0b2ae97f61e57daeeef8c770087

[unittests/Sema] Add an ability to retrieve stdlib types by name

view details

Pavel Yaskevich

commit sha dc7c9c2bfa0167180ec19f7a26029e16ef03dd60

[unittests/Sema] Add a simple integer literal type inference test

view details

Pavel Yaskevich

commit sha 6e470f5fcd55e94d5010e4621bec225314327f50

[unittest/Sema] NFC: Switch to use `AttributedImport` instead of deprecated `ImportedModuleDesc`

view details

Pavel Yaskevich

commit sha fde1af756d336cb4c22067c99fe2c83a3b026012

[unittest/Sema] Use default target triple to fix Windows build

view details

Alexis Laferrière

commit sha 8307a8d58e7ec6c5396b8e27ee4170a2f9fb844e

[Sema] Don't require availability for implicit decls Suppress warnings in synthesized code. The parent decls should already show a warning. require_explicit_availability.StructWithImplicitMembers:2:16: warning: public declarations should have an availability attribute when building with -require-explicit-availability public var hashValue: Int { get } ^

view details

Doug Gregor

commit sha f089ba9464fc164f6dc4ce01dafb1ec2f545912c

[Concurrency] Propagation of actor constraints. Implement propagation rules for global actor constraints, which can come from: * Enclosing extension or type * Superclass of a class * Overridden declaration * Requirement witnessed by a declaration * Storage declaration for an accessor

view details

Brent Royal-Gordon

commit sha a79417f48daeaa985100cafc30667a35015374b1

Tweak formatting of _Concurrency module CMakeLists.txt Helps fix rdar://66414410.

view details

swift-ci

commit sha 2c3a6e06f4edc2ed64a638e30379bbcc83479768

Merge pull request #34298 from brentdax/a-catalyst-for-nothing

view details

Dave Lee

commit sha b02dc2b25bc2c9c258370265c54d744c178a101c

LLDB_PATH_TO_SWIFT_SOURCE too

view details

Dave Lee

commit sha 52bbe11161f908d4c58cbdd2a423c68b9688b191

[build] Remove dash-dash from build-presets.ini (NFC)

view details

Doug Gregor

commit sha 2f7ff6aa398dfe65f09fb2e44bc5969fdebbc11b

[Concurrency] Allow ActorIsolation in diagnostic messages. ActorIsolation is rendered as a descriptive phrase before an entity, e.g, "actor-independent" or "global actor 'UIActor'-isolated" when used in diagnostics.

view details

Doug Gregor

commit sha 18fd4be17a6a4307e46eeeae5d5220e3b9179c23

[Concurrency] Check actor isolation consistency for overrides & subclasses. Both overriding declarations and subclasses must have the actor isolation as their overridden declarations or superclasses, respectively. Enforce this, ensuring that we're also doing the appropriate substitutions.

view details

Doug Gregor

commit sha 11cf3ceffe20ea7d32678c5d83347735cea94341

[Concurrency] Eliminate actor isolation checking for subclasses. Subclasses inherit the global actor from their superclass by default, but it's okay to change it---it's just a default that can be overridden on a per-member basis anyway.

view details

Doug Gregor

commit sha a5b15ed6309ce9c893204bec9ba8e9a2d19d9b66

[Concurrency] Substitute into superclass global actors when inheriting them.

view details

push time in 10 days

PullRequestReviewEvent

Pull request review commentapple/swift

[SR-13503] [Sema] Special InsertExplicitCall for nominal callable types

 ConstraintSystem::TypeMatchResult constraints::matchCallArguments(     if (!callArgumentMatch)       return cs.getTypeMatchFailure(locator); +    // When checking to see if the callable value can be explicit called to+    // produce the expected type, we need to make sure that we fail here for+    // missing argument (which normally have fix recorded in argument tracker)+    // except if all parameters have a default values.

I think the idea where would be to suggest adding a call and missing arguments, no?

Not really sure, that would mean a fix for a declaration like func callAsFunction(a: Int) -> Int { 0 } would be (a: <#editor placeholder#>)?

I guess we'd just need to adjust a fix for synthesized arguments to handle implicit calls to support that...

I didn't get it, have to take a look into this synthesized fix first :)

LucianoPAlmeida

comment created time in 11 days

PullRequestReviewEvent
more