@@ -79,22 +79,10 @@ namespace {
79
79
// / Internal struct for tracking information about types within a series
80
80
// / of "linked" expressions. (Such as a chain of binary operator invocations.)
81
81
struct LinkedTypeInfo {
82
- unsigned haveIntLiteral : 1 ;
83
- unsigned haveFloatLiteral : 1 ;
84
- unsigned haveStringLiteral : 1 ;
82
+ bool hasLiteral = false ;
85
83
86
84
llvm::SmallSet<TypeBase*, 16 > collectedTypes;
87
85
llvm::SmallVector<BinaryExpr *, 4 > binaryExprs;
88
-
89
- LinkedTypeInfo () {
90
- haveIntLiteral = false ;
91
- haveFloatLiteral = false ;
92
- haveStringLiteral = false ;
93
- }
94
-
95
- bool hasLiteral () {
96
- return haveIntLiteral || haveFloatLiteral || haveStringLiteral;
97
- }
98
86
};
99
87
100
88
// / Walks an expression sub-tree, and collects information about expressions
@@ -180,19 +168,9 @@ namespace {
180
168
!CS.getType (expr)->hasTypeVariable ()) {
181
169
return { false , expr };
182
170
}
183
-
184
- if (isa<IntegerLiteralExpr>(expr)) {
185
- LTI.haveIntLiteral = true ;
186
- return { false , expr };
187
- }
188
-
189
- if (isa<FloatLiteralExpr>(expr)) {
190
- LTI.haveFloatLiteral = true ;
191
- return { false , expr };
192
- }
193
-
194
- if (isa<StringLiteralExpr>(expr)) {
195
- LTI.haveStringLiteral = true ;
171
+
172
+ if (isa<LiteralExpr>(expr)) {
173
+ LTI.hasLiteral = true ;
196
174
return { false , expr };
197
175
}
198
176
@@ -331,7 +309,7 @@ namespace {
331
309
auto simplifyBinOpExprTyVars = [&]() {
332
310
// Don't attempt to do linking if there are
333
311
// literals intermingled with other inferred types.
334
- if (lti.hasLiteral () )
312
+ if (lti.hasLiteral )
335
313
return ;
336
314
337
315
for (auto binExp1 : lti.binaryExprs ) {
@@ -391,42 +369,6 @@ namespace {
391
369
simplifyBinOpExprTyVars ();
392
370
393
371
return true ;
394
- }
395
-
396
- if (lti.haveFloatLiteral ) {
397
- if (auto floatProto = CS.getASTContext ().getProtocol (
398
- KnownProtocolKind::ExpressibleByFloatLiteral)) {
399
- if (auto defaultType = TypeChecker::getDefaultType (floatProto, CS.DC )) {
400
- if (!CS.getFavoredType (expr)) {
401
- CS.setFavoredType (expr, defaultType.getPointer ());
402
- }
403
- return true ;
404
- }
405
- }
406
- }
407
-
408
- if (lti.haveIntLiteral ) {
409
- if (auto intProto = CS.getASTContext ().getProtocol (
410
- KnownProtocolKind::ExpressibleByIntegerLiteral)) {
411
- if (auto defaultType = TypeChecker::getDefaultType (intProto, CS.DC )) {
412
- if (!CS.getFavoredType (expr)) {
413
- CS.setFavoredType (expr, defaultType.getPointer ());
414
- }
415
- return true ;
416
- }
417
- }
418
- }
419
-
420
- if (lti.haveStringLiteral ) {
421
- if (auto stringProto = CS.getASTContext ().getProtocol (
422
- KnownProtocolKind::ExpressibleByStringLiteral)) {
423
- if (auto defTy = TypeChecker::getDefaultType (stringProto, CS.DC )) {
424
- if (!CS.getFavoredType (expr)) {
425
- CS.setFavoredType (expr, defTy.getPointer ());
426
- }
427
- return true ;
428
- }
429
- }
430
372
}
431
373
432
374
return false ;
0 commit comments