@@ -48,8 +48,7 @@ struct TypeJoin : TypeVisitor<TypeJoin, Type> {
48
48
Type visitType (Type second) {
49
49
// FIXME: Implement all the visitors.
50
50
// llvm_unreachable("Unimplemented type visitor!");
51
- // return First->getASTContext().TheAnyType;
52
- return nullptr ;
51
+ return First->getASTContext ().TheAnyType ;
53
52
}
54
53
55
54
public:
@@ -90,9 +89,8 @@ Type TypeJoin::getSuperclassJoin(Type first, Type second) {
90
89
if (!first || !second)
91
90
return TypeJoin::join (first, second);
92
91
93
- // FIXME: Return Any
94
92
if (!first->mayHaveSuperclass () || !second->mayHaveSuperclass ())
95
- return nullptr ;
93
+ return first-> getASTContext (). TheAnyType ;
96
94
97
95
// / Walk the superclasses of `first` looking for `second`. Record them
98
96
// / for our second step.
@@ -102,7 +100,8 @@ Type TypeJoin::getSuperclassJoin(Type first, Type second) {
102
100
CanType canSuper = super->getCanonicalType ();
103
101
104
102
// If we have found the second type, we're done.
105
- if (canSuper == canSecond) return super;
103
+ if (canSuper == canSecond)
104
+ return super;
106
105
107
106
superclassesOfFirst.insert (canSuper);
108
107
}
@@ -113,12 +112,12 @@ Type TypeJoin::getSuperclassJoin(Type first, Type second) {
113
112
CanType canSuper = super->getCanonicalType ();
114
113
115
114
// If we found the first type, we're done.
116
- if (superclassesOfFirst.count (canSuper)) return super;
115
+ if (superclassesOfFirst.count (canSuper))
116
+ return super;
117
117
}
118
118
119
- // FIXME: Return Any
120
119
// There is no common superclass; we're done.
121
- return nullptr ;
120
+ return first-> getASTContext (). TheAnyType ;
122
121
}
123
122
124
123
Type TypeJoin::visitClassType (Type second) {
@@ -138,47 +137,38 @@ Type TypeJoin::visitDynamicSelfType(Type second) {
138
137
}
139
138
140
139
Type TypeJoin::visitMetatypeType (Type second) {
141
- assert (!First->mayHaveSuperclass () && !second->mayHaveSuperclass ());
142
-
143
- // FIXME: Return Any
144
140
if (First->getKind () != second->getKind ())
145
- return nullptr ;
141
+ return First-> getASTContext (). TheAnyType ;
146
142
147
143
auto firstInstance = First->castTo <AnyMetatypeType>()->getInstanceType ();
148
144
auto secondInstance = second->castTo <AnyMetatypeType>()->getInstanceType ();
149
145
150
146
auto joinInstance = join (firstInstance, secondInstance);
151
147
152
- // FIXME: Return Any
153
148
if (!joinInstance)
154
- return nullptr ;
149
+ return First-> getASTContext (). TheAnyType ;
155
150
156
151
return MetatypeType::get (joinInstance);
157
152
}
158
153
159
154
Type TypeJoin::visitExistentialMetatypeType (Type second) {
160
- assert (!First->mayHaveSuperclass () && !second->mayHaveSuperclass ());
161
-
162
- // FIXME: Return Any
163
155
if (First->getKind () != second->getKind ())
164
- return nullptr ;
156
+ return First-> getASTContext (). TheAnyType ;
165
157
166
158
auto firstInstance = First->castTo <AnyMetatypeType>()->getInstanceType ();
167
159
auto secondInstance = second->castTo <AnyMetatypeType>()->getInstanceType ();
168
160
169
161
auto joinInstance = join (firstInstance, secondInstance);
170
162
171
- // FIXME: Return Any
172
163
if (!joinInstance)
173
- return nullptr ;
164
+ return First-> getASTContext (). TheAnyType ;
174
165
175
166
return ExistentialMetatypeType::get (joinInstance);
176
167
}
177
168
178
169
Type TypeJoin::visitBoundGenericEnumType (Type second) {
179
- // FIXME: Return Any
180
170
if (First->getKind () != second->getKind ())
181
- return nullptr ;
171
+ return First-> getASTContext (). TheAnyType ;
182
172
183
173
OptionalTypeKind otk1, otk2;
184
174
Type objectType1 = First->getAnyOptionalObjectType (otk1);
@@ -188,15 +178,14 @@ Type TypeJoin::visitBoundGenericEnumType(Type second) {
188
178
Type unwrappedJoin = join (objectType1 ? objectType1 : First,
189
179
objectType2 ? objectType2 : second);
190
180
// FIXME: More general joins of enums need to be handled.
191
- if (!unwrappedJoin) return nullptr ;
181
+ if (!unwrappedJoin)
182
+ return First->getASTContext ().TheAnyType ;
192
183
193
184
return OptionalType::get (unwrappedJoin);
194
185
}
195
186
196
- // FIXME: More general joins of enums need to be handled, and
197
- // then Any should be returned when there is no better
198
- // choice.
199
- return nullptr ;
187
+ // FIXME: More general joins of enums need to be handled.
188
+ return First->getASTContext ().TheAnyType ;
200
189
}
201
190
202
191
Type TypeJoin::visitOptionalType (Type second) {
0 commit comments