Skip to content

Commit 3225f62

Browse files
[Diagnostics] Adjust to get expr from type node anchor
1 parent 2a85acb commit 3225f62

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5547,7 +5547,7 @@ bool ThrowingFunctionConversionFailure::diagnoseAsError() {
55475547
}
55485548

55495549
bool UnnecessaryCoercionFailure::diagnoseAsError() {
5550-
auto expr = cast<CoerceExpr>(getAnchor());
5550+
auto expr = getAsExpr<CoerceExpr>(getAnchor());
55515551
auto sourceRange =
55525552
SourceRange(expr->getLoc(), expr->getCastTypeLoc().getSourceRange().End);
55535553
auto castType = expr->getCastTypeLoc().getType();
@@ -5558,15 +5558,14 @@ bool UnnecessaryCoercionFailure::diagnoseAsError() {
55585558
auto toTypeAlias = cast<TypeAliasType>(getToType().getPointer());
55595559
// If the typealias are different, we need a warning mentioning both types.
55605560
if (fromTypeAlias->getDecl() != toTypeAlias->getDecl()) {
5561-
emitDiagnostic(expr->getLoc(),
5562-
diag::unnecessary_same_typealias_type_coercion,
5561+
emitDiagnostic(diag::unnecessary_same_typealias_type_coercion,
55635562
getFromType(), castType)
55645563
.fixItRemove(sourceRange);
55655564
return true;
55665565
}
55675566
}
55685567

5569-
emitDiagnostic(expr->getLoc(), diag::unnecessary_same_type_coercion,
5568+
emitDiagnostic(diag::unnecessary_same_type_coercion,
55705569
castType)
55715570
.fixItRemove(sourceRange);
55725571
return true;

lib/Sema/CSFix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ bool RemoveUnnecessaryCoercion::attempt(ConstraintSystem &cs, Type fromType,
11551155
if (!isExplicitCoercion)
11561156
return false;
11571157

1158-
auto expr = cast<CoerceExpr>(locator.getAnchor());
1158+
auto expr = getAsExpr<CoerceExpr>(locator.getAnchor());
11591159

11601160
// Check to ensure the from and to types are equal the cast type.
11611161
// This is required to handle cases where the conversion is done

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10510,7 +10510,7 @@ void ConstraintSystem::addExplicitConversionConstraint(
1051010510
auto locatorPtr = getConstraintLocator(locator);
1051110511
ConstraintLocator *coerceLocator = locatorPtr;
1051210512

10513-
auto *anchor = locator.getAnchor();
10513+
auto *anchor = getAsExpr(locator.getAnchor());
1051410514
if (anchor && isa<CoerceExpr>(anchor) && !anchor->isImplicit()) {
1051510515
coerceLocator =
1051610516
getConstraintLocator(anchor, LocatorPathElt::ExplicitTypeCoercion());

0 commit comments

Comments
 (0)