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
The following commit(s) were added to refs/heads/develop by this push:
new a085e7e Fix for #92. return typing for removeAt method on a Vector
should resolve to the Vector's element type. This is a bug that seems to have
been an issue since original Falcon code. (It is currently still present in
Adobe Animate)
a085e7e is described below
commit a085e7e6d3820ae27379e9cf22d02e3ac55bbfcd
Author: greg-dove <[email protected]>
AuthorDate: Wed Jul 31 13:04:45 2019 +1200
Fix for #92. return typing for removeAt method on a Vector should resolve
to the Vector's element type.
This is a bug that seems to have been an issue since original Falcon code.
(It is currently still present in Adobe Animate)
---
.../compiler/internal/tree/as/FunctionCallNode.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/FunctionCallNode.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/FunctionCallNode.java
index 255eee5..b0628fb 100644
---
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/FunctionCallNode.java
+++
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/FunctionCallNode.java
@@ -23,10 +23,7 @@ import java.util.ArrayList;
import org.apache.royale.compiler.constants.IASLanguageConstants;
import org.apache.royale.compiler.constants.IASLanguageConstants.BuiltinType;
-import org.apache.royale.compiler.definitions.IAccessorDefinition;
-import org.apache.royale.compiler.definitions.IDefinition;
-import org.apache.royale.compiler.definitions.IFunctionDefinition;
-import org.apache.royale.compiler.definitions.ITypeDefinition;
+import org.apache.royale.compiler.definitions.*;
import org.apache.royale.compiler.parsing.IASToken;
import org.apache.royale.compiler.projects.ICompilerProject;
import org.apache.royale.compiler.tree.ASTNodeID;
@@ -211,8 +208,17 @@ public class FunctionCallNode extends ExpressionNodeBase
implements IFunctionCal
// new foo() returns the * type
if (getNewKeywordNode() != null)
return project.getBuiltinType(BuiltinType.ANY_TYPE);
- else
- return
((IFunctionDefinition)calledFunction).resolveReturnType(project);
+ else {
+ //special case: removeAt on a Vector needs to resolve its
return type to type 'T' (element type), not 'Object' (as it does with Array
method)
+ if (calledFunction.getQualifiedName().equals("removeAt")
+ && calledFunction.getContainingScope() != null
+ && calledFunction.getContainingScope().getDefinition()
instanceof IAppliedVectorDefinition)
+ {
+ return
((IAppliedVectorDefinition)(calledFunction.getContainingScope().getDefinition())).resolveElementType(project);
+ } else {
+ return
((IFunctionDefinition)calledFunction).resolveReturnType(project);
+ }
+ }
}
else if (calledFunction instanceof ITypeDefinition)
{