File tree 3 files changed +10
-13
lines changed
3 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -807,7 +807,8 @@ Type AssociatedTypeInference::computeFixedTypeWitness(
807
807
// require a fixed type for this associated type.
808
808
Type resultType;
809
809
for (auto conformedProto : adoptee->getAnyNominal ()->getAllProtocols ()) {
810
- if (!conformedProto->inheritsFrom (assocType->getProtocol ()))
810
+ if (conformedProto != assocType->getProtocol () &&
811
+ !conformedProto->inheritsFrom (assocType->getProtocol ()))
811
812
continue ;
812
813
813
814
const auto genericSig = conformedProto->getGenericSignature ();
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ class TestClass :
143
143
// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithConstraintAndDefault() -> ConcreteMyProtocol {|};
144
144
// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithAnyObjectConstraint() -> some MyProtocol & AnyObject {|}
145
145
// 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 {|}
147
147
// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithConformanceConstraintGeneric<T>(arg: T) -> AssocWithConformanceConstraintGeneric {|}
148
148
// OVERRIDE: End completions
149
149
}
Original file line number Diff line number Diff line change 1
1
// RUN: %target-typecheck-verify-swift
2
2
3
3
protocol P1 where A == Never {
4
- associatedtype A // expected-note {{protocol requires nested type 'A'}}
4
+ associatedtype A
5
5
}
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
8
7
9
8
protocol P2a {
10
9
associatedtype A
@@ -54,22 +53,19 @@ protocol P7b: P7a where A == Bool {}
54
53
struct S7 : P7b { }
55
54
56
55
protocol P8 where A == Bool {
57
- associatedtype A // expected-note {{protocol requires nested type 'A'}}
56
+ associatedtype A
58
57
}
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] }}
61
60
struct S8 : P8 , P7a { }
62
61
63
62
protocol P9a where A == Never {
64
63
associatedtype A
65
64
}
66
65
protocol P9b : P9a {
67
- associatedtype A // expected-note {{protocol requires nested type 'A'}}
66
+ associatedtype A
68
67
}
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
73
69
// expected-error@+2 {{'P9a' requires the types 'S9b.A' (aka 'Bool') and 'Never' be equivalent}}
74
70
// expected-note@+1 {{requirement specified as 'Self.A' == 'Never' [with Self = S9b]}}
75
71
struct S9b : P9b {
You can’t perform that action at this time.
0 commit comments