mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Most tests were using %swift or similar substitutions, which did not include the target triple and SDK. The driver was defaulting to the host OS. Thus, we could not run the tests when the standard library was not built for OS X. Swift SVN r24504
45 lines
657 B
Swift
45 lines
657 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
struct A<T> {
|
|
// Can deduce from this constructor
|
|
init(x:T) { }
|
|
|
|
// Can't from this one
|
|
init(x:Int, y:Int) { }
|
|
|
|
static func bort(x: T) -> T { return x }
|
|
}
|
|
|
|
var a = A(x: 0)
|
|
var a1 : A<Int> = a
|
|
|
|
var b = A(x: "zero")
|
|
var b1 : A<String> = b
|
|
|
|
class C<T> {
|
|
init(x:T) { }
|
|
}
|
|
|
|
var c = C(x: 0)
|
|
var c1 : C<Int> = c
|
|
|
|
var d = C(x: "zero")
|
|
var d1 : C<String> = d
|
|
|
|
var x : Int = A.bort(0)
|
|
var y : String = A.bort("zero")
|
|
|
|
func foo(a: A<String>) { }
|
|
// Deduce A<String> from context
|
|
foo(A(x: 0, y: 0))
|
|
|
|
// Specifying only some of the generic arguments.
|
|
struct B { }
|
|
|
|
struct X<T,U> {
|
|
init(a:U) {}
|
|
}
|
|
|
|
var q = X<B,Int>(a: x)
|
|
|