Skip to content

Commit 53a5b86

Browse files
authored
Merge pull request #72493 from xedin/rdar-124482122-tests
[Tests] NFC: Add a couple of tests for parametrized opaque result types
2 parents f1bb9c8 + e0da21b commit 53a5b86

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/type/opaque.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,24 @@ func f62787_1(x: Bool) -> Optional<some Collection<Int>> {
590590
}
591591
return nil // expected-error{{underlying type for opaque result type 'Optional<some Collection<Int>>' could not be inferred from return expression}}
592592
}
593+
594+
// rdar://124482122 - Make sure that constraints are respected by opaque types
595+
protocol P3<A> {
596+
associatedtype A: P1
597+
}
598+
599+
do {
600+
struct G<A: P1>: P3 {}
601+
602+
struct S: P1 {}
603+
604+
func test1() -> some P3<Int> { // expected-note {{opaque return type declared here}}
605+
return G<S>()
606+
// expected-error@-1 {{type of local function 'test1()' requires that 'S' conform to 'Int'}}
607+
}
608+
609+
func test2() -> some P3<G<S>> { // expected-note {{opaque return type declared here}}
610+
return G<S>()
611+
// expected-error@-1 {{return type of local function 'test2()' requires that 'S' conform to 'G<S>'}}
612+
}
613+
}

0 commit comments

Comments
 (0)