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 c6f396bc31b6a122d7d6cfb93d84925035b4b603 Author: Josh Tynjala <joshtynj...@apache.org> AuthorDate: Tue Sep 2 10:17:32 2025 -0700 MXMLComponentNode: fix null exception when fx:Component doesn't have a correct closing tag Instead, adds an MXMLSemanticProblem. This shouldn't be displayed to the user because the parsing problems will take precedence. However, if there's a weird edge case, it might, so at least there isn't a complete lack of an error. --- .../internal/tree/mxml/MXMLComponentNode.java | 45 +++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLComponentNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLComponentNode.java index 8f4ee9124..9d40ad6ab 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLComponentNode.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLComponentNode.java @@ -159,25 +159,34 @@ class MXMLComponentNode extends MXMLFactoryNode implements IMXMLComponentNode ClassDefinition fxComponentClassDefinition = fileScope.getClassDefinitionForComponentTag(tag); - assert fxComponentClassDefinition != null : "MXMLScopeBuilder failed to build a class for an fx:Component"; - - // attach scope with the component class definition node. - TypeScope componentClassScope = (TypeScope)fxComponentClassDefinition.getContainedScope(); - containedClassDefinitionNode.setScope(componentClassScope); // TODO Move this logic to initializeFromTag(). - - // Connect node to definitions and vice versa. - containedClassDefinitionNode.setClassReference(project, tagDefinition); // TODO Move this logic to initializeFromTag(). - containedClassDefinitionNode.setClassDefinition(fxComponentClassDefinition); // TODO Move this logic to initializeFromTag(). - - int nameStart = fxComponentClassDefinition.getNameStart(); - int nameEnd = fxComponentClassDefinition.getNameEnd(); - fxComponentClassDefinition.setNode(containedClassDefinitionNode); - // TODO The above call is setting nameStart and nameEnd to -1 - // because the MXML class definition node doesn't have a name expression node. - // We need to reset the correct nameStart and nameEnd. - fxComponentClassDefinition.setNameLocation(nameStart, nameEnd); + if (fxComponentClassDefinition == null) + { + // MXMLScopeBuilder failed to build a class for an fx:Component - containedClassDefinitionNode.initializeFromTag(builder, childTag); + // TODO Add a problem subclass for this. + ICompilerProblem problem = new MXMLSemanticProblem(tag); + builder.addProblem(problem); + } + else + { + // attach scope with the component class definition node. + TypeScope componentClassScope = (TypeScope)fxComponentClassDefinition.getContainedScope(); + containedClassDefinitionNode.setScope(componentClassScope); // TODO Move this logic to initializeFromTag(). + + // Connect node to definitions and vice versa. + containedClassDefinitionNode.setClassReference(project, tagDefinition); // TODO Move this logic to initializeFromTag(). + containedClassDefinitionNode.setClassDefinition(fxComponentClassDefinition); // TODO Move this logic to initializeFromTag(). + + int nameStart = fxComponentClassDefinition.getNameStart(); + int nameEnd = fxComponentClassDefinition.getNameEnd(); + fxComponentClassDefinition.setNode(containedClassDefinitionNode); + // TODO The above call is setting nameStart and nameEnd to -1 + // because the MXML class definition node doesn't have a name expression node. + // We need to reset the correct nameStart and nameEnd. + fxComponentClassDefinition.setNameLocation(nameStart, nameEnd); + + containedClassDefinitionNode.initializeFromTag(builder, childTag); + } } if (!handled) {