Skip to content

Conversation

@tshortli
Copy link
Contributor

@tshortli tshortli commented Sep 1, 2023

When -experimental-serialize-external-decls-only is specified, skip serializing conformances to protocols that should be skipped to avoid unnecessary typechecking. Also, ensure type and value witnesses are resolved lazily during serialization by passing true for useResolver.

Resolves rdar://114799742

@tshortli
Copy link
Contributor Author

tshortli commented Sep 1, 2023

@swift-ci please test

@tshortli tshortli requested a review from slavapestov September 1, 2023 04:45
When `-experimental-serialize-external-decls-only` is specified, skip
serializing conformances to protocols that should be skipped to avoid
unnecessary typechecking. Also, ensure type and value witnesses are resolved
lazily during serialization by passing `true` for `useResolver`.

Resolves rdar://114799742
@tshortli tshortli force-pushed the emit-module-lazy-typecheck-conformances branch from 11f1be5 to fde2016 Compare September 1, 2023 15:57
@tshortli
Copy link
Contributor Author

tshortli commented Sep 1, 2023

@swift-ci please smoke test

@tshortli tshortli merged commit 1b3d9d8 into swiftlang:main Sep 1, 2023
@tshortli tshortli deleted the emit-module-lazy-typecheck-conformances branch September 1, 2023 21:13
tshortli added a commit to tshortli/swift that referenced this pull request Jan 1, 2024
Serialization now enumerates the value witnesses of conformances with a
resolver in order to facilitate lazy type checking
(swiftlang#68262). This change in behavior introduced
an assertion failure when compiling modules from swiftinterface when the
interface contains a conformance to an `@objc` protocol that has a requirement
that is imported with an `async` variant. The `forEachValueWitness()`
invocation during serialization was causing the missing witness for an objc
async protocol requirement to be resolved after conformance check was already
marked "complete". This witness had not been previously resolved because
`ConformanceChecker::resolveValueWitnesses()` had special logic to skip objc
protocol requirements with witnessed siblings, whereas `forEachValueWitness()`
did not.

There are multiple potential solutions to this problem, but the one that seemed
least disruptive to me was to stop skipping resolution of these sibling
witnesses during `ConformanceChecker::resolveValueWitnesses()`. When I looked
into why they were being skipped, I discovered that this seemed to be a
concession to bugs in the logic for pruning missing witnesses. When I adjusted
the pruning logic it no longer became necessary to skip witnesses in
`ConformanceChecker::resolveValueWitnesses()` in order to avoid incorrect
diagnostics.

Resolves rdar://119435253
Catfish-Man pushed a commit to Catfish-Man/swift that referenced this pull request Jan 19, 2024
Serialization now enumerates the value witnesses of conformances with a
resolver in order to facilitate lazy type checking
(swiftlang#68262). This change in behavior introduced
an assertion failure when compiling modules from swiftinterface when the
interface contains a conformance to an `@objc` protocol that has a requirement
that is imported with an `async` variant. The `forEachValueWitness()`
invocation during serialization was causing the missing witness for an objc
async protocol requirement to be resolved after conformance check was already
marked "complete". This witness had not been previously resolved because
`ConformanceChecker::resolveValueWitnesses()` had special logic to skip objc
protocol requirements with witnessed siblings, whereas `forEachValueWitness()`
did not.

There are multiple potential solutions to this problem, but the one that seemed
least disruptive to me was to stop skipping resolution of these sibling
witnesses during `ConformanceChecker::resolveValueWitnesses()`. When I looked
into why they were being skipped, I discovered that this seemed to be a
concession to bugs in the logic for pruning missing witnesses. When I adjusted
the pruning logic it no longer became necessary to skip witnesses in
`ConformanceChecker::resolveValueWitnesses()` in order to avoid incorrect
diagnostics.

Resolves rdar://119435253
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.

2 participants