Files
swift-mirror/test/Constraints/generic_construction_deduction.swift
Dmitri Hrybenko 3b04d1b013 tests: reorganize tests so that they actually use the target platform
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
2015-01-19 06:52:49 +00:00

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)