-
Notifications
You must be signed in to change notification settings - Fork 10.5k
GSB: use a request for the structural type of type aliases #24204
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
Conversation
@swift-ci Please smoke test |
191fdc5
to
d3b7306
Compare
@swift-ci Please smoke test |
d3b7306
to
44c9459
Compare
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
Fix looks good |
@swift-ci Please smoke test macOS |
…iases This request evaluator doesn't rely on the previous execution of a compilation phase but it caches the result in a compatible way.
58f6c5e
to
9e6713d
Compare
@swift-ci Please smoke test macOS |
@swift-ci Please smoke test Linux |
@swift-ci Please test source compatibility |
lib/Sema/TypeCheckGeneric.cpp
Outdated
TypeAliasDecl *D) const { | ||
auto typeRepr = D->getUnderlyingTypeLoc().getTypeRepr(); | ||
auto resolution = TypeResolution::forStructural(D); | ||
return resolution.resolveType(typeRepr, None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use the same options as in validateTypeAliasType()
:
TypeResolutionOptions options(
(typeAlias->getGenericParams() ?
TypeResolverContext::GenericTypeAliasDecl :
TypeResolverContext::TypeAliasDecl));
if (!typeAlias->getDeclContext()->isCascadingContextForLookup(
/*functionsAreNonCascading*/true)) {
options |= TypeResolutionFlags::KnownNonCascadingDependency;
}
For now you can just copy and paste that code, we'll factor it out later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... however a generic type alias will never end up here, so you remove that part. In fact, can you assert(!getGenericParams())
in TypeAliasDecl::getStructuralType()
?
…l type request The underlying type may have been set on a validated type alias or when deserialized.
9e6713d
to
c27dca3
Compare
@swift-ci Please smoke test macOS |
@swift-ci Please smoke test Linux |
@swift-ci Please test source compatibility |
It looks like expandConformanceRequirement() needs to skip generic type aliases altogether. |
... and generic types in general. They're not something the GSB tries to model anyway. |
Fixes crashes in 28437-swift-typechecker-validatedecl.swift (from previous commit) and the compiler crasher 28861-gpdecl-getdepth-generictypeparamdecl- invaliddepth-parameter-hasnt-been-validated.swift.
@swift-ci Please smoke test macOS |
@swift-ci Please smoke test Linux |
@swift-ci Please test source compatibility |
@swift-ci Please smoke test Linux |
No description provided.