File tree Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -807,7 +807,8 @@ Type AssociatedTypeInference::computeFixedTypeWitness(
807807 // require a fixed type for this associated type.
808808 Type resultType;
809809 for (auto conformedProto : adoptee->getAnyNominal ()->getAllProtocols ()) {
810- if (!conformedProto->inheritsFrom (assocType->getProtocol ()))
810+ if (conformedProto != assocType->getProtocol () &&
811+ !conformedProto->inheritsFrom (assocType->getProtocol ()))
811812 continue ;
812813
813814 const auto genericSig = conformedProto->getGenericSignature ();
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ class TestClass :
143143// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithConstraintAndDefault() -> ConcreteMyProtocol {|};
144144// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithAnyObjectConstraint() -> some MyProtocol & AnyObject {|}
145145// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithConstraintOnProto() -> some MyProtocol {|}
146- // OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithSameTypeConstraint() -> AssocWithSameTypeConstraint {|}
146+ // OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithSameTypeConstraint() -> ConcreteMyProtocol {|}
147147// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithConformanceConstraintGeneric<T>(arg: T) -> AssocWithConformanceConstraintGeneric {|}
148148// OVERRIDE: End completions
149149}
Original file line number Diff line number Diff line change 11// RUN: %target-typecheck-verify-swift
22
33protocol P1 where A == Never {
4- associatedtype A // expected-note {{protocol requires nested type 'A'}}
4+ associatedtype A
55}
6- // FIXME: Should this infer A := Never?
7- struct S1 : P1 { } // expected-error {{type 'S1' does not conform to protocol 'P1'}}
6+ struct S1 : P1 { } // OK, A := Never
87
98protocol P2a {
109 associatedtype A
@@ -54,22 +53,19 @@ protocol P7b: P7a where A == Bool {}
5453struct S7 : P7b { }
5554
5655protocol P8 where A == Bool {
57- associatedtype A // expected-note {{protocol requires nested type 'A'}}
56+ associatedtype A
5857}
59- // expected-error@+2 {{type 'S8' does not conform to protocol 'P7a' }}
60- // expected-error @+1 {{type 'S8' does not conform to protocol 'P8' }}
58+ // expected-error@+2 {{'P7a' requires the types 'S8.A' (aka 'Bool') and 'Never' be equivalent }}
59+ // expected-note @+1 {{requirement specified as 'Self.A' == 'Never' [with Self = S8] }}
6160struct S8 : P8 , P7a { }
6261
6362protocol P9a where A == Never {
6463 associatedtype A
6564}
6665protocol P9b : P9a {
67- associatedtype A // expected-note {{protocol requires nested type 'A'}}
66+ associatedtype A
6867}
69- // FIXME: Associated type restatement sabotages the conformance.
70- // expected-error@+2 {{type 'S9a' does not conform to protocol 'P9a'}}
71- // expected-error@+1 {{type 'S9a' does not conform to protocol 'P9b'}}
72- struct S9a : P9b { }
68+ struct S9a : P9b { } // OK, A := Never
7369// expected-error@+2 {{'P9a' requires the types 'S9b.A' (aka 'Bool') and 'Never' be equivalent}}
7470// expected-note@+1 {{requirement specified as 'Self.A' == 'Never' [with Self = S9b]}}
7571struct S9b : P9b {
You can’t perform that action at this time.
0 commit comments