mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
83 lines
1.1 KiB
Swift
83 lines
1.1 KiB
Swift
// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-apple-darwin11.3.0
|
|
|
|
class A {}
|
|
|
|
#if FOO
|
|
typealias A1 = A;
|
|
#endif
|
|
var a: A = A()
|
|
var a1: A1 = A1() // should not result in an error
|
|
|
|
#if FOO
|
|
class C {}
|
|
#endif
|
|
|
|
var c = C() // should not result in an error
|
|
|
|
class D {
|
|
#if FOO
|
|
var x: Int;
|
|
#endif
|
|
|
|
init() {
|
|
#if !BAR
|
|
x = "BAR"; // should not result in an error
|
|
#else
|
|
x = 1;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
var d = D()
|
|
|
|
#if !FOO
|
|
func f1() -> Bool {
|
|
return true
|
|
}
|
|
#else
|
|
func f1() -> Int {
|
|
#if BAR
|
|
return 1
|
|
#else
|
|
return "1" // should not result in an error
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
var i: Int = f1()
|
|
|
|
protocol P1 {
|
|
#if FOO
|
|
func fFOO() -> Int;
|
|
#endif
|
|
|
|
#if !BAR
|
|
func fNotBAR() -> Int;
|
|
#else
|
|
func fBAR() -> Int;
|
|
#endif
|
|
}
|
|
|
|
class P : P1 {
|
|
func fFOO() -> Int { return 0; }
|
|
func fBAR() -> Int { return 0; }
|
|
}
|
|
|
|
func constants1() -> Int {
|
|
#if true
|
|
return 1
|
|
#else
|
|
return "1" // should not result in an error
|
|
#endif
|
|
}
|
|
|
|
func constants2() -> Int {
|
|
#if false
|
|
return "1" // should not result in an error
|
|
#elseif ((false || false))
|
|
return "1" // should not result in an error
|
|
#else
|
|
return 1
|
|
#endif
|
|
}
|