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 6c75f00b96f52a4d9072d558ec27da7ce30819e7
Author: Josh Tynjala <[email protected]>
AuthorDate: Mon Mar 16 09:55:44 2026 -0700

    MXMLClassReferenceNodeBase: stricter MXML handling of default element 
children
    
    MX Containers may have children, and classes with [DefaultProperty] 
metadata may have children, but a compile-time error should be reported for 
classes that meet neither requirement.
---
 .../tree/mxml/MXMLClassReferenceNodeBase.java      | 29 +++++++++++++++-------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
index ad39d68fd..e452e09e2 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
@@ -51,6 +51,7 @@ import org.apache.royale.compiler.mxml.IMXMLUnitData;
 import org.apache.royale.compiler.parsing.MXMLTokenTypes;
 import org.apache.royale.compiler.problems.ICompilerProblem;
 import org.apache.royale.compiler.problems.MXMLDuplicateChildTagProblem;
+import org.apache.royale.compiler.problems.MXMLUnexpectedTagProblem;
 import org.apache.royale.compiler.problems.MXMLUnresolvedTagProblem;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.tree.ASTNodeID;
@@ -494,8 +495,9 @@ abstract class MXMLClassReferenceNodeBase extends 
MXMLNodeBase implements IMXMLC
             if (definition instanceof ClassDefinition)
             {
                 // Handle child tags that are instance tags.
+                IClassDefinition classDefinition = (IClassDefinition) 
definition;
 
-                if (isMXML2006Declaration(childTag, definition, builder))
+                if (isMXML2006Declaration(childTag, classDefinition, builder))
                 {
                     // This tag is not part of the default property value.
                     processNonDefaultPropertyContentUnit(builder, info, tag);
@@ -531,14 +533,23 @@ abstract class MXMLClassReferenceNodeBase extends 
MXMLNodeBase implements IMXMLC
                     }
                     else
                     {
-                        // This tag is not part of the default property value.
-                        processNonDefaultPropertyContentUnit(builder, info, 
tag);
-
-                        MXMLInstanceNode instanceNode = 
MXMLInstanceNode.createInstanceNode(
-                                builder, definition.getQualifiedName(), this);
-                        instanceNode.setClassReference(project, 
(IClassDefinition)definition); // TODO Move this logic to initializeFromTag().
-                        instanceNode.initializeFromTag(builder, childTag);
-                        info.addChildNode(instanceNode);   
+                        if (isContainer() && 
classDefinition.isInstanceOf(uiComponentInterface, builder.getProject()))
+                        {
+                            // This tag is not part of the default property 
value.
+                            processNonDefaultPropertyContentUnit(builder, 
info, tag);
+
+                            MXMLInstanceNode instanceNode = 
MXMLInstanceNode.createInstanceNode(
+                                    builder, definition.getQualifiedName(), 
this);
+                            instanceNode.setClassReference(project, 
(IClassDefinition)definition); // TODO Move this logic to initializeFromTag().
+                            instanceNode.initializeFromTag(builder, childTag);
+                            info.addChildNode(instanceNode);   
+                        }
+                        else
+                        {
+                            // no default property, and not an IUIComponent
+                            // inside an IContainer.
+                            builder.getProblems().add(new 
MXMLUnexpectedTagProblem(childTag));
+                        }
                     }
                 }
             }

Reply via email to