Skip to content

SILGen: Lower formal callee type pre-opaque-type-substitution. #33276

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

jckarter
Copy link
Contributor

@jckarter jckarter commented Aug 4, 2020

Explanation: Fixes a regression in handling generic functions that are called with opaque types as their generic arguments, which would cause functions generically returning functions or metatypes to crash or potentially miscompile.

Scope: Regression from Swift 5.2

Risk: Low.

Testing: Swift CI, compatibility suite

Reviewed by: @aschwaighofer

Prior to this fix, if we called a generic function with a substitutable opaque type as its formal substitution,
as in:

```
func opaque() -> some Any { return { } as ()->() }
func generic<T>(_ x: T) -> T { return x }

let x = generic(opaque())
```

then we would generate the formal type of the callee using the substitutions *after* opaque type expansion,
causing us to emit functions and metatypes at the wrong abstraction level and crash with SIL-level type mismatches.

Fixes rdar://problem/65683913.
@jckarter jckarter requested a review from a team as a code owner August 4, 2020 01:30
@jckarter
Copy link
Contributor Author

jckarter commented Aug 4, 2020

@swift-ci Please test

@jckarter
Copy link
Contributor Author

jckarter commented Aug 4, 2020

@swift-ci Please test source compatibility

@jckarter jckarter added the r5.3 label Aug 4, 2020
@jckarter
Copy link
Contributor Author

jckarter commented Aug 4, 2020

Compatibility suite failures look like server configuration issues unrelated to this change.

@jckarter
Copy link
Contributor Author

jckarter commented Aug 4, 2020

@swift-ci Please nominate

@jckarter jckarter merged commit 8565544 into swiftlang:release/5.3 Aug 4, 2020
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants