File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments