Skip to content

IRGen: Use correct archetype conformance code path for opaque associated types. #26249

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

The code here was not correct in a situation where an opaque type had constraints that were
refinements of the protocol requirements of an associated type, as in:

protocol ParentProtocol {}
protocol SubProtocol: ParentProtocol {}

protocol P {
  associatedtype A: ParentProtocol
  func foo() -> A
}

struct S: P {
  func foo() -> some SubProtocol
}

because it assumed that the conformance could be found directly on the opaque type instead of
potentially via an arbitrary MetadataPath. Falling through to the code that already correctly
handles archetype conformances right below the removed code does the right thing. Fixes
rdar://problem/53081207.

@jckarter jckarter requested a review from rjmccall July 19, 2019 21:28
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 4c7b1afde145aaf54fc11b7ace6844f0cc87c5e7

@jckarter jckarter force-pushed the opaque-associated-type-witness-protocol-refinement branch from 4c7b1af to c3a6842 Compare July 20, 2019 01:36
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 4c7b1afde145aaf54fc11b7ace6844f0cc87c5e7

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 4c7b1afde145aaf54fc11b7ace6844f0cc87c5e7

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

LGTM

…ted types.

The code here was not correct in a situation where an opaque type had constraints that were
refinements of the protocol requirements of an associated type, as in:

```
protocol ParentProtocol {}
protocol SubProtocol: ParentProtocol {}

protocol P {
  associatedtype A: ParentProtocol
  func foo() -> A
}

struct S: P {
  func foo() -> some SubProtocol
}
```

because it assumed that the conformance could be found directly on the opaque type instead of
potentially via an arbitrary MetadataPath. Falling through to the code that already correctly
handles archetype conformances right below the removed code does the right thing. Fixes
rdar://problem/53081207.
@jckarter jckarter force-pushed the opaque-associated-type-witness-protocol-refinement branch from c3a6842 to e12f935 Compare July 20, 2019 04:30
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c3a68423a6575d62036b6fe88364f07d7f07e20a

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c3a68423a6575d62036b6fe88364f07d7f07e20a

@jckarter
Copy link
Contributor Author

@swift-ci Please test OS X

@jckarter jckarter merged commit c6284f4 into swiftlang:master Jul 20, 2019
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.

4 participants