Skip to content

Commit 9b73885

Browse files
committed
RequirementMachine: Enable concrete contraction for nested type parameters
Fixes rdar://problem/91594361.
1 parent 5068393 commit 9b73885

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

lib/AST/RequirementMachine/ConcreteContraction.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,6 @@ bool ConcreteContraction::performConcreteContraction(
518518
assert(subjectType->isTypeParameter() &&
519519
"You forgot to call desugarRequirement()");
520520

521-
if (!subjectType->is<GenericTypeParamType>())
522-
continue;
523-
524521
auto kind = req.req.getKind();
525522
switch (kind) {
526523
case RequirementKind::SameType: {

test/Generics/rdar91594361.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
2+
3+
protocol P1 {
4+
associatedtype T
5+
}
6+
7+
protocol P2 {
8+
associatedtype T : P3
9+
}
10+
11+
protocol P3 {}
12+
13+
struct G<T : P3> : P2 {}
14+
15+
extension P1 where T : P2 {
16+
// CHECK-LABEL: .foo@
17+
// CHECK-NEXT: <Self, X where Self : P1, X : P3, Self.[P1]T == G<X>>
18+
func foo<X>(_: X) where T == G<X> {}
19+
}
20+

test/Generics/requirement_inference.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=verify -requirement-machine-inferred-signatures=off
2-
// RUN: not %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=verify -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=verify
2+
// RUN: not %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
33

44
protocol P1 {
55
func p1()

test/Generics/requirement_machine_diagnostics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,18 @@ func sameTypeConflicts() {
295295
fatalError()
296296
}
297297

298-
// expected-error@+1{{no type for 'T.Bar.Foo' can satisfy both 'T.Bar.Foo == X' and 'T.Bar.Foo == Z'}}
299298
func fail4<T: Barrable>(_ t: T) -> (Y, Z)
300299
where
301300
T.Bar == Y,
302301
T.Bar.Foo == Z {
302+
// expected-error@-1{{generic signature requires types 'Y.Foo' (aka 'X') and 'Z' to be the same}}
303303
fatalError()
304304
}
305305

306-
// expected-error@+1{{no type for 'T.Bar.Foo' can satisfy both 'T.Bar.Foo == X' and 'T.Bar.Foo == Z'}}
307306
func fail5<T: Barrable>(_ t: T) -> (Y, Z)
308307
where
309308
T.Bar.Foo == Z,
309+
// expected-error@-1{{generic signature requires types 'Y.Foo' (aka 'X') and 'Z' to be the same}}
310310
T.Bar == Y {
311311
fatalError()
312312
}

test/attr/accessibility_where_clause.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=off
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=on
22

33
public class OuterClass {
44
class InnerClass {}
@@ -17,9 +17,6 @@ public protocol PublicProto2 {
1717
// FIXME: Once we no longer do that, come up with another strategy
1818
// to make the above diagnose.
1919

20-
// FIXME: Get this working with the Requirement Machine, or decide that it should
21-
// be unsupported: rdar://90469477
22-
2320
extension PublicProto2 where Self.T : OuterClass, Self.U == Self.T.InnerClass {
2421
public func cannotBePublic() {}
2522
// expected-error@-1 {{cannot declare a public instance method in an extension with internal requirements}}

0 commit comments

Comments
 (0)