Skip to content

Commit 85051c5

Browse files
committed
Test: Add a test exercising expressions with an immutable base
1 parent edd8f70 commit 85051c5

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

test/expr/postfix/dot/init_ref_delegation.swift

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -514,29 +514,28 @@ class TestOptionalTrySub : TestOptionalTry {
514514
struct X { init() {} }
515515

516516
struct Y {
517-
func foo(_: X) {}
518-
func asFunctionReturn() -> X {
519-
var a = X()
520-
return a.init() // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{14-14=type(of: }} {{18-18=)}}
521-
}
522517
var x: X
518+
let x2: X
519+
523520
init() {
524521
x.init() // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{6-6= = }}
525522
foo(x.init()) // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{11-11=type(of: }} {{15-15=)}}
526523
}
527-
}
528-
529-
struct Y2 {
530-
var x: X
531-
init() {
532-
x = X()
524+
525+
func foo(_: X) {}
526+
func asFunctionReturn() -> X {
527+
var a = X()
528+
return a.init() // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{14-14=type(of: }} {{18-18=)}}
533529
}
534530
}
535531

536532
struct MultipleMemberAccesses {
537533
var y: Y
534+
let y2: Y
538535
init() {
539536
y = Y()
537+
y2 = Y()
540538
y.x.init() // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{8-8= = }}
539+
y2.x2.init() // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{11-11=type(of: }} {{15-15=)}}
541540
}
542541
}

0 commit comments

Comments
 (0)