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


The following commit(s) were added to refs/heads/develop by this push:
     new a90b17068 MXMLPropertySpecifierNode: fix crash when IStyleDefinition 
was incorrectly cast to IVariableDefinition when handling default property for 
type Object
a90b17068 is described below

commit a90b170687075deaacebd68ba056d829b243232d
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue May 14 13:51:45 2024 -0700

    MXMLPropertySpecifierNode: fix crash when IStyleDefinition was incorrectly 
cast to IVariableDefinition when handling default property for type Object
---
 RELEASE_NOTES.md                                            |  1 +
 .../internal/tree/mxml/MXMLPropertySpecifierNode.java       | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index e596c91b4..48fba9674 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -31,6 +31,7 @@ Apache Royale Compiler 0.9.11
 - compiler: Added CSS support for modern syntax without commas in `rgb` and 
`rgba` functions.
 - compiler: Added CSS support for `radial-gradient`, `conic-gradient`, and 
repeating gradient functions.
 - compiler: Added CSS support for several translate, rotate, scale, skew, and 
matrix transformation functions.
+- compiler: Fix crash when `[Style]` is of type `Object` and value is passed 
in MXML.
 - debugger: Fix exception when evaluating certain expressions at run-time.
 - formatter: Added `insert-new-line-else` configuration option.
 - formatter: Filtered out unnecessary compiler warnings.
diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
index b6a096b11..469097b72 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
@@ -317,7 +317,18 @@ class MXMLPropertySpecifierNode extends 
MXMLSpecifierNodeBase implements IMXMLPr
             {
                 if (unit instanceof IMXMLTagData)
                 {
-                    initializeDefaultProperty(builder, 
(IVariableDefinition)getDefinition(), 
+                    IVariableDefinition variableDefinition = null;
+                    IDefinition propertyDefinition = getDefinition();
+                    if (propertyDefinition instanceof IVariableDefinition)
+                    {
+                        variableDefinition = (IVariableDefinition) 
propertyDefinition;
+                    }
+                    // this code used to cast getDefinition() as
+                    // IVariableDefinition, but it crashed if the return value
+                    // was IStyleDefinition instead.
+                    // now, we pass null for definitions that aren't variables,
+                    // to avoid the crash. however, is that the right solution?
+                    initializeDefaultProperty(builder, variableDefinition, 
                                 tag, getListOfUnits(tag));
                     return;                        
                 }

Reply via email to