You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2026/01/21 00:07:48 UTC
(royale-compiler) 01/04: AsIsEmitter: fix (x as *) emitting Language.as(x, *) in JS, where * doesn't exist
This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit 5ef5638c54af643819c2a56d546f09bb3e0af371
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Jan 20 13:23:09 2026 -0800
AsIsEmitter: fix (x as *) emitting Language.as(x, *) in JS, where * doesn't exist
---
.../royale/compiler/internal/codegen/js/jx/AsIsEmitter.java | 7 +++++++
.../internal/codegen/js/royale/TestRoyaleExpressions.java | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AsIsEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AsIsEmitter.java
index cf35c48d5..1b7c62669 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AsIsEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AsIsEmitter.java
@@ -57,6 +57,13 @@ public class AsIsEmitter extends JSSubEmitter
//IDefinition dnode = project != null ? (right).resolve(project) : null;
IDefinition dnode = getProject() != null ? (right)
.resolve(getProject()) : null;
+ if (id == ASTNodeID.Op_AsID && dnode != null && IASLanguageConstants.ANY_TYPE.equals(dnode.getQualifiedName()))
+ {
+ write("/** @type {*} */ (");
+ getWalker().walk(left);
+ write(")");
+ return;
+ }
if (id != ASTNodeID.Op_IsID && dnode != null)
{
boolean emit = coercion ?
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
index 13c7a7b1f..8e7ebac11 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
@@ -1580,6 +1580,14 @@ public class TestRoyaleExpressions extends TestExpressions
assertOut("org.apache.royale.utils.Language.as(a, org.apache.royale.utils.Language.synthType('uint'))");
}
+ @Test
+ public void testVisitAsAny()
+ {
+ IBinaryOperatorNode node = getBinaryNode("a as *");
+ asBlockWalker.visitBinaryOperator(node);
+ assertOut("/** @type {*} */ (a)");
+ }
+
@Test
public void testVisitAsMemberVariable()
{