diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index 3cde016475c0dc517a15fc6c6871511390634a11..88a71002f8b233850bcbf3444e179df12e41f060 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -271,6 +271,9 @@ void ETSChecker::InitializeBuiltins(varbinder::ETSBinder *varbinder) } const auto varMap = varbinder->TopScope()->Bindings(); + if (varMap.find(compiler::Signatures::BUILTIN_OBJECT_CLASS) == varMap.end()) { + return; + } auto const objectName = InitBuiltin(this, compiler::Signatures::BUILTIN_OBJECT_CLASS); diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index c09ef969526ebd93230c91bbba113b5f4b7f5886..b3af0fc6c574caf78792ce5f538dd5c0529e5835 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -553,7 +553,7 @@ void ETSChecker::CheckDynamicInheritanceAndImplement(ETSObjectType *const interf interfaceOrClassType->GetDeclNode()->Start()); } } - if (isFromDynamicDecl(interfaceOrClassType->SuperType())) { + if (interfaceOrClassType->SuperType() != nullptr && isFromDynamicDecl(interfaceOrClassType->SuperType())) { LogError(diagnostic::INTERFACE_OR_CLASS_CANNOT_IMPL_OR_EXTEND_DYNAMIC, {getTypeString(interfaceOrClassType), interfaceOrClassType->Name(), "extends", getTypeString(interfaceOrClassType->SuperType()), interfaceOrClassType->SuperType()->Name()}, diff --git a/ets2panda/test/tsconfig/test-config/builtin-init/arkconfig.json b/ets2panda/test/tsconfig/test-config/builtin-init/arkconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..f8fbd7cee6447b62cc979efc7bf10bef9f8ea3e8 --- /dev/null +++ b/ets2panda/test/tsconfig/test-config/builtin-init/arkconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "outDir": "outdir" + }, + "files": [ + "./src/file_1.ets", + "./src/file_2.ets" + ] +} \ No newline at end of file diff --git a/ets2panda/test/tsconfig/test-config/builtin-init/expected.json b/ets2panda/test/tsconfig/test-config/builtin-init/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..65b5812cb9bd3dc5435c67e9f9da1e6b4d891425 --- /dev/null +++ b/ets2panda/test/tsconfig/test-config/builtin-init/expected.json @@ -0,0 +1,8 @@ +{ + "returncode": 1, + "stdout": "Fatal error: Failed to compile from builtin-init/src/file_2.ets to builtin-init/outdir/src/file_2.abc\nFatal error: Failed to compile from builtin-init/src/file_1.ets to builtin-init/outdir/src/file_1.abc\nFatal error: Can't find prefix for 'file_1.ets' in builtin-init/arkconfig.json [file_2.ets:16:29]\nFatal error: Can't find prefix for 'file_1.ets' in builtin-init/arkconfig.json [file_2.ets:17:40]\nFatal error: Can't find prefix for 'file_1.ets' in builtin-init/arkconfig.json [file_2.ets:18:33]\nFatal error: Can't find prefix for 'file_1.ets' in builtin-init/arkconfig.json [file_2.ets:19:48]\nTypeError: Cannot find type 'Class1'. [file_2.ets:28:20]\nTypeError: Cannot find type 'Class_1'. [file_2.ets:31:20]\nFatal error: Can't find prefix for 'std/core' in builtin-init/arkconfig.json [.ets:1:15]\nFatal error: Can't find prefix for 'std/math' in builtin-init/arkconfig.json [.ets:1:40]\nFatal error: Can't find prefix for 'std/containers' in builtin-init/arkconfig.json [.ets:1:65]\nFatal error: Can't find prefix for 'std/interop/js' in builtin-init/arkconfig.json [.ets:1:96]\nFatal error: Can't find prefix for 'std/time' in builtin-init/arkconfig.json [.ets:1:127]\nFatal error: Can't find prefix for 'std/debug' in builtin-init/arkconfig.json [.ets:1:152]\nFatal error: Can't find prefix for 'std/debug/concurrency' in builtin-init/arkconfig.json [.ets:1:178]\nFatal error: Can't find prefix for 'std/testing' in builtin-init/arkconfig.json [.ets:1:216]\nFatal error: Can't find prefix for 'escompat' in builtin-init/arkconfig.json [.ets:1:244]\nFatal error: Can't find prefix for 'std/concurrency' in builtin-init/arkconfig.json [.ets:1:269]\nFatal error: Can't find prefix for 'std/annotations' in builtin-init/arkconfig.json [.ets:1:301]\nFatal error: Can't find prefix for 'std/interop' in builtin-init/arkconfig.json [.ets:1:333]", + "stderr": "" +} + + + diff --git a/ets2panda/test/tsconfig/test-config/builtin-init/src/file_1.ets b/ets2panda/test/tsconfig/test-config/builtin-init/src/file_1.ets new file mode 100644 index 0000000000000000000000000000000000000000..71c1a5d861bfc14d53c62bfcde08ced87614f386 --- /dev/null +++ b/ets2panda/test/tsconfig/test-config/builtin-init/src/file_1.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class Class1 { + constructor() {} +} + +export interface Interface1{} diff --git a/ets2panda/test/tsconfig/test-config/builtin-init/src/file_2.ets b/ets2panda/test/tsconfig/test-config/builtin-init/src/file_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..70a9e88d66b07284812d93dd60dd53c4a75f4d80 --- /dev/null +++ b/ets2panda/test/tsconfig/test-config/builtin-init/src/file_2.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type { Class1 } from 'file_1.ets'; +import type { Class1 as Class_1 } from 'file_1.ets'; +import type { Interface1 } from 'file_1.ets'; +import type { Interface1 as Interface_1 } from 'file_1.ets'; + +export class Class2 { + constructor() {} +} + +export interface Interface2 { +} + +function f1(value: Class1): void { +} + +function f2(value: Class_1): void { +}