mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Require that either T be default constructible or that the user provide a closure that maps indices to initial values. We don't actually call the closure yet to initialize the array; that's blocked on function abstraction difference <rdar://problem/13251236>. Swift SVN r8801
23 lines
848 B
Swift
23 lines
848 B
Swift
// RUN: %swift -parse -verify %s
|
|
|
|
struct DefaultConstructible {
|
|
constructor() {}
|
|
constructor(x:Int) {}
|
|
constructor(x:Int, y:String) {}
|
|
}
|
|
|
|
struct NotDefaultConstructible {
|
|
constructor(x:Int) {}
|
|
constructor(x:Int, y:String) {}
|
|
}
|
|
|
|
var a = new DefaultConstructible[10]
|
|
var b = new DefaultConstructible[10] { DefaultConstructible($0) }
|
|
var c = new DefaultConstructible[10] { NotDefaultConstructible($0) } // expected-error{{}}
|
|
var d = new DefaultConstructible[10] { DefaultConstructible(22, $0) } // expected-error{{}}
|
|
|
|
var e = new NotDefaultConstructible[10] // expected-error{{}}
|
|
var f = new NotDefaultConstructible[10] { NotDefaultConstructible($0) }
|
|
var g = new NotDefaultConstructible[10] { DefaultConstructible($0) } // expected-error{{}}
|
|
var h = new NotDefaultConstructible[10] { NotDefaultConstructible(22, $0) } // expected-error{{}}
|