Files
swift-mirror/test/Interpreter/repl_conformance_lookup.swift
Dmitri Hrybenko 6058d291ca CMake: allow the SDK overlay to be built separately from the compiler
and the stdandard library

rdar://19703353

Swift SVN r25139
2015-02-10 21:57:03 +00:00

42 lines
787 B
Swift

// RUN: %target-repl-run-simple-swift | FileCheck %s
// REQUIRES: swift_repl
protocol Fooable {
func foo()
}
class C {}
class D: C {}
func fooify<T>(x: T) {
if let foo = x as? Fooable {
foo.foo()
} else {
println("--not fooable--")
}
}
fooify(1) // CHECK: --not fooable--
fooify(1) // CHECK: --not fooable--
fooify(C()) // CHECK: --not fooable--
fooify(C()) // CHECK: --not fooable--
fooify(D()) // CHECK: --not fooable--
fooify(D()) // CHECK: --not fooable--
extension Int: Fooable {
func foo() { println("--Int--") }
}
fooify(1) // CHECK: --Int--
fooify(1) // CHECK: --Int--
extension D: Fooable {
func foo() { println("--D--") }
}
fooify(D()) // CHECK: D
fooify(D()) // CHECK: D
fooify(C()) // CHECK: --not fooable--
fooify(C()) // CHECK: --not fooable--