You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/expr/postfix/dot/init_ref_delegation.swift
+47-6Lines changed: 47 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -273,12 +273,23 @@ func foo<T: C>(_ x: T, y: T.Type) where T: P {
273
273
varci1= x.init(required:0) // expected-error{{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{15-15=type(of: }} {{19-19=)}}
274
274
varci2= x.init(x:0) // expected-error{{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{15-15=type(of: }} {{19-19=)}}
275
275
varci3= x.init() // expected-error{{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{15-15=type(of: }} {{19-19=)}}
276
-
varci4= x.init(proto:"") // expected-error{{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{15-15=type(of: }} {{19-19=)}}
277
-
278
-
varci1a=x(required:0) // expected-error{{cannot call value of non-function type 'T'}}
279
-
varci2a=x(x:0) // expected-error{{cannot call value of non-function type 'T'}}
280
-
varci3a=x() // expected-error{{cannot call value of non-function type 'T'}}{{15-17=}}
281
-
varci4a=x(proto:"") // expected-error{{cannot call value of non-function type 'T'}}
276
+
varci4= x.init(proto:"") // expected-error{{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{15-15=type(of: }} {{19-19=)}}
277
+
278
+
varz= x
279
+
z.init(required:0) // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{4-4= = }}
280
+
z.init(x:0) // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{4-4= = }}
281
+
z.init() // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{4-4= = }}
282
+
z.init(proto:"") // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{4-4= = }}
283
+
284
+
varci1a= z.init(required:0) // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{16-16=type(of: }} {{20-20=)}}
285
+
varci2a= z.init(x:0) // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{16-16=type(of: }} {{20-20=)}}
286
+
varci3a= z.init() // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{16-16=type(of: }} {{20-20=)}}
287
+
varci4a= z.init(proto:"") // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{16-16=type(of: }} {{20-20=)}}
288
+
289
+
varci1b=x(required:0) // expected-error{{cannot call value of non-function type 'T'}}
290
+
varci2b=x(x:0) // expected-error{{cannot call value of non-function type 'T'}}
291
+
varci3b=x() // expected-error{{cannot call value of non-function type 'T'}}{{15-17=}}
292
+
varci4b=x(proto:"") // expected-error{{cannot call value of non-function type 'T'}}
@@ -499,3 +510,33 @@ class TestOptionalTrySub : TestOptionalTry {
499
510
// expected-note@-1 {{force potentially-failing result with 'try!'}} {{5-9=try!}}
500
511
}
501
512
}
513
+
514
+
structX{init(){}}
515
+
516
+
structY{
517
+
func foo(_:X){}
518
+
func asFunctionReturn()->X{
519
+
vara=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
+
}
522
+
varx:X
523
+
init(){
524
+
x.init() // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{6-6= = }}
525
+
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=)}}
526
+
}
527
+
}
528
+
529
+
structY2{
530
+
varx:X
531
+
init(){
532
+
x =X()
533
+
}
534
+
}
535
+
536
+
structMultipleMemberAccesses{
537
+
vary:Y
538
+
init(){
539
+
y =Y()
540
+
y.x.init() // expected-error {{'init' is a member of the type; use assignment to initalize the value instead}} {{8-8= = }}
0 commit comments