Files
swift-mirror/test/Interpreter/generic_implicit_closure.swift
Joe Groff 3e3e5710ec Set proper DeclContext for ImplicitClosureExprs.
Now that SILGen and IRGen can both handle capturing archetypes from generic scopes, we can set the DeclContext of ImplicitClosureExprs correctly, so that SILGen captures their context archetypes. &&, and ||, and assert now work in generic contexts, at least in simple test cases.

Swift SVN r5476
2013-06-05 05:09:59 +00:00

35 lines
673 B
Swift

// RUN: %swift -i %s | FileCheck %s
func andc<T:LogicValue>(x:Bool, y:T) -> Bool {
return x && !y.getLogicValue()
}
struct Truthy : LogicValue {
func getLogicValue() -> Bool {
return true
}
}
struct Falselike : LogicValue {
func getLogicValue() -> Bool {
return false
}
}
println(andc(true, Truthy())) // CHECK: false
println(andc(false, Truthy())) // CHECK: false
println(andc(true, Falselike())) // CHECK: true
println(andc(false, Falselike())) // CHECK: false
func must<T:LogicValue>(x:T) {
assert(x.getLogicValue())
}
func shant<T:LogicValue>(x:T) {
assert(!x.getLogicValue())
}
must(Truthy())
shant(Falselike())
println("ok") // CHECK: ok