You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/03/16 07:33:17 UTC
[royale-compiler] 02/02: Match Flex for IEventDispatcher-ness with
Bindable classes that receive the IEventDispatcher upgrades from the
compiler.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit ff8aa37f90c5084e7176fd5d4861276b71375b81
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Mar 16 20:01:06 2020 +1300
Match Flex for IEventDispatcher-ness with Bindable classes that receive the IEventDispatcher upgrades from the compiler.
---
.../semantics/MethodBodySemanticChecker.java | 28 ++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
index 349a4a8..5640c8d 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
@@ -66,11 +66,14 @@ import org.apache.royale.compiler.definitions.ISetterDefinition;
import org.apache.royale.compiler.definitions.ITypeDefinition;
import org.apache.royale.compiler.definitions.IVariableDefinition;
import org.apache.royale.compiler.definitions.references.INamespaceReference;
+import org.apache.royale.compiler.internal.as.codegen.*;
import org.apache.royale.compiler.internal.definitions.AmbiguousDefinition;
import org.apache.royale.compiler.internal.definitions.VariableDefinition;
+import org.apache.royale.compiler.internal.scopes.ASProjectScope;
import org.apache.royale.compiler.problems.*;
import org.apache.royale.compiler.projects.ICompilerProject;
import org.apache.royale.compiler.scopes.IASScope;
+import org.apache.royale.compiler.scopes.IDefinitionSet;
import org.apache.royale.compiler.tree.ASTNodeID;
import org.apache.royale.compiler.tree.as.IASNode;
import org.apache.royale.compiler.tree.as.IBinaryOperatorNode;
@@ -90,10 +93,6 @@ import org.apache.royale.compiler.tree.as.IScopedNode;
import org.apache.royale.compiler.tree.as.ITypedExpressionNode;
import org.apache.royale.compiler.tree.as.IUnaryOperatorNode;
import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.apache.royale.compiler.internal.as.codegen.ABCGeneratingReducer;
-import org.apache.royale.compiler.internal.as.codegen.Binding;
-import org.apache.royale.compiler.internal.as.codegen.InlineFunctionLexicalScope;
-import org.apache.royale.compiler.internal.as.codegen.LexicalScope;
import org.apache.royale.compiler.internal.definitions.AccessorDefinition;
import org.apache.royale.compiler.internal.definitions.ClassDefinition;
import org.apache.royale.compiler.internal.definitions.ClassTraitsDefinition;
@@ -847,6 +846,13 @@ public class MethodBodySemanticChecker
}
}
+ private IInterfaceDefinition iEventDispatcher(){
+ String iEventDispatcherPackage = BindableHelper.NAME_IEVENT_DISPATCHER.getQualifiers().getSingleQualifier().getName();
+ String iEventDispatcherName = BindableHelper.NAME_IEVENT_DISPATCHER.getBaseName();
+ IDefinition iEventDispatcher = ((ASProjectScope)(project.getScope())).findDefinitionByName(iEventDispatcherPackage + "." + iEventDispatcherName);
+ if (iEventDispatcher instanceof IInterfaceDefinition) return (IInterfaceDefinition) iEventDispatcher;
+ return null;
+ }
/**
* Check a function call.
@@ -864,6 +870,19 @@ public class MethodBodySemanticChecker
}
IDefinition def = method_binding.getDefinition();
+ if (def == null) {
+ IDefinition defCheck = SemanticUtils.getDefinitionOfUnderlyingType(iNode,true, project);
+ if (defCheck instanceof IClassDefinition) {
+ //if we are adding the bindable IEventDispatcher implementation, then we should allow those IEventDispatcher methods
+ if (((IClassDefinition)defCheck).needsEventDispatcher(project)) {
+ IInterfaceDefinition iEventDispatcher = iEventDispatcher();
+ IDefinitionSet bindingMethodCheck = iEventDispatcher.getContainedScope().getLocalDefinitionSetByName( method_binding.getName().getBaseName());
+ if (bindingMethodCheck!=null && bindingMethodCheck.getSize() == 1) {
+ def = bindingMethodCheck.getDefinition(0);
+ }
+ }
+ }
+ }
if ( def == null && utils.definitionCanBeAnalyzed(method_binding) )
{
@@ -878,6 +897,7 @@ public class MethodBodySemanticChecker
}
else if ( SemanticUtils.hasExplicitStem(iNode) && utils.hasUnderlyingType(iNode) )
{
+
addProblem(new StrictUndefinedMethodProblem(
roundUpUsualSuspects(method_binding, iNode),
method_binding.getName().getBaseName(),