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 @@ -3856,6 +3856,13 @@ ConstraintSystem::matchTypesBindTypeVar(
38563856 // let's ignore this mismatch and mark affected type variable as a hole
38573857 // because something else has to be fixed already for this to happen.
38583858 if (type->is<DependentMemberType>() && !type->hasTypeVariable()) {
3859+ // Since the binding couldn't be performed, the type variable is a
3860+ // hole regardless whether it would be bound later to some other
3861+ // type or not. If this is not reflected in constraint system
3862+ // it would let the solver to form a _valid_ solution as if the
3863+ // constraint between the type variable and the unresolved dependent
3864+ // member type never existed.
3865+ increaseScore(SK_Hole);
38593866 recordPotentialHole(typeVar);
38603867 return getTypeMatchSuccess();
38613868 }
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