Skip to content

GSB: Fix maybeResolveEquivalenceClass() with member type of superclass-constrained type [5.3] #31923

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

Conversation

slavapestov
Copy link
Contributor

Name lookup might find an associated type whose protocol is not in our
conforms-to list, if we have a superclass constraint and the superclass
conforms to the associated type's protocol.

We used to return an unresolved type in this case, which would result in
the constraint getting delayed forever and dropped.

While playing wack-a-mole with regressing crashers, I had to do some
refactoring to get all the tests to pass. Unfortuanately these refactorings
don't lend themselves well to being peeled off into their own commits:

  • maybeAddSameTypeRequirementForNestedType() was almost identical to
    concretizeNestedTypeFromConcreteParent(), except for superclasses
    instead of concrete same-type constraints. I merged them together.

  • We used to drop same-type constraints where the subject type was an
    ErrorType, because maybeResolveEquivalenceClass() would return an
    unresolved type in this case.

    This violated some invariants around nested types of ArchetypeTypes,
    because now it was possible for a nested type of a concrete type to
    be non-concrete, if the type witness in the conformance was missing
    due to an error.

    Fix this by removing the ErrorType hack, and adjusting a couple of
    other places to handle ErrorTypes in order to avoid regressing with
    invalid code.

Fixes rdar://problem/45216921, https://bugs.swift.org/browse/SR-8945,
https://bugs.swift.org/browse/SR-12744.

AnthonyLatsis and others added 2 commits May 20, 2020 15:04
…s-constrained type

Name lookup might find an associated type whose protocol is not in our
conforms-to list, if we have a superclass constraint and the superclass
conforms to the associated type's protocol.

We used to return an unresolved type in this case, which would result in
the constraint getting delayed forever and dropped.

While playing wack-a-mole with regressing crashers, I had to do some
refactoring to get all the tests to pass. Unfortuanately these refactorings
don't lend themselves well to being peeled off into their own commits:

- maybeAddSameTypeRequirementForNestedType() was almost identical to
  concretizeNestedTypeFromConcreteParent(), except for superclasses
  instead of concrete same-type constraints. I merged them together.

- We used to drop same-type constraints where the subject type was an
  ErrorType, because maybeResolveEquivalenceClass() would return an
  unresolved type in this case.

  This violated some invariants around nested types of ArchetypeTypes,
  because now it was possible for a nested type of a concrete type to
  be non-concrete, if the type witness in the conformance was missing
  due to an error.

  Fix this by removing the ErrorType hack, and adjusting a couple of
  other places to handle ErrorTypes in order to avoid regressing with
  invalid code.

Fixes <rdar://problem/45216921>, <https://bugs.swift.org/browse/SR-8945>,
<https://bugs.swift.org/browse/SR-12744>.
@slavapestov slavapestov requested a review from a team as a code owner May 20, 2020 19:06
@tkremenek
Copy link
Member

@swift-ci test and merge

@swift-ci swift-ci merged commit bc5c85c into swiftlang:release/5.3 Jun 17, 2020
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants