File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -3814,6 +3814,13 @@ ConstraintSystem::matchTypesBindTypeVar(
3814
3814
// let's ignore this mismatch and mark affected type variable as a hole
3815
3815
// because something else has to be fixed already for this to happen.
3816
3816
if (type->is<DependentMemberType>() && !type->hasTypeVariable()) {
3817
+ // Since the binding couldn't be performed, the type variable is a
3818
+ // hole regardless whether it would be bound later to some other
3819
+ // type or not. If this is not reflected in constraint system
3820
+ // it would let the solver to form a _valid_ solution as if the
3821
+ // constraint between the type variable and the unresolved dependent
3822
+ // member type never existed.
3823
+ increaseScore(SK_Hole);
3817
3824
recordPotentialHole(typeVar);
3818
3825
return getTypeMatchSuccess();
3819
3826
}
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ protocol P { }
4
+
5
+ protocol Key {
6
+ associatedtype A : P
7
+ // expected-note@-1 {{unable to infer associated type 'A' for protocol 'Key'}}
8
+ static var value : A { get }
9
+ }
10
+
11
+ struct Values {
12
+ subscript< K: Key > ( type: K . Type ) -> K . A {
13
+ fatalError ( )
14
+ }
15
+ }
16
+
17
+ enum MyKey : Key { // expected-error {{type 'MyKey' does not conform to protocol 'Key'}}
18
+ static let value = 1
19
+ // expected-note@-1 {{candidate would match and infer 'A' = 'Int' if 'Int' conformed to 'P'}}
20
+ }
21
+
22
+ extension Values {
23
+ var myValue : Int {
24
+ get { self [ MyKey . self] }
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments