We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73156ad commit bf7089dCopy full SHA for bf7089d
test/Constraints/optional.swift
@@ -598,3 +598,19 @@ do {
598
test(x!) // expected-error {{no exact matches in call to local function 'test'}}
599
// expected-error@-1 {{cannot force unwrap value of non-optional type 'Double'}}
600
}
601
+
602
+// Diagnose cases of invalid chaining when parameter is not optional based on context.
603
+do {
604
+ class Test {
605
+ var value: Int = 42
606
+ }
607
608
+ class Container {
609
+ let test: Test = Test()
610
611
+ func loop() {
612
+ [test].forEach { $0?.value = 42 }
613
+ // expected-error@-1 {{cannot use optional chaining on non-optional value of type 'Test'}}
614
615
616
+}
0 commit comments