Skip to content

Commit c8e9018

Browse files
committed
[CSGen] Don't merge type variables for literals in computeFavoredTypeForExpr
1 parent df51c4a commit c8e9018

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -339,22 +339,6 @@ namespace {
339339

340340
expr->walk(LinkedExprAnalyzer(lti, CS));
341341

342-
auto mergeTypeVariables = [&](ArrayRef<TypeVariableType *> typeVars) {
343-
if (typeVars.size() < 2)
344-
return;
345-
346-
auto rep1 = CS.getRepresentative(typeVars.front());
347-
for (unsigned i = 1, n = typeVars.size(); i != n; ++i) {
348-
auto rep2 = CS.getRepresentative(typeVars[i]);
349-
if (rep1 != rep2)
350-
CS.mergeEquivalenceClasses(rep1, rep2, /*updateWorkList*/ false);
351-
}
352-
};
353-
354-
mergeTypeVariables(lti.intLiteralTyvars);
355-
mergeTypeVariables(lti.floatLiteralTyvars);
356-
mergeTypeVariables(lti.stringLiteralTyvars);
357-
358342
if (lti.collectedTypes.size() == 1) {
359343
// TODO: Compute the BCT.
360344

test/stdlib/UnicodeScalarDiagnostics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ func isString(_ s: inout String) {}
88
func test_UnicodeScalarDoesNotImplementArithmetic(_ us: UnicodeScalar, i: Int) {
99
var a1 = "a" + "b" // OK
1010
isString(&a1)
11-
let a2 = "a" - "b" // expected-error {{binary operator '-' cannot be applied to two 'String' operands}}
12-
let a3 = "a" * "b" // expected-error {{binary operator '*' cannot be applied to two 'String' operands}}
13-
let a4 = "a" / "b" // expected-error {{binary operator '/' cannot be applied to two 'String' operands}}
11+
let a2 = "a" - "b" // expected-error {{binary operator '-' cannot be applied to two 'String' operands}} expected-note {{}}
12+
let a3 = "a" * "b" // expected-error {{binary operator '*' cannot be applied to two 'String' operands}} expected-note {{}}
13+
let a4 = "a" / "b" // expected-error {{binary operator '/' cannot be applied to two 'String' operands}} expected-note {{}}
1414

1515
let b1 = us + us // expected-error {{binary operator '+' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}
1616
let b2 = us - us // expected-error {{binary operator '-' cannot be applied to two 'UnicodeScalar' (aka 'Unicode.Scalar') operands}}

0 commit comments

Comments
 (0)