From 0fb3dce54f6b86c8407f54dd68201fc66bf276a1 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Sat, 12 Jul 2025 16:16:06 +0800 Subject: [PATCH] bugfix class implements arkEvo interface Issue: #ICLUP2 Signed-off-by: wuhailong Change-Id: I1dc0548841574d591cbedb2d33be81111927ac07 --- .../interop/process_arkts_evolution.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts b/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts index 7cf11fe98..c374bfac7 100644 --- a/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts +++ b/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts @@ -604,9 +604,11 @@ function collectDeepInheritedInterfacesFromType(type: ts.Type, checker: ts.TypeC const ifacePath: string = getArkTSEvoFileOHMUrl(type); interfaces.add(`L${ifacePath}/${type.symbol.name};`); } - const baseTypes: ts.BaseType[] = checker.getBaseTypes(type as ts.InterfaceType) ?? []; - for (const baseType of baseTypes) { - collectDeepInheritedInterfacesFromType(baseType, checker, visited, interfaces); + if (hasResolvedBaseTypes(type)) { + const baseTypes: ts.BaseType[] = checker.getBaseTypes(type) ?? []; + for (const baseType of baseTypes) { + collectDeepInheritedInterfacesFromType(baseType, checker, visited, interfaces); + } } if (decls) { @@ -618,6 +620,14 @@ function collectDeepInheritedInterfacesFromType(type: ts.Type, checker: ts.TypeC } } +function hasResolvedBaseTypes(type: ts.Type): type is ts.InterfaceType { + return ( + (type.flags & ts.TypeFlags.Object) !== 0 && + ((type as ts.ObjectType).objectFlags & (ts.ObjectFlags.Class | ts.ObjectFlags.Interface)) !== 0 && + 'resolvedBaseTypes' in type + ); +} + function transformHeritage(context: ts.TransformationContext, classToInterfacesMap: Map>): ts.Visitor { return function visitor(node: ts.SourceFile): ts.SourceFile { -- Gitee