Skip to content

Commit f03274b

Browse files
committed
Add regression test to close #51217
1 parent 927d099 commit f03274b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/Generics/unbound.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,34 @@ func nested(_: OuterStruct.InnerStruct<Int>) {}
106106

107107
func nested(_: OuterStruct<Int>.InnerStruct) {}
108108
// expected-error@-1 {{reference to generic type 'OuterStruct<Int>.InnerStruct' requires arguments in <...>}}
109+
110+
111+
func assertExactType<T>(of _: T, is _: T.Type) {}
112+
113+
// https://github.com/apple/swift/issues/51217
114+
protocol P {
115+
associatedtype A
116+
associatedtype B
117+
}
118+
do {
119+
struct Concrete: P {
120+
typealias A = Int
121+
typealias B = Bool
122+
}
123+
struct Generic<A, B>: P {}
124+
125+
struct BinderGenericParams1<T1: P, T2: P>
126+
where T1.A == T2.A, T1.B == T2.B {
127+
static func bind(_: T1, _: T2) -> T2 {}
128+
}
129+
struct BinderGenericParams2 {
130+
static func bind<T1: P, T2: P>(_: T1, _: T2) -> T2
131+
where T1.A == T2.A, T1.B == T2.B {}
132+
}
133+
134+
let x1 = BinderGenericParams1.bind(Concrete(), Generic())
135+
let x2 = BinderGenericParams2.bind(Concrete(), Generic())
136+
137+
assertExactType(of: x1, is: Generic<Int, Bool>.self)
138+
assertExactType(of: x2, is: Generic<Int, Bool>.self)
139+
}

0 commit comments

Comments
 (0)