diff options
author | vrubezhny | 2014-01-22 17:01:31 +0000 |
---|---|---|
committer | vrubezhny | 2014-01-22 17:01:31 +0000 |
commit | c5d400a5bfa28a2db8621fd144dadec48a8eb310 (patch) | |
tree | cc17ca660e047a34c9ef5f1ce48d4b2e148d4390 | |
parent | 29cf115223bfd2f34b352a89aff97d373007ece9 (diff) | |
download | webtools.jsdt.tests-R3_5_maintenance.tar.gz webtools.jsdt.tests-R3_5_maintenance.tar.xz webtools.jsdt.tests-R3_5_maintenance.zip |
[411589] Invalid this detectionv201401221702R3_5_2R3_5_maintenance
The infer engine is made to calculate the correct types for local declarations initialized by this reference value
JUnit Test Case is added due to verify the issue.
Signed-off-by: vrubezhny <vrubezhny@exadel.com>
-rw-r--r-- | tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java index c0e85fb..ffd3772 100644 --- a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java +++ b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java @@ -2606,4 +2606,30 @@ public class InferTypesTests extends AbstractRegressionTest { ); assertNull("There should not be a global function def()", declaration.findInferredType("@G".toCharArray()).findMethod("def".toCharArray(), null)); } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=411589 - Invalid this detection + */ + public void testInitializationWithThisReference() { + CompilationUnitDeclaration declaration = this.runInferTest( + "(function() {\n" + + " var clazz = function() {\n" + + " var me = this;\n" + + " var you = me;\n" + + " me.funcMe = function() {return this;};\n" + + " you.funcYou = function() {return this;};\n" + + " this.funcWe = function() {return this;};\n" + + " }\n" + + "})();", + "X.js", + null, + getDefaultOptions() + ); + assertNull("There should not be a global function funcMe()", declaration.findInferredType("@G".toCharArray()).findMethod("funcMe".toCharArray(), null)); + assertNull("There should not be a global function funcYou()", declaration.findInferredType("@G".toCharArray()).findMethod("funcYou".toCharArray(), null)); + + assertNotNull("There should be a local method funcMe() in class clazz", declaration.findInferredType("clazz".toCharArray()).findMethod("funcMe".toCharArray(), null)); + assertNotNull("There should be a local method funcYou() in class clazz", declaration.findInferredType("clazz".toCharArray()).findMethod("funcYou".toCharArray(), null)); + assertNotNull("There should be a local method funcWe() in class clazz", declaration.findInferredType("clazz".toCharArray()).findMethod("funcWe".toCharArray(), null)); + } } |