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

IRGen: Derive the proper formal Self type for @convention(*method) methods on Optional. #5492

Merged
merged 1 commit into from Oct 27, 2016

Conversation

jckarter
Copy link
Member

Now that Optional's type parameter can be lowered, we can't make the assumption that a substituted nominal type in SIL is usable as-is as a formal type. At this moment, we can at least still rely on the fact that only nominals have methods, so we can at least go up to the original unsubstituted function type, extract the nominal Self type from there, and do formal AST type substitution on it. This is still only a stopgap solution that wouldn't necessarily work once we start allowing conformances to be added to structural types, or even constrained extensions on Optional such as extension <T: class, U: class> Optional<(T) -> U>, but is good enough to fix SR-3021 for the language today. We would need something like the "substituted generic signature" concept to fully fix this.

…thods on Optional.

Now that Optional's type parameter can be lowered, we can't make the assumption that a substituted nominal type in SIL is usable as-is as a formal type. At this moment, we can at least still rely on the fact that only nominals have methods, so we can at least go up to the original unsubstituted function type, extract the Self type from there, and do formal AST type substitution on it. This is still only a stopgap solution that wouldn't necessarily work once we start allowing conformances to be added to structural types, or even constrained extensions on Optional such as 'extension <T: class, U: class> Optional<(T) -> U>, but is good enough to fix SR-3021 for the language today. We would need something like the "substituted generic signature" concept to fully fix this.
@jckarter
Copy link
Member Author

@swift-ci Please smoke test and merge

@jckarter
Copy link
Member Author

@rjmccall Mind reviewing this for 3.0 as well?

@swift-ci swift-ci merged commit fa885d7 into apple:master Oct 27, 2016
@rjmccall
Copy link
Member

Ah, yes, that makes sense. I agree with both your short-term fix and the longer-term proposal to use a substituted function type.

@rjmccall
Copy link
Member

To be clear, LGTM. :)

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

3 participants