mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
For the implicit memberwise struct constructor to be suppressed, one has to write a constructor with the same parameters (names, types, and order) as the instance variables of the struct. Swift SVN r4819
27 lines
283 B
Swift
27 lines
283 B
Swift
// RUN: %swift -parse %s -verify
|
|
|
|
struct X {
|
|
constructor() {}
|
|
}
|
|
|
|
X()
|
|
|
|
struct Y {
|
|
var i : Int, f : Float
|
|
constructor(i : Int, f : Float) {}
|
|
}
|
|
|
|
Y(1, 1.5)
|
|
|
|
struct Z {
|
|
var a : Int
|
|
var b : Int
|
|
|
|
constructor (a : Int, b : Int = 5) {
|
|
this.a = a
|
|
this.b = b
|
|
}
|
|
}
|
|
|
|
Z(1, 2)
|