Skip to content

Conversation

@beccadax
Copy link
Contributor

@beccadax beccadax commented Nov 14, 2025

When a DeclRefTypeRepr is bound to a known declaration, the exact DeclNameRef used to create it is erased. This means that we no longer know exactly which module selector was used in the source code, so repeating the lookup with the same instance might produce different results.

Avoid this problem by reusing the bound decl instead of trying to look up the same declaration again.

Fixes rdar://164647850.

@beccadax
Copy link
Contributor Author

@slavapestov I think you might be the best person to review this.

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

❤️

@nkcsgexi
Copy link
Contributor

Looks like we've fixed a compiler crasher with this diff:

16:49:12  ********************
16:49:12  Failed Tests (1):
16:49:12    Swift-validation(macosx-x86_64) :: compiler_crashers/RequirementMachine-areReducedTypeParametersEqual-1801de.swift

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Sure, that’s reasonable. FWIW I’d like to get rid of the bound decl entirely at some point. Caching the result of these lookups is best handled at higher levels.

@beccadax beccadax force-pushed the mod-squad-bound-by-its-word branch from 66a2d6c to 22477f2 Compare November 15, 2025 10:20
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax beccadax enabled auto-merge November 15, 2025 10:21
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

When a DeclRefTypeRepr is bound to a known declaration, the exact DeclNameRef used to create it is erased. This means that we no longer know exactly which module selector was used in the source code, so repeating the lookup with the same instance might produce different results.

Avoid this problem by reusing the bound decl instead of trying to look up the same declaration again.

Fixes rdar://164647850.
@beccadax beccadax force-pushed the mod-squad-bound-by-its-word branch from 22477f2 to b9747b7 Compare November 16, 2025 03:16
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

3 similar comments
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

beccadax commented Dec 3, 2025

@swift-ci please smoke test

@beccadax beccadax merged commit 5c2fe42 into swiftlang:main Dec 4, 2025
3 checks passed
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