mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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>.