Skip to content

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 11, 2019

This takes the patch from #23624 and adds a fix for a tricky bug in ProtocolConformance::getWitnessDeclRef(). Also a couple of tiny related cleanups. Thanks @pschuh for the actual refactoring!

slavapestov and others added 4 commits June 11, 2019 02:47
…emanticExpr.

For reference, all other literal types except dictionaries and string
interpolation have been converted over to this form.
This method was only ever called with non-generic witnesses,
because it assumed the substitutions stored in the witness
would always be derived from the conforming type.

There were two cases where this wasn't the case though:

1) If the witness is itself generic
2) The witness was defined in a protocol extension and the
   conforming type is a non-final class

In all cases, the SubstitutionMap stored in a Witness always
uses the 'synthetic environment'. In some cases, the
'synthetic environment' is the generic environment of the
witness. But in 1) and 2) it was different. While 1) never
occurred because we never used this method to look up
witnesses for generic requirements, 2) could happen.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test


// If the witness is generic, you have to call getWitness() and build
// your own substitutions in terms of the synthetic environment.
if (auto *witnessDC = dyn_cast<DeclContext>(witnessDecl))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be triggered by just another level of genericness in the crasher example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ll take a look. It would not have worked before anyway though.

@slavapestov slavapestov merged commit 5d59600 into swiftlang:master Jun 11, 2019
@compnerd
Copy link
Member

compnerd commented Jun 11, 2019

@compnerd
Copy link
Member

I would have expected this to break 32-bit iOS as well

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.

3 participants