mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
includes a number of QoI things to help people write the correct code. I will commit the testcase for it as the next patch. The bulk of this patch is moving the stdlib, testsuite and validation testsuite to the new syntax. I moved a few uses of "as" patterns back to as? expressions in the stdlib as well. Swift SVN r27959
39 lines
728 B
Swift
39 lines
728 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
class C : Hashable {
|
|
var x = 0
|
|
|
|
var hashValue: Int {
|
|
return x
|
|
}
|
|
}
|
|
|
|
func == (x: C, y: C) -> Bool { return true }
|
|
|
|
|
|
class D : C {}
|
|
|
|
// Unrelated to the classes above.
|
|
class U : Hashable {
|
|
var hashValue: Int {
|
|
return 0
|
|
}
|
|
}
|
|
|
|
func == (x: U, y: U) -> Bool { return true }
|
|
|
|
var setC = Set<C>()
|
|
var setD = Set<D>()
|
|
|
|
// Test set forced downcasts
|
|
setD = setC as! Set<D>
|
|
|
|
// Test set conditional downcasts
|
|
if let setD = setC as? Set<D> { }
|
|
|
|
// Test set downcasts to unrelated types.
|
|
setC as! Set<U> // expected-error{{'U' is not a subtype of 'C'}}
|
|
|
|
// Test set conditional downcasts to unrelated types
|
|
if let setU = setC as? Set<U> { } // expected-error{{'U' is not a subtype of 'C'}}
|