Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0189-sr10033.swift
Slava Pestov bcee54b936 GSB: The combination of a superclass and conformance requirement might force a type to be concrete
A protocol can constrain an associated type to Self:

    protocol P {
      associatedtype A : Q where A.B == Self
    }

    protocol Q {
      associatedtype B
    }

And a class might conform to this protocol:

    class C : P {
      typealias A = D
    }

    class D : Q {
      typealias B = C
    }

The generic signature <Self where Self : P, Self : C> is built during
conformance checking. Since Self : C, we must have that Self.A == D;
since D.B == C, the requierement 'A.B == Self' in protocol P implies
that 'Self == C'. So the correct minimized signature here is
<Self where Self == C>.

This wasn't handled properly before, because of assumptions in
removeSelfDerived() and a couple of other places.

Fixes rdar://71677712, rdar://76155506, https://bugs.swift.org/browse/SR-10033,
https://bugs.swift.org/browse/SR-13884.
2021-04-03 23:04:39 -04:00

21 lines
317 B
Swift

// RUN: %target-swift-frontend -emit-ir -verify %s
protocol P1 {
associatedtype A2 : P2 where A2.A1 == Self
}
protocol P2 {
associatedtype A1 : P1 where A1.A2 == Self
var property: Int { get }
}
extension P2 {
var property: Int { return 0 }
}
class C1 : P1 {
class A2 : P2 {
typealias A1 = C1
}
}