Skip to content

[Serialization] Allow unbound generic types to cross-reference typealias decls #16784

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 1 commit into from
May 23, 2018

Conversation

xedin
Copy link
Contributor

@xedin xedin commented May 23, 2018

Ideally UnboundGenericType should never be serialized but it is
currently allowed to make generic typealias declarations without
specifying generic parameters, so it should be allowed to cross
reference typealias decls in such types as well because NameAliasType
can't be used until generic parameters are resolved.

This is only a temporary fix and more comprehensive solution is still
pending here, most likely such declarations should not produce
UnboundGenericType but instead should copy generic parameters from
underlying type and produce proper NameAliasType.

Resolves: rdar://problem/37384120

…ias decls

Ideally `UnboundGenericType` should never be serialized but it is
currently allowed to make generic `typealias` declarations without
specifying generic parameters, so it should be allowed to cross
reference typealias decls in such types as well because `NameAliasType`
can't be used until generic parameters are resolved.

This is only a temporary fix and more comprehensive solution is still
pending here, most likely such declarations should not produce
`UnboundGenericType` but instead should copy generic parameters from
underlying type and produce proper `NameAliasType`.

Resolves: rdar://problem/37384120
@xedin xedin requested review from DougGregor and jrose-apple May 23, 2018 01:25
Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Hm. The original logic to always go through NameAliasType was intended to make sure a typealias that failed to import could always be replaced by its underlying type. But the logic for serialization recovery already isn't very strong for generic types, and this wouldn't be a regression because it's just doing what a no-asserts build would do anyway. Okay, we can take this.

@slavapestov
Copy link
Contributor

Ah yes, this is an annoying corner case. I agree we should “desugar” such type aliases early instead of forming UnboundGenericType as a long term fix. It’s only on accident that this construct was even accepted at all, but now we’re stuck with it.

@xedin
Copy link
Contributor Author

xedin commented May 23, 2018

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented May 23, 2018

@swift-ci please test source compatibility

@xedin xedin merged commit e27af10 into swiftlang:master May 23, 2018
@DougGregor
Copy link
Member

We might be able to stage out this construct, but regardless... we need to fix the modeling problem at some point.

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.

4 participants