Skip to content

Commit 644aa87

Browse files
committed
Harden diagnoseForcedCastExpr for lack of cast-to type
1 parent eff8cc2 commit 644aa87

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/SILGen/SILGenDistributed.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ void InitializeDistActorIdentity::dump(SILGenFunction &) const {
281281

282282
bool SILGenFunction::shouldReplaceConstantForApplyWithDistributedThunk(
283283
FuncDecl *func) const {
284-
auto isDistributedFuncOrAccessor =
285-
func->isDistributed();
284+
auto isDistributedFuncOrAccessor = func->isDistributed();
286285
if (auto acc = dyn_cast<AccessorDecl>(func)) {
287286
isDistributedFuncOrAccessor =
288287
acc->getStorage()->isDistributed();

lib/Sema/CSDiagnostics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9268,9 +9268,10 @@ bool NoopCheckedCast::diagnoseForcedCastExpr() const {
92689268
}
92699269

92709270
if (fromType->isEqual(toType)) {
9271-
auto castTypeRepr = expr->getCastTypeRepr();
9272-
emitDiagnostic(diag::forced_downcast_noop, toType)
9273-
.fixItRemove(SourceRange(diagLoc, castTypeRepr->getSourceRange().End));
9271+
auto diag = emitDiagnostic(diag::forced_downcast_noop, toType);
9272+
if (auto castTypeRepr = expr->getCastTypeRepr()) {
9273+
diag.fixItRemove(SourceRange(diagLoc, castTypeRepr->getSourceRange().End));
9274+
}
92749275

92759276
} else {
92769277
emitDiagnostic(diag::forced_downcast_coercion, fromType, toType)

lib/Sema/DerivedConformance/DerivedConformanceDistributedActor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ deriveBodyDistributed_invokeHandlerOnReturn(AbstractFunctionDecl *afd,
335335
// If the SerializationRequirement requires it, we need to emit a cast:
336336
// metatype as! <<concrete SerializationRequirement.Type>>
337337
bool serializationRequirementIsAny =
338-
metatypeParam->getInterfaceType()->getMetatypeInstanceType()->isAny();
338+
serializationRequirementMetaTypeTy->getMetatypeInstanceType()->isEqual(
339+
C.getAnyExistentialType());
339340

340341
auto metatypeRef =
341342
new (C) DeclRefExpr(ConcreteDeclRef(metatypeParam), dloc, implicit);

0 commit comments

Comments
 (0)