Skip to content

Commit 1603fdc

Browse files
committed
---
yaml --- r: 326006 b: refs/heads/master-next c: 1a57fc4 h: refs/heads/master
1 parent b5ea6b1 commit 1603fdc

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e052da7d8886fa0439677852e8f7830b20c2e1da
3-
refs/heads/master-next: 6d5cf3e43d45c0bdac6732ac5f3876573fe669bf
3+
refs/heads/master-next: 1a57fc403a4ccdc194d2a0d501632422b9e2e70a
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Sema/CSDiagnostics.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4466,6 +4466,19 @@ bool ArgumentMismatchFailure::diagnoseAsError() {
44664466
diagnostic = diag::cannot_convert_argument_value_protocol;
44674467

44684468
auto diag = emitDiagnostic(getLoc(), diagnostic, argType, paramType);
4469+
4470+
// If argument is an l-value type and parameter is a pointer type,
4471+
// let's match up its element type to the argument to see whether
4472+
// it would be appropriate to suggest adding `&`.
4473+
auto *argExpr = getAnchor();
4474+
if (getType(argExpr)->is<LValueType>()) {
4475+
auto elementTy = paramType->getAnyPointerElementType();
4476+
if (elementTy && argType->isEqual(elementTy)) {
4477+
diag.fixItInsert(argExpr->getStartLoc(), "&");
4478+
return true;
4479+
}
4480+
}
4481+
44694482
tryFixIts(diag);
44704483
return true;
44714484
}

branches/master-next/lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,6 +2574,12 @@ bool ConstraintSystem::repairFailures(
25742574
}))
25752575
break;
25762576

2577+
// If this is something like `[A] argument conv [B]` where `A` and `B`
2578+
// are unrelated types, let's give `matchTypes` a chance to consider
2579+
// element types.
2580+
if (hasConversionOrRestriction(ConversionRestrictionKind::DeepEquality))
2581+
break;
2582+
25772583
conversionsOrFixes.push_back(AllowArgumentMismatch::create(
25782584
*this, lhs, rhs, getConstraintLocator(locator)));
25792585
break;

0 commit comments

Comments
 (0)