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/ParseableInterface/inherited-defaults-checks.swiftinterface
+17-6Lines changed: 17 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -12,16 +12,27 @@ public class Bar {
12
12
}
13
13
14
14
public class Foo: Bar {
15
-
public override init(@_inheritedDefaultValue x: Int, y: Int)
16
-
public subscript(@_inheritedDefaultValue k: Int) -> Int { get } // expected-error {{@_inheritedDefaultValue is only valid on parameter declarations of initializers}}
17
-
public func foo(@_inheritedDefaultValue z: Int) // expected-error {{@_inheritedDefaultValue is only valid on parameter declarations of initializers}}
15
+
public override init(x: Int = super, y: Int)
16
+
public subscript(k: Int = super) -> Int { get } // expected-error {{default value inheritance via 'super' is only valid for initializer parameters}}
17
+
public func foo(z: Int = super) // expected-error {{default value inheritance via 'super' is only valid for initializer parameters}}
18
18
}
19
19
20
20
public class Baz: Bar {
21
-
public override init(@_inheritedDefaultValue x: Int, @_inheritedDefaultValue y: Int) // expected-error {{@_inheritedDefaultValue requires that the corresponding parameter of the overridden initializer has a default value}}
21
+
public override init(x: Int = super, y: Int = super) // expected-error {{default value inheritance via 'super' requires that the corresponding parameter of the overridden initializer has a default value}}
22
22
}
23
23
24
-
@_inheritedDefaultValue public enum Bob { // expected-error {{@_inheritedDefaultValue may only be used on 'parameter' declarations}}
24
+
public class Direct: Bar {
25
+
public override init(x: Int = super, y: Int)
26
+
public override init(other: Int = super, value: Int) // expected-error {{argument labels for initializer 'init(other:value:)' do not match those of overridden initializer 'init(x:y:)'}}
27
+
// expected-error@-1 {{default value inheritance via 'super' can only be used on the parameters of overriding initializers}}
28
+
}
29
+
30
+
public class Indirect: Direct {
31
+
public override init(x: Int = super, y: Int)
32
+
public override init(other: Int = super, value: Int)
33
+
}
34
+
35
+
public enum Bob {
25
36
case bar(p: Int)
26
-
public init(@_inheritedDefaultValue foo: String) // expected-error {{@_inheritedDefaultValue can only be used on the parameters of overriding initializers}}
37
+
public init(foo: String = super /*comment*/) // expected-error {{default value inheritance via 'super' can only be used on the parameters of overriding initializers}}
0 commit comments