Skip to content

[IDE] Fix superclass constraint handling for extension merging #37295

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
May 7, 2021

Conversation

hamishknight
Copy link
Contributor

For a case like:

public class C<T> {}
public class D {}

extension C where T : D {
  public func foo() {}
}

We would indadvertedly drop the extension for C in the doc info, as the superclass constraint would fail the isBindableToSuperclassOf check. Instead, map the subject type of the constraint into the context and check if it could be bound to the superclass. In the example above, this is trivially true, but for cases where we're mirroring a protocol extension onto the type, this will disregard those that don't fulfil the requirements.

Resolves rdar://76868074

For a case like:

```
public class C<T> {}
public class D {}

extension C where T : D {
  public func foo() {}
}
```

We would indadvertedly drop the extension for `C`
in the doc info, as the superclass constraint would
fail the `isBindableToSuperclassOf` check.
Instead, map the subject type of the constraint
into the context and check if it could be bound to
the superclass. In the example above, this is
trivially true, but for cases where we're mirroring
a protocol extension onto the type, this will
disregard those that don't fulfil the requirements.

Resolves rdar://76868074
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight requested a review from akyrtzi May 6, 2021 21:28
@hamishknight hamishknight merged commit 61be047 into swiftlang:main May 7, 2021
@hamishknight hamishknight deleted the extra-extensions branch May 7, 2021 09:49
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