Skip to content

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Sep 12, 2025

TypeChecker::resolveDeclRefExpr() would leave error nodes in the AST when performing fallback name lookups with MemberImportVisibility. When running in migration mode for MemberImportVisibility, these error nodes would then cause the compiler to either diagnose a missing error or to crash during SILGen.

Instead of restricting name lookup during TypeChecker::resolveDeclRefExpr(), allow it to find candidates with missing imports and then diagnose them if necessary before forming a resolve decl ref.

Resolves rdar://154361861.

@tshortli tshortli force-pushed the member-import-visibility-migrate-crash branch 2 times, most recently from a1960ea to d3f1868 Compare September 15, 2025 17:11
@tshortli tshortli marked this pull request as ready for review September 15, 2025 17:12
@tshortli
Copy link
Contributor Author

@swift-ci please test source compatibility debug

@tshortli
Copy link
Contributor Author

@swift-ci please test Linux

`TypeChecker::resolveDeclRefExpr()` would leave error nodes in the AST when
performing fallback name lookups with `MemberImportVisibility`. When running in
migration mode for `MemberImportVisibility`, these error nodes would then cause
the compiler to either diagnose a missing error or to crash during SILGen.

Instead of restricting name lookup during `TypeChecker::resolveDeclRefExpr()`,
allow it to find candidates with missing imports and then diagnose them if
necessary before forming a resolve decl ref.

Resolves rdar://154361861.
@tshortli tshortli force-pushed the member-import-visibility-migrate-crash branch from d3f1868 to d8fac32 Compare September 16, 2025 03:48
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli tshortli enabled auto-merge September 16, 2025 03:53
@tshortli
Copy link
Contributor Author

swiftlang/swift-foundation#1510

@swift-ci please test

@tshortli
Copy link
Contributor Author

swiftlang/swift-foundation#1512

@swift-ci please test Windows

@tshortli tshortli merged commit ba62465 into swiftlang:main Sep 16, 2025
5 checks passed
@tshortli tshortli deleted the member-import-visibility-migrate-crash branch September 16, 2025 17:44
tshortli added a commit to tshortli/swift that referenced this pull request Oct 2, 2025
The changes from swiftlang#84259 caused a
regression in which declarations from an outer scope could be shadowed
inappropriately by member declarations from a module that has not been
imported. This fix addresses the issue by refactoring `resolveDeclRefExpr()` so
that it performs lookups in two passes. First, it attempts to resolve the decl
ref using the complete lookup algorithm and standard name lookup options, which
will ignore members from modules that haven't been imported if
`MemberImportVisibility` is enabled. Then, if no results were found it re-runs
the full lookup algorithm again with `NameLookupFlags::IgnoreMissingImports`
included to find additional results that ought to be diagnosed as unavailable.
This insures that the unavailable results are not considered until after the
main lookup has already failed.

Resolves rdar://161078015.
tshortli added a commit to tshortli/swift that referenced this pull request Oct 3, 2025
The changes from swiftlang#84259 caused a
regression in which declarations from an outer scope could be shadowed
inappropriately by member declarations from a module that has not been
imported. This fix addresses the issue by refactoring `resolveDeclRefExpr()` so
that it performs lookups in two passes. First, it attempts to resolve the decl
ref using the complete lookup algorithm and standard name lookup options, which
will ignore members from modules that haven't been imported if
`MemberImportVisibility` is enabled. Then, if no results were found it re-runs
the full lookup algorithm again with `NameLookupFlags::IgnoreMissingImports`
included to find additional results that ought to be diagnosed as unavailable.
This insures that the unavailable results are not considered until after the
main lookup has already failed.

Resolves rdar://161078015.
tshortli added a commit to tshortli/swift that referenced this pull request Oct 4, 2025
The changes from swiftlang#84259 caused a
regression in which declarations from an outer scope could be shadowed
inappropriately by member declarations from a module that has not been
imported. This fix addresses the issue by refactoring `resolveDeclRefExpr()` so
that it performs lookups in two passes. First, it attempts to resolve the decl
ref using the complete lookup algorithm and standard name lookup options, which
will ignore members from modules that haven't been imported if
`MemberImportVisibility` is enabled. Then, if no results were found it re-runs
the full lookup algorithm again with `NameLookupFlags::IgnoreMissingImports`
included to find additional results that ought to be diagnosed as unavailable.
This insures that the unavailable results are not considered until after the
main lookup has already failed.

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

1 participant