diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 3fe590ae199f220822b23cb74cc52f9c48905d17..6c13296f648f7e4399df5fa58ce59cdaf81d0c28 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -2004,7 +2004,12 @@ checker::Type *ETSAnalyzer::CheckDynamic(ir::ObjectExpression *expr) const static bool ValidatePreferredType(ETSChecker *checker, ir::ObjectExpression *expr) { - auto preferredType = expr->PreferredType(); + auto preferredType = expr->PreferredType()->MaybeBaseTypeOfGradualType(); + if (preferredType == nullptr) { + checker->LogError(diagnostic::CLASS_COMPOSITE_UNKNOWN_TYPE, {}, expr->Start()); + return false; + } + if (preferredType->IsTypeError()) { // Don't need to duplicate error message for a single error. return false; diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index 9ffb2732ec79529dfbc8f6fae64ab9a5ed0e3395..66fb67ba663d0820b68437c86063e8909f419750 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -125,7 +125,8 @@ ir::MethodDefinition *InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter ctx->Allocator(), ir::ScriptFunction::ScriptFunctionData { nullptr, std::move(signature), // CC-OFF(G.FMT.02) project code style // CC-OFFNXT(G.FMT.02) project code style - isSetter ? ir::ScriptFunctionFlags::SETTER : ir::ScriptFunctionFlags::GETTER, flags}); + isSetter ? ir::ScriptFunctionFlags::SETTER : ir::ScriptFunctionFlags::GETTER, flags, + classScope->Node()->AsTSInterfaceDeclaration()->Language()}); func->SetRange(field->Range()); func->SetScope(functionScope); diff --git a/ets2panda/compiler/lowering/ets/unboxLowering.cpp b/ets2panda/compiler/lowering/ets/unboxLowering.cpp index 0e5299b8229ce42fd61f03c60511f0142ff83851..ef0704c10e907b0bdfc4545435a4420914901f9c 100644 --- a/ets2panda/compiler/lowering/ets/unboxLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unboxLowering.cpp @@ -268,6 +268,11 @@ static void NormalizeAllTypes(UnboxContext *uctx, ir::AstNode *ast) static void HandleScriptFunctionHeader(UnboxContext *uctx, ir::ScriptFunction *func) { + // dynamic function does not need to unbox + if (func->Language() == Language::Id::JS) { + return; + } + auto *sig = func->Signature(); if (sig == nullptr) { return;