Skip to content

GSB: Fix maybeResolveEquivalenceClass() with member type of superclass-constrained type #31871

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

@slavapestov slavapestov commented May 18, 2020

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 force-pushed the superclass-nested-type-fix branch from b57767a to b55f033 Compare May 18, 2020 23:18
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov force-pushed the superclass-nested-type-fix branch from b55f033 to 96d13e1 Compare May 20, 2020 00:28
…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 force-pushed the superclass-nested-type-fix branch from 96d13e1 to 653fa07 Compare May 20, 2020 00:31
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility Release

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.

1 participant