@@ -100,52 +100,26 @@ CheckTypeWitnessResult checkTypeWitness(Type type,
100
100
const NormalProtocolConformance *Conf,
101
101
SubstOptions options = None);
102
102
103
- // / Describes the means of inferring an abstract type witness.
104
- enum class AbstractTypeWitnessKind : uint8_t {
105
- // / The type witness was inferred via a same-type-to-concrete constraint
106
- // / in a protocol requirement signature.
107
- Fixed,
108
-
109
- // / The type witness was inferred via a defaulted associated type.
110
- Default,
111
-
112
- // / The type witness was inferred to a generic parameter of the
113
- // / conforming type.
114
- GenericParam,
115
- };
116
-
117
103
// / A type witness inferred without the aid of a specific potential
118
104
// / value witness.
119
105
class AbstractTypeWitness {
120
- AbstractTypeWitnessKind Kind;
121
106
AssociatedTypeDecl *AssocType;
122
107
Type TheType;
123
108
124
- // / When this is a default type witness, the declaration responsible for it .
125
- // / May not necessarilly match \c AssocType.
109
+ // / The defaulted associated type that was used to infer this type witness .
110
+ // / Need not necessarilly match \c AssocType, but their names must .
126
111
AssociatedTypeDecl *DefaultedAssocType;
127
112
128
- AbstractTypeWitness (AbstractTypeWitnessKind Kind,
129
- AssociatedTypeDecl *AssocType, Type TheType,
130
- AssociatedTypeDecl *DefaultedAssocType)
131
- : Kind(Kind), AssocType(AssocType), TheType(TheType),
113
+ public:
114
+ AbstractTypeWitness ( AssociatedTypeDecl *AssocType, Type TheType,
115
+ AssociatedTypeDecl *DefaultedAssocType = nullptr )
116
+ : AssocType(AssocType), TheType(TheType),
132
117
DefaultedAssocType (DefaultedAssocType) {
133
118
assert (AssocType && TheType);
119
+ assert (!DefaultedAssocType ||
120
+ (AssocType->getName () == DefaultedAssocType->getName ()));
134
121
}
135
122
136
- public:
137
- static AbstractTypeWitness forFixed (AssociatedTypeDecl *assocType, Type type);
138
-
139
- static AbstractTypeWitness forDefault (AssociatedTypeDecl *assocType,
140
- Type type,
141
- AssociatedTypeDecl *defaultedAssocType);
142
-
143
- static AbstractTypeWitness forGenericParam (AssociatedTypeDecl *assocType,
144
- Type type);
145
-
146
- public:
147
- AbstractTypeWitnessKind getKind () const { return Kind; }
148
-
149
123
AssociatedTypeDecl *getAssocType () const { return AssocType; }
150
124
151
125
Type getType () const { return TheType; }
0 commit comments