Skip to content

Commit 6b31c97

Browse files
committed
Sema: Synthesize function bodies before type checking external declarations
1 parent dbf2a9b commit 6b31c97

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/Sema/TypeChecker.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,17 @@ static void typeCheckFunctionsAndExternalDecls(SourceFile &SF, TypeChecker &TC)
453453
TC.typeCheckAbstractFunctionBody(AFD);
454454
}
455455

456+
// Synthesize any necessary function bodies.
457+
// FIXME: If we're not planning to run SILGen, this is wasted effort.
458+
while (!TC.FunctionsToSynthesize.empty()) {
459+
auto function = TC.FunctionsToSynthesize.back().second;
460+
TC.FunctionsToSynthesize.pop_back();
461+
if (function.getDecl()->isInvalid() || TC.Context.hadError())
462+
continue;
463+
464+
TC.synthesizeFunctionBody(function);
465+
}
466+
456467
// Type check external definitions.
457468
for (unsigned n = TC.Context.ExternalDefinitions.size();
458469
currentExternalDef != n;
@@ -483,17 +494,6 @@ static void typeCheckFunctionsAndExternalDecls(SourceFile &SF, TypeChecker &TC)
483494
TC.validateDecl(decl);
484495
}
485496

486-
// Synthesize any necessary function bodies.
487-
// FIXME: If we're not planning to run SILGen, this is wasted effort.
488-
while (!TC.FunctionsToSynthesize.empty()) {
489-
auto function = TC.FunctionsToSynthesize.back().second;
490-
TC.FunctionsToSynthesize.pop_back();
491-
if (function.getDecl()->isInvalid() || TC.Context.hadError())
492-
continue;
493-
494-
TC.synthesizeFunctionBody(function);
495-
}
496-
497497
// Validate any referenced declarations for SIL's purposes.
498498
// Note: if we ever start putting extension members in vtables, we'll need
499499
// to validate those members too.

0 commit comments

Comments
 (0)