Skip to content

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

Merged
merged 5 commits into from
Sep 19, 2018

Conversation

slavapestov
Copy link
Contributor

I started looking at a fix for rdar://44429394 and ended up doing this first...

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

return getGenericParamsOfContext()->getParams().front()
auto *genericParams = getGenericParamsOfContext();
if (genericParams == nullptr)
return nullptr;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

/// typealias GX2<A> = X<A, A>
/// typealias GX3<A, B> = X<B, A>
/// \endcode
bool isPassThroughTypealias(TypeAliasDecl *typealias) {
Copy link
Contributor

Choose a reason for hiding this comment

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

static?

Copy link
Contributor Author

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().
@slavapestov slavapestov force-pushed the validate-extension-cleanup branch from f977555 to 4c7e889 Compare September 19, 2018 16:47
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Member

@DougGregor DougGregor left a 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))
Copy link
Member

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).

@slavapestov slavapestov merged commit 165f658 into swiftlang:master Sep 19, 2018
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.

3 participants