Skip to content

Commit 2342712

Browse files
committed
[NFC] Reorganize a few SE-309 test cases with opaque result types
1 parent 88dc3ad commit 2342712

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

test/decl/protocol/existential_member_accesses_self_assoctype.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,10 @@ protocol P1 {
225225
subscript(invariantAssocSubscript7 _: any P1 & Class<Q>) -> Void { get }
226226
subscript(invariantAssocSubscript8 _: Void) -> Struct<Q>.InnerGeneric<Void> { get }
227227
}
228-
@available(macOS 10.15, *)
229228
extension P1 {
230-
func invariantSelf1_1() -> some P1 { self }
231-
var invariantSelfProp1_1: some P1 { self }
232-
subscript(invariantSelfSubscript1_1: Void) -> some P1 { self }
229+
func opaqueResultTypeMethod() -> some P1 { self }
230+
var opaqueResultTypeProp: some P1 { self }
231+
subscript(opaqueResultTypeSubscript _: Bool) -> some P1 { self }
233232
}
234233

235234
do {
@@ -318,6 +317,10 @@ do {
318317
{ (_: () -> Any?) in }
319318
]
320319

320+
let _: any P1 = arg.opaqueResultTypeMethod()
321+
let _: any P1 = arg.opaqueResultTypeProp
322+
let _: any P1 = arg[opaqueResultTypeSubscript: true]
323+
321324
arg.contravariantSelf1(0) // expected-error {{member 'contravariantSelf1' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
322325
arg.contravariantSelf2(0) // expected-error {{member 'contravariantSelf2' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
323326
arg.contravariantSelf3(0) // expected-error {{member 'contravariantSelf3' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
@@ -342,9 +345,6 @@ do {
342345
arg.contravariantAssoc11(0) // expected-error {{member 'contravariantAssoc11' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
343346

344347
arg.invariantSelf1(0) // expected-error {{member 'invariantSelf1' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
345-
if #available(macOS 10.15, *) {
346-
_ = arg.invariantSelf1_1()
347-
}
348348
arg.invariantSelf2(0) // expected-error {{member 'invariantSelf2' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
349349
arg.invariantSelf3(0) // expected-error {{member 'invariantSelf3' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
350350
arg.invariantSelf4(0) // expected-error {{member 'invariantSelf4' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
@@ -391,9 +391,6 @@ do {
391391
arg.contravariantAssocProp11 // expected-error {{member 'contravariantAssocProp11' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
392392

393393
arg.invariantSelfProp1 // expected-error {{member 'invariantSelfProp1' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
394-
if #available(macOS 10.15, *) {
395-
_ = arg.invariantSelfProp1_1
396-
}
397394
arg.invariantSelfProp2 // expected-error {{member 'invariantSelfProp2' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
398395
arg.invariantSelfProp3 // expected-error {{member 'invariantSelfProp3' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}
399396
arg.invariantSelfProp4 // expected-error {{member 'invariantSelfProp4' cannot be used on value of protocol type 'P1'; consider using a generic constraint instead}}

0 commit comments

Comments
 (0)