@@ -33,14 +33,34 @@ public struct Type: CustomStringConvertible, NoReflectionChildren {
33
33
public var description : String { String ( taking: bridged. getDebugDescription ( ) ) }
34
34
35
35
public var hasTypeParameter : Bool { bridged. hasTypeParameter ( ) }
36
+ public var hasOpenedExistential : Bool { bridged. hasOpenedExistential ( ) }
36
37
public var isOpenedExistentialWithError : Bool { bridged. isOpenedExistentialWithError ( ) }
37
38
public var isEscapable : Bool { bridged. isEscapable ( ) }
38
39
public var isNoEscape : Bool { bridged. isNoEscape ( ) }
39
40
public var isInteger : Bool { bridged. isInteger ( ) }
41
+ public var isMetatypeType : Bool { bridged. isMetatypeType ( ) }
42
+ public var isExistentialMetatypeType : Bool { bridged. isExistentialMetatypeType ( ) }
40
43
44
+ public var anyNominal : NominalTypeDecl ? { bridged. getAnyNominal ( ) . getAs ( NominalTypeDecl . self) }
45
+ public var instanceTypeOfMetatype : Type { Type ( bridged: bridged. getInstanceTypeOfMetatype ( ) ) }
46
+
41
47
public func subst( with substitutionMap: SubstitutionMap ) -> Type {
42
48
return Type ( bridged: bridged. subst ( substitutionMap. bridged) )
43
49
}
50
+
51
+ /// Performas a global conformance lookup for this type for `protocol`.
52
+ /// It checks conditional requirements.
53
+ ///
54
+ /// This type must be a contextualized type. It must not contain type parameters.
55
+ ///
56
+ /// The resulting conformance reference does not include "missing" conformances, which are synthesized for
57
+ /// some protocols as an error recovery mechanism.
58
+ ///
59
+ /// Returns an invalid conformance if the search failed, otherwise an
60
+ /// abstract, concrete or pack conformance, depending on the lookup type.
61
+ public func checkConformance( to protocol: ProtocolDecl ) -> Conformance {
62
+ return Conformance ( bridged: bridged. checkConformance ( `protocol`. bridged) )
63
+ }
44
64
}
45
65
46
66
/// A Type that is statically known to be canonical.
@@ -61,15 +81,26 @@ public struct CanonicalType: CustomStringConvertible, NoReflectionChildren {
61
81
public var description : String { type. description }
62
82
63
83
public var hasTypeParameter : Bool { type. hasTypeParameter }
84
+ public var hasOpenedExistential : Bool { type. hasOpenedExistential }
64
85
public var isOpenedExistentialWithError : Bool { type. isOpenedExistentialWithError }
65
86
public var isEscapable : Bool { type. isEscapable }
66
87
public var isNoEscape : Bool { type. isNoEscape }
67
88
public var isInteger : Bool { type. isInteger }
89
+ public var isMetatypeType : Bool { type. isMetatypeType }
90
+ public var isExistentialMetatypeType : Bool { type. isExistentialMetatypeType }
68
91
92
+ public var anyNominal : NominalTypeDecl ? { type. anyNominal }
93
+ public var instanceTypeOfMetatype : CanonicalType { type. instanceTypeOfMetatype. canonical }
94
+
69
95
public func subst( with substitutionMap: SubstitutionMap ) -> CanonicalType {
70
96
return type. subst ( with: substitutionMap) . canonical
71
97
}
72
98
99
+ // See `type.checkConformance`
100
+ public func checkConformance( to proto: ProtocolDecl ) -> Conformance {
101
+ return type. checkConformance ( to: proto)
102
+ }
103
+
73
104
public var canBeClass : TraitResult { bridged. canBeClass ( ) . result }
74
105
}
75
106
@@ -104,3 +135,15 @@ extension BridgedCanType.TraitResult {
104
135
}
105
136
}
106
137
}
138
+
139
+ extension Type : Equatable {
140
+ public static func == ( lhs: Type , rhs: Type ) -> Bool {
141
+ lhs. bridged. type == rhs. bridged. type
142
+ }
143
+ }
144
+
145
+ extension CanonicalType : Equatable {
146
+ public static func == ( lhs: CanonicalType , rhs: CanonicalType ) -> Bool {
147
+ lhs. type == rhs. type
148
+ }
149
+ }
0 commit comments