mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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
34 lines
839 B
Swift
34 lines
839 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
// Simple struct types
|
|
struct X1 {
|
|
static func create(i: Int) -> X1 { }
|
|
static func createGeneric<T>(d: T) -> X1 { }
|
|
static func createMaybe(i : Int) -> X1! { }
|
|
|
|
static func notAFactory(i: Int) -> Int { }
|
|
}
|
|
|
|
// Static methods
|
|
var x1: X1 = .create(5)
|
|
x1 = .createGeneric(3.14159)
|
|
|
|
// Non-matching data members
|
|
x1 = .notAFactory(5) // expected-error{{could not find member 'notAFactory'}}
|
|
|
|
// Static methods returning unchecked-optional types
|
|
x1 = .createMaybe(5)
|
|
|
|
// Generic struct types
|
|
struct X2<T> {
|
|
static func create(t: T) -> X2 { }
|
|
static func createGeneric<U>(t: T, u:U) -> X2 { }
|
|
static func createMaybe(i : T) -> X2! { }
|
|
}
|
|
|
|
// Static methods
|
|
var x2a: X2 = .create(5)
|
|
x2a = .createGeneric(5, u: 3.14159)
|
|
var x2b: X2 = .createGeneric(5, u: 3.14159)
|
|
var x2c: X2 = .createMaybe(5)
|