forked from swiftlang/swift
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbool_as_generic.swift
27 lines (22 loc) · 705 Bytes
/
bool_as_generic.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test
// <rdar://problem/13986638> Missing Bool metadata when Bool is used as a generic
// parameter or existential value
prefix operator !!
infix operator &&&
protocolBooleanProtocol{
varboolValue:Bool{get}
}
extensionBool:BooleanProtocol{
varboolValue:Bool{returnself}
}
prefixfunc!!<T :BooleanProtocol>(x:T)->Bool{
return x.boolValue
}
func&&&(x:BooleanProtocol, y:@autoclosure()->BooleanProtocol)->Bool{
return x.boolValue ?y().boolValue :false
}
print(!!true) // CHECK: true
print(!!false) // CHECK: false
print(true&&&true) // CHECK: true
print(true&&&false) // CHECK: false