From d1f89ea26041b0bc9cd9ef1555f17f1bce09ce59 Mon Sep 17 00:00:00 2001 From: Nate Chandler Date: Mon, 24 Feb 2025 12:16:57 -0800 Subject: [PATCH] Check file type better in this verifier. Ask the decl directly whether its source file is a sil source file. --- lib/SIL/IR/TypeLowering.cpp | 18 ++++++++---------- test/IRGen/enum_value_semantics_future.sil | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/SIL/IR/TypeLowering.cpp b/lib/SIL/IR/TypeLowering.cpp index 44866177638fd..d0b388ffe1b1d 100644 --- a/lib/SIL/IR/TypeLowering.cpp +++ b/lib/SIL/IR/TypeLowering.cpp @@ -3228,19 +3228,17 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering, if (auto *nominal = substType.getAnyNominal()) { auto *module = nominal->getModuleContext(); - if (module) { - if (module->isBuiltFromInterface()) { + if (module && module->isBuiltFromInterface()) { // Don't verify for types in modules built from interfaces; the feature // may not have been enabled in them. return; - } - auto *file = dyn_cast_or_null(module->getModuleScopeContext()); - if (file && file->getKind() == FileUnitKind::Source) { - auto sourceFile = nominal->getParentSourceFile(); - if (sourceFile && sourceFile->Kind == SourceFileKind::SIL) { - // Don't verify for types in SIL files. - return; - } + } + auto *file = nominal->getParentSourceFile(); + if (file && file->getKind() == FileUnitKind::Source) { + auto sourceFile = nominal->getParentSourceFile(); + if (sourceFile && sourceFile->Kind == SourceFileKind::SIL) { + // Don't verify for types in SIL files. + return; } } } diff --git a/test/IRGen/enum_value_semantics_future.sil b/test/IRGen/enum_value_semantics_future.sil index 0f7d77091828d..d950e725a816a 100644 --- a/test/IRGen/enum_value_semantics_future.sil +++ b/test/IRGen/enum_value_semantics_future.sil @@ -8,6 +8,7 @@ // UNSUPPORTED: CPU=armv7s && OS=ios import Builtin +import Swift enum NoPayload { case a