-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Clean up extension validation #19386
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
Clean up extension validation #19386
Conversation
@swift-ci Please test |
@swift-ci Please test source compatibility |
return getGenericParamsOfContext()->getParams().front() | ||
auto *genericParams = getGenericParamsOfContext(); | ||
if (genericParams == nullptr) | ||
return nullptr; |
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.
When does this come up for a protocol extension?
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.
Invalid code, like when an extension is inside of another decl, we don't build the generic parameter list for it anymore.
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.
But we still bind the underlying type? Okay.
lib/Sema/TypeCheckDecl.cpp
Outdated
/// typealias GX2<A> = X<A, A> | ||
/// typealias GX3<A, B> = X<B, A> | ||
/// \endcode | ||
bool isPassThroughTypealias(TypeAliasDecl *typealias) { |
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.
static
?
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.
Right...
…es() Instead, call validateExtension(), but only after we've already ruled out the non-protocol extension case, because we can do that by using getExtendedNominal().
We'll instead diagnose them when we type check their primary file, since typeCheckDecl() calls validateExtension() whcih calls bindExtension().
f977555
to
4c7e889
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.
Thanks!
auto extendedNominal = aliasDecl->getDeclaredInterfaceType()->getAnyNominal(); | ||
if (extendedNominal) { | ||
extendedType = extendedNominal->getDeclaredType(); | ||
if (!isPassThroughTypealias(aliasDecl)) |
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.
I suppose this is where we should diagnose non-passthrough typealias
declarations that will turn into extensions of the underlying nominal type (and not become parameterized extensions magically).
I started looking at a fix for rdar://44429394 and ended up doing this first...