Skip to content

Commit 07f069c

Browse files
committed
[Sema] only check conformance of synth. extensions
1 parent a4e9919 commit 07f069c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/Sema/TypeChecker.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,18 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const {
293293
// Type-check macro-generated or implicitly-synthesized extensions.
294294
if (auto *synthesizedSF = SF->getSynthesizedFile()) {
295295
for (auto *decl : synthesizedSF->getTopLevelDecls()) {
296-
assert(isa<ExtensionDecl>(decl));
297-
TypeChecker::typeCheckDecl(decl);
296+
auto extension = cast<ExtensionDecl>(decl);
297+
298+
// Limit typechecking of synthesized _impicit_ extensions to conformance
299+
// checking. This is done because a conditional conformance to Copyable
300+
// is synthesized as an extension, based on the markings of `~Copyable`
301+
// in a value type. This call to `checkConformancesInContext` will
302+
// the actual check to verify that the conditional extension is correct,
303+
// as it may be an invalid conformance.
304+
if (extension->isImplicit())
305+
TypeChecker::checkConformancesInContext(extension);
306+
else
307+
TypeChecker::typeCheckDecl(extension);
298308
}
299309
}
300310
SF->typeCheckDelayedFunctions();

0 commit comments

Comments
 (0)