diff --git a/ets2panda/checker/types/ets/etsObjectType.h b/ets2panda/checker/types/ets/etsObjectType.h index 2f81c4be7c98481b663be75eb3c0a94a6bb28383..593acc0e410ee7dd259a6ef0fff55d61cda73d93 100644 --- a/ets2panda/checker/types/ets/etsObjectType.h +++ b/ets2panda/checker/types/ets/etsObjectType.h @@ -433,7 +433,12 @@ private: void EnsurePropertiesInstantiated() const { if (!propertiesInstantiated_) { + if (isInstantiatingProperties_) { + return; // avoid infinite recursive call + } + isInstantiatingProperties_ = true; InstantiateProperties(); + isInstantiatingProperties_ = false; propertiesInstantiated_ = true; } } @@ -478,6 +483,7 @@ private: // for lazy properties instantiation TypeRelation *relation_ = nullptr; const ArenaSubstitution *effectiveSubstitution_ = nullptr; + mutable bool isInstantiatingProperties_ = false; mutable bool propertiesInstantiated_ = false; mutable ArenaVector constructSignatures_; mutable PropertyHolder properties_; diff --git a/ets2panda/test/ast/compiler/ets/invalid_method_signature.ets b/ets2panda/test/ast/compiler/ets/invalid_method_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..740ba562f9167caa22f3da645e2a6b5a44c0d9b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/invalid_method_signature.ets @@ -0,0 +1,46 @@ +/* + * 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. + */ + +class D { + f9(z: W, y: Int): D.f9-2"; +} + +interface Preferences { + delenager.Preferences.Core yncCallback): void; +} + +/* @@? 17:5 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:9 Error TypeError: Cannot find type 'W'. */ +/* @@? 17:23 Error TypeError: 'f9' type does not exist. */ +/* @@? 17:23 Error TypeError: 'f9' type does not exist. */ +/* @@? 17:25 Error SyntaxError: Unexpected token '-'. */ +/* @@? 17:26 Error SyntaxError: Unexpected token '2'. */ +/* @@? 17:27 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 17:27 Error SyntaxError: Unexpected token ';'. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 20:24 Error SyntaxError: Identifier expected. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 20:24 Error SyntaxError: Identifier expected. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 20:24 Error SyntaxError: Identifier expected. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 20:24 Error SyntaxError: Identifier expected. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 20:24 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 20:24 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 20:24 Error TypeError: 'Core' type does not exist. */ +/* @@? 20:24 Error TypeError: 'Core' type does not exist. */