Skip to content

Commit 2394bab

Browse files
authored
Merge pull request #28116 from hborla/same-type-regression
[ConstraintSystem] Allow binding metatypes to succeed if one contains a hole
2 parents 8779e23 + b560261 commit 2394bab

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,13 @@ bool ConstraintSystem::repairFailures(
33993399
break;
34003400
}
34013401

3402+
case ConstraintLocator::InstanceType: {
3403+
if (lhs->hasUnresolvedType() || rhs->hasUnresolvedType())
3404+
return true;
3405+
3406+
break;
3407+
}
3408+
34023409
default:
34033410
break;
34043411
}

test/Constraints/same_types.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,16 @@ struct Bar<A: P1, B: P1> where A.Assoc == B.Assoc {
320320
fatalError()
321321
}
322322
}
323+
324+
protocol P7 {
325+
associatedtype A
326+
static func fn(args: A)
327+
}
328+
329+
class R<T>: P7 where T: P7, T.A == T.Type { // expected-note {{'T' declared as parameter to type 'R'}}
330+
typealias A = T.Type
331+
static func fn(args: T.Type) {}
332+
}
333+
334+
R.fn(args: R.self) // expected-error {{generic parameter 'T' could not be inferred}}
335+
// expected-note@-1 {{explicitly specify the generic arguments to fix this issue}}

validation-test/Sema/type_checker_perf/fast/rdar21374729.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ protocol P {
77
}
88

99
class R<T> : P where T : P, T.A == T.Type {
10+
// expected-note@-1 {{'T' declared as parameter to type 'R'}}
1011
typealias A = T.Type
1112
static func fn(args: T.Type) {}
1213
}
1314

1415
R.fn(args: R.self)
15-
// expected-error@-1 {{type of expression is ambiguous without more context}}
16+
// expected-error@-1 {{generic parameter 'T' could not be inferred}}
17+
// expected-note@-2 {{explicitly specify the generic arguments to fix this issue}}

0 commit comments

Comments
 (0)