Skip to content

[SE-0326] Re-enable multi-statement closure inference by default #41730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Mar 8, 2022

Fixes a performance regression related to one-way constraints and re-enables
multi-statement closure inference by default.

The changes include:

  • New locator for each pattern binding element
  • Recording a type of a named pattern declaration in a constraint system
  • Solving pattern bindings declarations via conjunctions

Resolves: rdar://88205521

xedin added 2 commits March 7, 2022 10:51
The new element points to an index of a particular pattern in a
pattern binding declaration.
@xedin xedin requested a review from hborla March 8, 2022 20:07
@xedin
Copy link
Contributor Author

xedin commented Mar 8, 2022

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 8, 2022

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Mar 8, 2022

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 8, 2022

@shahmishal FYI source compat suite is failing with [/Users/ec2-user/jenkins/workspace-private/swift-PR-source-compat-suite-macos/swift/utils/build-script] ERROR: can't find CMake (please install CMake)

@xedin
Copy link
Contributor Author

xedin commented Mar 9, 2022

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 9, 2022

There are a couple of unrelated issues in the source compatibility suite:

  • Eureka is crashing in request evaluator:
Cannot build interface type for term [OptionsProviderRow:OptionsProviderType].[OptionsProviderConformance:Option]
Prefix does not conform to any protocols: [OptionsProviderRow:OptionsProviderType]
  • Moya conformance failure:
error: type 'MoyaProvider<Target>' does not conform to protocol 'ReactiveCompatible'
extension MoyaProvider: ReactiveCompatible {}
  • SwiftGraph conformance failure due to unavailable subscript:
error: type 'Graph<V>' does not conform to protocol 'Collection'
open class Graph<V: Equatable>: CustomStringConvertible, Sequence, Collection {
           ^
/Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-debug-macos/swift-source-compat-suite/project_cache/SwiftGraph/Sources/SwiftGraph/Graph.swift:22:12: error: unavailable subscript 'subscript(_:)' was used to satisfy a requirement of protocol 'Collection'
open class Graph<V: Equatable>: CustomStringConvertible, Sequence, Collection {
           ^

xedin added 4 commits March 8, 2022 21:37
This is going to be used by multi-statement closure inference
because patterns could be declarated and referenced in the body
via the associated declaration.
`one-way` constraints disable some optimizations related to component
selection because they imply strict ordering. This is a problem for
multi-statement closures because variable declarations could involve
complex operator expressions that rely on aforementioned optimizations.

In order to fix that, let's move away from solving whole pattern binding
declaration into scheme that explodes such declarations into indvidual
elements and inlines them into a conjunction.

For example:

```
let x = 42, y = x + 1, z = (x, test())
```

Would result in a conjunction of three elements:

```
x = 42
y = x + 1
z = (x, test())
```

Each element is solved indepedently, which eliminates the need for
`one-way` constraints and re-enables component selection optimizations.
@xedin xedin force-pushed the se-0326-solve-pattern-bindings-via-conjunctions branch from ffe26c3 to 5e4c964 Compare March 9, 2022 05:38
@shahmishal
Copy link
Member

@swift-ci please test source compatibility

@shahmishal
Copy link
Member

@shahmishal FYI source compat suite is failing with [/Users/ec2-user/jenkins/workspace-private/swift-PR-source-compat-suite-macos/swift/utils/build-script] ERROR: can't find CMake (please install CMake)

This should be fixed now.

@xedin
Copy link
Contributor Author

xedin commented Mar 9, 2022

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 9, 2022

@swift-ci please test

Copy link
Member

@hborla hborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, lgtm!

@xedin
Copy link
Contributor Author

xedin commented Mar 15, 2022

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Mar 15, 2022

@swift-ci please test Linux platform

@xedin
Copy link
Contributor Author

xedin commented Mar 15, 2022

@swift-ci please test macOS platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants