Skip to content

Commit 5c01efa

Browse files
committed
[test] Add a couple of IUO test cases
1 parent f227643 commit 5c01efa

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

test/Constraints/dynamic_lookup.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ let _: DynamicIUO = o[dyn_iuo]!
311311
let _: DynamicIUO = o[dyn_iuo]!!
312312
let _: DynamicIUO? = o[dyn_iuo]
313313
// FIXME: These should all produce lvalues that we can write through
314+
o.t = s // expected-error {{cannot assign to property: 'o' is immutable}}
315+
o.t! = s // expected-error {{cannot assign through '!': 'o' is immutable}}
316+
o.t!! = s // expected-error {{cannot assign through '!': 'o' is immutable}}
314317
o[dyn_iuo] = dyn_iuo // expected-error {{cannot assign through subscript: 'o' is immutable}}
315318
o[dyn_iuo]! = dyn_iuo // expected-error {{cannot assign through '!': 'o' is immutable}}
316319
o[dyn_iuo]!! = dyn_iuo // expected-error {{cannot assign through '!': 'o' is immutable}}

test/Constraints/iuo.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,7 @@ func rdar83352038() {
247247
return foo(cnode)
248248
}
249249
}
250+
251+
// Make sure we reject an attempt at a function conversion.
252+
func returnsIUO() -> Int! { 0 }
253+
let _ = (returnsIUO as () -> Int)() // expected-error {{cannot convert value of type '() -> Int?' to type '() -> Int' in coercion}}

0 commit comments

Comments
 (0)