forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnominal_types.swift
89 lines (71 loc) · 1.38 KB
/
nominal_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// RUN: %target-swift-remoteast-test %s | %FileCheck %s
// REQUIRES: swift-remoteast-test
@_silgen_name("printMetadataType")
func printType(_: Any.Type)
printType(Int.self)
// CHECK: Int
struct A {}
printType(A.self)
// CHECK: A
struct B {
struct Foo {}
}
printType(B.Foo.self)
// CHECK: B.Foo
extension B {
struct Bar {}
}
printType(B.Bar.self)
// CHECK: B.Bar
class C {
}
printType(C.self)
// CHECK: C
class D : C {
}
printType(D.self)
// CHECK: D
class E {
struct Foo {}
}
printType(E.Foo.self)
// CHECK: E.Foo
struct F {
class Foo {}
}
printType(F.Foo.self)
// CHECK: F.Foo
enum G {
case Gwhatever
struct Foo {}
}
printType(G.self)
// CHECK: G
printType(G.Foo.self)
// CHECK: G.Foo
struct H<T, U> {}
printType(H<A,A>.self)
// CHECK: H<A, A>
printType(H<B.Foo, H<B, A>>.self)
// CHECK: H<B.Foo, H<B, A>>
class I<T> {}
printType(I<Int>.self)
// CHECK: I<Int>
// None of these are currently permitted by Sema.
// TODO: non-generic types nested in generic types
// TODO: generic types nested in generic types
// TODO: generic types nested in non-generic types
protocol J {}
printType(J.self)
// CHECK: found type: J
printType(J.Protocol.self)
// CHECK: found type: J.Protocol
printType(J.Type.self)
// CHECK: found type: J.Type
protocol K {}
typealias JK = J & K
typealias KJ = K & J
printType(JK.self)
// CHECK: found type: J & K
printType(KJ.self)
// CHECK: found type: J & K