-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILGen: Properly calculate substitutions to invoke _bridgeToObjectiveC. #4990
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
@swift-ci Please smoke test |
@slavapestov Mind reviewing for 3.x? |
@adrian-prantl Any idea where this assertion failure would come from?
|
Adrian reverted here... it should merge soon |
@swift-ci Please smoke test OS X |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for 3.0. Let's spend some time thinking about the right abstractions so we can clean this up later -- along with witness thunk emission, and the stuff in the devirtualizer for building substitutions...
ArrayRef<Substitution> substitutions = | ||
swiftValueType->gatherAllSubstitutions( | ||
gen.SGM.SwiftModule, nullptr); | ||
ArrayRef<Substitution> witnessSubstitutions = witness.getSubstitutions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty epic -- I wanted to clean up witness substitutions at some point since I've got a few changes that are blocked on representation issues, and this provides even more motivation.
GenericEnvironment *witnessEnv; | ||
GenericSignature *witnessSig; | ||
|
||
if (witness.getDecl()->getDeclContext()->getDeclaredTypeOfContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMemberSubstitutions() does the right thing for a member of a protocol vs member of a concrete type (it takes a base and a DC for the member), but this is fine for now.
The existing code assumed that the _bridgeToObjectiveC witness would never come from a protocol extension. Generating the correct set of substitutions is a bit harder than it ought to be, due to inconsistencies in how Sema represents generic witnesses. Fixes rdar://problem/28279269.
2d086db
to
c698da6
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
Linux failure looks unrelated. @ddunbar or @parkera, you know what's going on here?
|
@swift-ci Please smoke test Linux |
The existing code assumed that the
_bridgeToObjectiveC
witness would never come from a protocol extension. Generating the correct set of substitutions is a bit harder than it ought to be, due to inconsistencies in how Sema represents generic witnesses. The right thing to do is probably to emit awitness_method
invocation and let the specializer work out the underlying witness, but for now, get a minimal fix in place for 3.x. Fixes rdar://problem/28279269.