Skip to content

Commit aeb9627

Browse files
committed
Apply the solution to the CS before diagnosing solution fixes.
1 parent 44ce96a commit aeb9627

File tree

6 files changed

+7
-14
lines changed

6 files changed

+7
-14
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7765,6 +7765,8 @@ bool ConstraintSystem::applySolutionFixes(Expr *E, const Solution &solution) {
77657765
llvm::SmallDenseMap<Expr *, SmallVector<const ConstraintFix *, 4>>
77667766
fixesPerExpr;
77677767

7768+
applySolution(solution);
7769+
77687770
for (auto *fix : solution.Fixes)
77697771
fixesPerExpr[fix->getAnchor()].push_back(fix);
77707772

lib/Sema/CSDiag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ void swift::diagnoseSubElementFailure(Expr *destExpr,
883883
}
884884
}
885885

886-
auto type = destExpr->getType() ?: CS.getType(destExpr);
886+
auto type = destExpr->getType() ?: CS.simplifyType(CS.getType(destExpr));
887887
TC.diagnose(loc, unknownDiagID, type)
888888
.highlight(immInfo.first->getSourceRange());
889889
}

lib/Sema/CSDiagnostics.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,6 @@ bool RValueTreatedAsLValueFailure::diagnose() {
565565
diagExpr = parens->getSubExpr();
566566
}
567567

568-
// FIXME: Needed right now to apply correct overload choices to diagExpr for
569-
// use by diagnoseSubElementFailure(). Once all callers are routed through
570-
// here, that function can be rewritten to take the current Solution and use
571-
// it for determining chosen decl bindings instead, making this extra
572-
// typecheck unnecessary.
573-
getConstraintSystem().TC.typeCheckExpression(diagExpr,
574-
getConstraintSystem().DC);
575-
576568
diagnoseSubElementFailure(diagExpr, loc, getConstraintSystem(),
577569
subElementDiagID, rvalueDiagID);
578570
return true;

test/expr/cast/array_iteration.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ for view in rootView.subviews as! [View] { // expected-warning{{immutable value
1616
doFoo()
1717
}
1818

19-
// FIXME: Diagnostic below should be "'AnyObject' is not convertible to
20-
// 'View'", but IUO type gets in the way of proper diagnosis.
21-
for view:View in rootView.subviews { // expected-error{{type 'Array<AnyObject>?' does not conform to protocol 'Sequence'}}
19+
for view:View in rootView.subviews { // expected-error{{'AnyObject' is not convertible to 'View'}}
2220
doFoo()
2321
}
2422

test/expr/expressions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func unaryOps(_ i8: inout Int8, i64: inout Int64) {
614614
i64 += 1
615615
i8 -= 1
616616

617-
Int64(5) += 1 // expected-error{{left side of mutating operator isn't mutable: function call returns immutable value}}
617+
Int64(5) += 1 // expected-error{{left side of mutating operator has immutable type 'Int64'}}
618618

619619
// <rdar://problem/17691565> attempt to modify a 'let' variable with ++ results in typecheck error not being able to apply ++ to Float
620620
let a = i8 // expected-note {{change 'let' to 'var' to make it mutable}} {{3-6=var}}

validation-test/stdlib/FixedPointDiagnostics.swift.gyb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func testMixedSignArithmetic() {
9595
x += Stride(1) // expected-error {{'+=' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
9696
x -= Stride(1) // expected-error {{'-=' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
9797

98-
_ = (x - x) as Stride // expected-error {{ambiguous reference to member '-'}}
98+
// Terrible over-specific error, but at least disabled
99+
_ = (x - x) as Stride // expected-error {{'(@lvalue ${T}, @lvalue ${T}) -> ${T}' is not convertible to '(${T}, ${T}) -> ${T}'}}
99100

100101
//===------------------------------------------------------------------===//
101102
// The following errors are different because they're not being

0 commit comments

Comments
 (0)