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 2019/04/11 22:29:36 UTC
[royale-compiler] branch develop updated: compiler: refined check
for local variable in new expression because the class_binding.isLocal()
check might include non-variables
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 ab7cb9d compiler: refined check for local variable in new expression because the class_binding.isLocal() check might include non-variables
ab7cb9d is described below
commit ab7cb9daadf2f1fc4d7f34d55c7eb10d05f6609a
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Apr 11 15:28:46 2019 -0700
compiler: refined check for local variable in new expression because the class_binding.isLocal() check might include non-variables
---
.../semantics/MethodBodySemanticChecker.java | 46 +++++++++++-----------
1 file changed, 23 insertions(+), 23 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 7c6eecd..52a5bd4 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
@@ -2056,29 +2056,7 @@ public class MethodBodySemanticChecker
{
IDefinition def = class_binding.getDefinition();
- if ( class_binding.isLocal() )
- {
- // Note: previously, local bindings were not checked at all, but
- // actually, variables of most types cannot be used with a "new"
- // expression -JT
-
- if (def instanceof IVariableDefinition)
- {
- ITypeDefinition typeDef = def.resolveType(project);
- if (typeDef != null
- && !SemanticUtils.isBuiltin(typeDef, BuiltinType.CLASS, project)
- && !SemanticUtils.isBuiltin(typeDef, BuiltinType.FUNCTION, project)
- && !SemanticUtils.isBuiltin(typeDef, BuiltinType.OBJECT, project)
- && !SemanticUtils.isBuiltin(typeDef, BuiltinType.ANY_TYPE, project))
- {
- addProblem(new CallUndefinedMethodProblem(
- roundUpUsualSuspects(class_binding, iNode),
- class_binding.getName().getBaseName()
- ));
- }
- }
- }
- else if ( def == null && utils.definitionCanBeAnalyzed(class_binding) && !(class_binding.getName().isTypeName()) )
+ if ( def == null && utils.definitionCanBeAnalyzed(class_binding) && !(class_binding.getName().isTypeName()) )
{
// Note: don't have to check accessability because
// AS3 mandates constructors be public.
@@ -2129,6 +2107,28 @@ public class MethodBodySemanticChecker
));
}
}
+ else if ( def instanceof IVariableDefinition)
+ {
+ if (class_binding.isLocal())
+ {
+ // Note: previously, local variable bindings were not checked at
+ // all, but actually, variables of most types cannot be used with a
+ // "new" expression -JT
+
+ ITypeDefinition typeDef = def.resolveType(project);
+ if (typeDef != null
+ && !SemanticUtils.isBuiltin(typeDef, BuiltinType.CLASS, project)
+ && !SemanticUtils.isBuiltin(typeDef, BuiltinType.FUNCTION, project)
+ && !SemanticUtils.isBuiltin(typeDef, BuiltinType.OBJECT, project)
+ && !SemanticUtils.isBuiltin(typeDef, BuiltinType.ANY_TYPE, project))
+ {
+ addProblem(new CallUndefinedMethodProblem(
+ roundUpUsualSuspects(class_binding, iNode),
+ class_binding.getName().getBaseName()
+ ));
+ }
+ }
+ }
checkReference(class_binding);
}