File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -3642,18 +3642,16 @@ void bindFuncDeclToOperator(TypeChecker &TC, FuncDecl *FD) {
3642
3642
3643
3643
if (!op) {
3644
3644
SourceLoc insertionLoc;
3645
- if (dyn_cast <SourceFile>(FD->getParent ())) {
3645
+ if (isa <SourceFile>(FD->getParent ())) {
3646
3646
// Parent context is SourceFile, insertion location is start of func declaration
3647
3647
// or unary operator
3648
3648
insertionLoc = FD->isUnaryOperator () ? FD->getAttrs ().getStartLoc () : FD->getStartLoc ();
3649
3649
} else {
3650
3650
// Finding top-level decl context before SourceFile and inserting before it
3651
3651
for (DeclContext *CurContext = FD->getLocalContext ();
3652
- CurContext;
3652
+ !isa<SourceFile>( CurContext) ;
3653
3653
CurContext = CurContext->getParent ()) {
3654
3654
insertionLoc = CurContext->getAsDecl ()->getStartLoc ();
3655
- if (dyn_cast<SourceFile>(CurContext->getParent ()))
3656
- break ;
3657
3655
}
3658
3656
}
3659
3657
@@ -3670,8 +3668,9 @@ void bindFuncDeclToOperator(TypeChecker &TC, FuncDecl *FD) {
3670
3668
3671
3669
insertion += operatorName.str ();
3672
3670
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);
3675
3674
return ;
3676
3675
}
3677
3676
You can’t perform that action at this time.
0 commit comments