From 2d07d98c1f219bac2b6ff54514debe0c5652440e Mon Sep 17 00:00:00 2001 From: Denis Slynko Date: Tue, 2 Sep 2025 17:03:32 +0300 Subject: [PATCH] [ArkTS] Fix ImportMetadata::ohmUrl assignment Issue: #ICW290 Change-Id: I3b5b1ca67ccd38d5b0c0e59f9d049e3358ca81a9 Signed-off-by: Denis Slynko --- ets2panda/util/importPathManager.cpp | 10 ++++++---- ets2panda/util/importPathManager.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ets2panda/util/importPathManager.cpp b/ets2panda/util/importPathManager.cpp index a22a321bea..3313a9fa13 100644 --- a/ets2panda/util/importPathManager.cpp +++ b/ets2panda/util/importPathManager.cpp @@ -76,7 +76,8 @@ void ImportPathManager::ProcessExternalLibraryImport(ImportMetadata &importData) // process emptry "path" in dependencies, since in interop we allow imports without typecheck if (!Helpers::EndsWith(std::string(externalModuleImportData.Path()), ".abc")) { importData.importFlags |= ImportFlags::EXTERNAL_SOURCE_IMPORT; - importData.ohmUrl.assign(externalModuleImportData.OhmUrl(), externalModuleImportData.OhmUrl().size()); + util::UString ohmUrlLocal {externalModuleImportData.OhmUrl(), allocator_}; + importData.ohmUrl = ohmUrlLocal.View().Utf8(); return; } @@ -99,9 +100,10 @@ void ImportPathManager::ProcessExternalLibraryImport(ImportMetadata &importData) // rely on the following mangling: .ETSGLOBAL auto etsGlobalSuffix = std::string(".") + std::string(compiler::Signatures::ETS_GLOBAL); ES2PANDA_ASSERT(Helpers::EndsWith(etsGlobalRecord->second.name, etsGlobalSuffix)); - auto moduleName = - etsGlobalRecord->second.name.substr(0, etsGlobalRecord->second.name.size() - etsGlobalSuffix.size()); - importData.ohmUrl = moduleName; + util::UString moduleName { + etsGlobalRecord->second.name.substr(0, etsGlobalRecord->second.name.size() - etsGlobalSuffix.size()), + allocator_}; + importData.ohmUrl = moduleName.View().Utf8(); auto annotations = etsGlobalRecord->second.metadata->GetAnnotations(); auto moduleDeclarationAnno = std::find_if(annotations.begin(), annotations.end(), [](auto &anno) { diff --git a/ets2panda/util/importPathManager.h b/ets2panda/util/importPathManager.h index 02273bf0ec..5979defc02 100644 --- a/ets2panda/util/importPathManager.h +++ b/ets2panda/util/importPathManager.h @@ -83,7 +83,7 @@ public: Language::Id lang {Language::Id::COUNT}; std::string_view resolvedSource {}; std::string_view declPath {}; - std::string ohmUrl {}; + std::string_view ohmUrl {}; std::string_view declText {}; // NOLINTEND(misc-non-private-member-variables-in-classes) -- Gitee