Skip to content

Commit 189819f

Browse files
committed
[CSSolver] NFC: Add few more tests to verify () -> T to () -> Void conversions
(cherry picked from commit 2646258)
1 parent 87b109f commit 189819f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/Constraints/closures.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,37 @@ func rdar36054961() {
652652
}])
653653
}
654654

655+
protocol P_37790062 {
656+
associatedtype T
657+
var elt: T { get }
658+
}
659+
655660
func rdar37790062() {
656661
struct S<T> {
657662
init(_ a: () -> T, _ b: () -> T) {}
658663
}
659664

665+
class C1 : P_37790062 {
666+
typealias T = Int
667+
var elt: T { return 42 }
668+
}
669+
670+
class C2 : P_37790062 {
671+
typealias T = (String, Int, Void)
672+
var elt: T { return ("question", 42, ()) }
673+
}
674+
660675
func foo() -> Int { return 42 }
661676
func bar() -> Void {}
662677
func baz() -> (String, Int) { return ("question", 42) }
678+
func bzz<T>(_ a: T) -> T { return a }
679+
func faz<T: P_37790062>(_ a: T) -> T.T { return a.elt }
663680

664681
_ = S({ foo() }, { bar() }) // Ok, should infer T to be 'Void'
665682
_ = S({ baz() }, { bar() }) // Ok, should infer T to be 'Void'
683+
_ = S({ bzz(("question", 42)) }, { bar() }) // Ok
684+
_ = S({ bzz(String.self) }, { bar() }) // Ok
685+
_ = S({ bzz(((), (()))) }, { bar() }) // Ok
686+
_ = S({ bzz(C1()) }, { bar() }) // Ok
687+
_ = S({ faz(C2()) }, { bar() }) // Ok
666688
}

0 commit comments

Comments
 (0)