forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
associated_types.swift
52 lines (38 loc) · 1.18 KB
/
associated_types.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RUN: %target-swift-frontend -emit-ir -primary-file %s | FileCheck %s
// REQUIRES: CPU=i386_or_x86_64
protocol Runcer {
typealias Runcee
}
protocol Runcible {
typealias RuncerType : Runcer
typealias AltRuncerType : Runcer
}
struct Mince {}
struct Quince : Runcer {
typealias Runcee = Mince
}
struct Spoon : Runcible {
typealias RuncerType = Quince
typealias AltRuncerType = Quince
}
struct Owl<T : Runcible, U> {
// CHECK: define hidden void @_TFV16associated_types3Owl3eat{{.*}}(%swift.opaque*
func eat(what: T.RuncerType.Runcee, and: T.RuncerType, with: T) { }
}
class Pussycat<T : Runcible, U> {
init() {}
// CHECK: define hidden void @_TFC16associated_types8Pussycat3eat{{.*}}(%swift.opaque* noalias nocapture, %swift.opaque* noalias nocapture, %swift.opaque* noalias nocapture, %C16associated_types8Pussycat*)
func eat(what: T.RuncerType.Runcee, and: T.RuncerType, with: T) { }
}
func owl() -> Owl<Spoon, Int> {
return Owl()
}
func owl2() {
Owl<Spoon, Int>().eat(Mince(), and: Quince(), with: Spoon())
}
func pussycat() -> Pussycat<Spoon, Int> {
return Pussycat()
}
func pussycat2() {
Pussycat<Spoon, Int>().eat(Mince(), and: Quince(), with: Spoon())
}