diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 149c12d4d57963671b7f818166bbcc4ac098b78d..dde5c4c5602ca61cb4024533b5299b14e0b7a85b 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -1201,10 +1201,6 @@ void ETSGen::CastToReftype(const ir::AstNode *const node, const checker::Type *c const auto *const sourceType = GetAccumulatorType(); ES2PANDA_ASSERT(sourceType->IsETSReferenceType()); - if (targetType->IsETSStringType() && !sourceType->IsETSStringType()) { - CastToString(node); - } - if (!unchecked) { CheckedReferenceNarrowing(node, targetType); return; diff --git a/ets2panda/test/runtime/ets/no-as-string.ets b/ets2panda/test/runtime/ets/no-as-string.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ced428c7e75f5c0e3103b5f7f5d74df4a448731 --- /dev/null +++ b/ets2panda/test/runtime/ets/no-as-string.ets @@ -0,0 +1,12 @@ +function ff(o: Object): string { + return o as string +} + +function main(): int { + try { + ff(44) + return 1 + } catch (e) { + return 0 + } +}