@@ -381,6 +381,8 @@ ProtocolConformance *deriveConformanceForInvertible(Evaluator &evaluator,
381
381
if (!ip)
382
382
llvm_unreachable (" not an invertible protocol" );
383
383
384
+ auto file = cast<FileUnit>(nominal->getModuleScopeContext ());
385
+
384
386
// Generates a conformance for the nominal to the protocol.
385
387
// The conformanceDC specifies THE decl context to use for the conformance.
386
388
auto generateConformance =
@@ -430,7 +432,6 @@ ProtocolConformance *deriveConformanceForInvertible(Evaluator &evaluator,
430
432
nominal->addExtension (ext);
431
433
432
434
// Make it accessible to getTopLevelDecls() so it gets type-checked.
433
- auto file = cast<FileUnit>(nominal->getModuleScopeContext ());
434
435
file->getOrCreateSynthesizedFile ().addTopLevelDecl (ext);
435
436
436
437
// Then create the conformance using the extension as the conformance's
@@ -469,8 +470,10 @@ ProtocolConformance *deriveConformanceForInvertible(Evaluator &evaluator,
469
470
//
470
471
// I'm currently unsure what happens when rebuilding a module from its
471
472
// interface, so this might not be unreachable code just yet.
472
- if (SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS)
473
+ if (SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS &&
474
+ file->getKind () != FileUnitKind::Synthesized) {
473
475
llvm_unreachable (" when can this actually happen??" );
476
+ }
474
477
475
478
// If there's no inverse, we infer a positive IP conformance.
476
479
return generateConformance (nominal);
0 commit comments