Skip to content
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

[Availability] Lazily expand type refinement contexts for extensions. #71365

Merged
merged 1 commit into from Feb 5, 2024

Conversation

hborla
Copy link
Member

@hborla hborla commented Feb 3, 2024

When resolving an attached macro, the constraint system needs to check whether a potential macro candidate is available in the current context. That triggers building a type refinement context, and when the macro is applied at the top-level, building the type refinement context needs to resolve extensions because extensions get their availability from the extended type. However, if the extended type is nested inside another type that has attached macros, those macros must be expanded to produce any member types that might be added by the macro. This leads to circularity errors that cannot be resolved.

This change opts extension declarations into lazily building a TRC to avoid needing to resolve the extended type while building a type refinement context to check availability at an unrelated source location in the same file.

Resolves rdar://115851283

@hborla
Copy link
Member Author

hborla commented Feb 3, 2024

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Feb 3, 2024

@swift-ci please test source compatibility

@hborla hborla marked this pull request as ready for review February 3, 2024 20:02
@hborla hborla merged commit 93b68cd into apple:main Feb 5, 2024
5 checks passed
@hborla hborla deleted the lazy-trc-extension branch February 5, 2024 16:06
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.

None yet

2 participants