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
66 lines
1.8 KiB
Swift
66 lines
1.8 KiB
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
struct S {
|
|
var x: Int = 0
|
|
let y: Int = 0
|
|
|
|
init() {}
|
|
}
|
|
|
|
struct T {
|
|
var mutS: S? = nil
|
|
let immS: S? = nil
|
|
|
|
init() {}
|
|
}
|
|
|
|
var mutT: T?
|
|
let immT: T? = nil
|
|
|
|
let mutTPayload = mutT!
|
|
|
|
mutT! = T()
|
|
mutT!.mutS = S()
|
|
mutT!.mutS! = S()
|
|
mutT!.mutS!.x = 0
|
|
mutT!.mutS!.y = 0 // expected-error{{cannot assign}}
|
|
mutT!.immS = S() // expected-error{{cannot assign}}
|
|
mutT!.immS! = S() // expected-error{{cannot assign}}
|
|
mutT!.immS!.x = 0 // expected-error{{cannot assign}}
|
|
mutT!.immS!.y = 0 // expected-error{{cannot assign}}
|
|
|
|
immT! = T() // expected-error{{cannot assign}}
|
|
immT!.mutS = S() // expected-error{{cannot assign}}
|
|
immT!.mutS! = S() // expected-error{{cannot assign}}
|
|
immT!.mutS!.x = 0 // expected-error{{cannot assign}}
|
|
immT!.mutS!.y = 0 // expected-error{{cannot assign}}
|
|
immT!.immS = S() // expected-error{{cannot assign}}
|
|
immT!.immS! = S() // expected-error{{cannot assign}}
|
|
immT!.immS!.x = 0 // expected-error{{cannot assign}}
|
|
immT!.immS!.y = 0 // expected-error{{cannot assign}}
|
|
|
|
var mutIUO: T! = nil
|
|
let immIUO: T! = nil
|
|
|
|
mutIUO!.mutS = S()
|
|
mutIUO!.immS = S() // expected-error{{cannot assign}}
|
|
immIUO!.mutS = S() // expected-error{{cannot assign}}
|
|
immIUO!.immS = S() // expected-error{{cannot assign}}
|
|
|
|
mutIUO.mutS = S()
|
|
mutIUO.immS = S() // expected-error{{cannot assign}}
|
|
immIUO.mutS = S() // expected-error{{cannot assign}}
|
|
immIUO.immS = S() // expected-error{{cannot assign}}
|
|
|
|
func foo(x: Int) {}
|
|
|
|
var nonOptional: S = S()
|
|
_ = nonOptional! // expected-error{{operand of postfix '!' should have optional type; type is 'S'}}
|
|
_ = nonOptional!.x // expected-error{{operand of postfix '!' should have optional type; type is 'S'}}
|
|
|
|
class C {}
|
|
class D: C {}
|
|
|
|
let c = C()
|
|
let d = (c as! D)! // expected-error{{forced downcast already produces a non-optional value}}
|