Skip to content

[Sema] Extend fix for reference storage types in protocol witnesses to include generics. #12446

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
Oct 16, 2017

Conversation

gregomni
Copy link
Contributor

Had wrongly disregarded generic conformers in my original fix for sr-6097. This commit extends that fix.

(I had only been thinking in terms of methods with generic parameters before (which obviously couldn't contain reference storage types) -- oops.)

@gregomni
Copy link
Contributor Author

@swift-ci Please smoke test

@gregomni
Copy link
Contributor Author

@slavapestov Should've asked for review on the last one, sorry... can you take a quick glance at this?

As far as the deduction in the tests -- the indication of regression would be errors during compilation, a la:

gen.swift:5:7: error: type 'G<T>' does not conform to protocol 'SomeProto'
class G<T> : SomeProto where T : AnyObject {
      ^
gen.swift:2:18: protocol requires nested type 'A'; do you want to add it?

If you did somehow get past Sema with a conformance where the associated type witness was still weak/unowned you'd run into asserts in Silgen in generating the witness table functions, because Silgen doesn't know how to do those wrong type transformations. (I went down this blind alley for a bit.)

@slavapestov
Copy link
Contributor

This looks good, thanks!

Indeed we don't want associated type witnesses to have weak or unowned types. At the SILGen level, a storage requirement is witnessed by the getter/setter pair, and the type of the getter and setter does not include weak or unowned. Essentially those are not types at all, but a property of how the underlying storage is implemented.

@slavapestov slavapestov merged commit d442fb8 into swiftlang:master Oct 16, 2017
@gregomni gregomni deleted the 6097 branch August 18, 2020 23:12
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.

2 participants