Skip to content

Commit d8878d2

Browse files
committed
[Tests] Add IUO tests for implicit member chains
1 parent 30e52be commit d8878d2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/expr/delayed-ident/member_chains.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ struct ImplicitMembers: Equatable {
2727
}
2828
static var superOptional: ImplicitMembers??? = ImplicitMembers()
2929

30+
static func createIUOArg(_: Int) -> ImplicitMembers { ImplicitMembers() }
31+
var anotherIUO: ImplicitMembers! { ImplicitMembers() }
32+
func getAnotherIUO() -> ImplicitMembers! { ImplicitMembers() }
33+
3034
var another: ImplicitMembers { ImplicitMembers() }
3135
var anotherMutable: ImplicitMembers {
3236
get { ImplicitMembers() }
@@ -115,13 +119,27 @@ let _: ImplicitMembers = .implicit.another.another.another.another.another
115119
let _: ImplicitMembers = .implicit.getAnother().getAnother().getAnother().getAnother().getAnother()
116120
let _: ImplicitMembers = .implicit.getAnother(arg: 0).getAnother(arg: 0).getAnother(arg: 0).getAnother(arg: 0).getAnother(arg: 0)
117121

122+
let _: ImplicitMembers = .implicit.another.getAnother().getAnother(arg: 0).anotherIUO
123+
let _: ImplicitMembers = .createImplicit().another.getAnother().getAnother(arg: 0).anotherIUO
124+
let _: ImplicitMembers = .init().another.getAnother().getAnother(arg: 0).anotherIUO
125+
126+
let _: ImplicitMembers = .implicit.another.getAnother().getAnother(arg: 0).getAnotherIUO()
127+
let _: ImplicitMembers = .createImplicit().another.getAnother().getAnother(arg: 0).getAnotherIUO()
128+
let _: ImplicitMembers = .init().another.getAnother().getAnother(arg: 0).getAnotherIUO()
129+
130+
let _: ImplicitMembers = .createIUOArg(_:)(0)
131+
118132
let _: ImplicitMembers = .optional!
119133
let _: ImplicitMembers = .optional!.another
120134
let _: ImplicitMembers = .createOptional()!.another
121135
let _: ImplicitMembers = .optional!.anotherOptional!
122136
let _: ImplicitMembers = .createOptional()!.anotherOptional!
123137
let _: ImplicitMembers = .optional!.getAnotherOptional()!
124138
let _: ImplicitMembers = .createOptional()!.getAnotherOptional()!
139+
let _: ImplicitMembers = .implicit.getAnotherIUO()
140+
let _: ImplicitMembers = .createImplicit().anotherIUO
141+
let _: ImplicitMembers = .implicit.anotherIUO
142+
let _: ImplicitMembers = .createImplicit().anotherIUO
125143

126144
let _: ImplicitMembers = .optional // expected-error {{value of optional type 'ImplicitMembers?' must be unwrapped to a value of type 'ImplicitMembers'}} expected-note {{coalesce using '??' to provide a default when the optional value contains 'nil'}} {{35-35= ?? <#default value#>}} expected-note {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{35-35=!}}
127145
let _: ImplicitMembers = .implicit.anotherOptional // expected-error {{value of optional type 'ImplicitMembers?' must be unwrapped to a value of type 'ImplicitMembers'}} expected-note {{coalesce using '??' to provide a default when the optional value contains 'nil'}} {{51-51= ?? <#default value#>}} expected-note {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{51-51=!}}
@@ -167,6 +185,8 @@ let _: ImplicitMembers? = .createOptional()?.getAnother()
167185
let _: ImplicitMembers? = .createOptional()?.getAnotherOptional()
168186
let _: ImplicitMembers? = .createOptional()?.anotherOptional?.another
169187
let _: ImplicitMembers? = .createOptional()?.getAnotherOptional()?.another
188+
let _: ImplicitMembers? = .createOptional()?.getAnotherOptional()?.anotherIUO
189+
let _: ImplicitMembers? = .createOptional()?.getAnotherOptional()?.getAnotherIUO()
170190
// FIXME: This should be allowed
171191
// let _: ImplicitMembers? = .superOptional???.another
172192

0 commit comments

Comments
 (0)