Skip to content

Commit b4ae75b

Browse files
committed
Apply code review suggestions
1 parent ad29110 commit b4ae75b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,18 +3642,16 @@ void bindFuncDeclToOperator(TypeChecker &TC, FuncDecl *FD) {
36423642

36433643
if (!op) {
36443644
SourceLoc insertionLoc;
3645-
if (dyn_cast<SourceFile>(FD->getParent())) {
3645+
if (isa<SourceFile>(FD->getParent())) {
36463646
// Parent context is SourceFile, insertion location is start of func declaration
36473647
// or unary operator
36483648
insertionLoc = FD->isUnaryOperator() ? FD->getAttrs().getStartLoc() : FD->getStartLoc();
36493649
} else {
36503650
// Finding top-level decl context before SourceFile and inserting before it
36513651
for (DeclContext *CurContext = FD->getLocalContext();
3652-
CurContext;
3652+
!isa<SourceFile>(CurContext);
36533653
CurContext = CurContext->getParent()) {
36543654
insertionLoc = CurContext->getAsDecl()->getStartLoc();
3655-
if (dyn_cast<SourceFile>(CurContext->getParent()))
3656-
break;
36573655
}
36583656
}
36593657

@@ -3670,8 +3668,9 @@ void bindFuncDeclToOperator(TypeChecker &TC, FuncDecl *FD) {
36703668

36713669
insertion += operatorName.str();
36723670
insertion += " : <# Precedence Group #>\n";
3673-
TC.diagnose(FD, diag::declared_operator_without_operator_decl)
3674-
.fixItInsert(insertionLoc, insertion);
3671+
InFlightDiagnostic opDiagnostic = TC.diagnose(FD, diag::declared_operator_without_operator_decl);
3672+
if (insertionLoc.isValid())
3673+
opDiagnostic.fixItInsert(insertionLoc, insertion);
36753674
return;
36763675
}
36773676

0 commit comments

Comments
 (0)