Skip to content

Commit 359b06c

Browse files
committed
GROOVY-5364
1 parent a1041c7 commit 359b06c

File tree

8 files changed

+1855
-15
lines changed

8 files changed

+1855
-15
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/StaticInferencingTests.java

+36-10
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ public void testStaticReference13() {
369369

370370
@Test
371371
public void testStaticReference14() {
372-
String contents = "class C {\n" +
372+
String contents =
373+
"class C {\n" +
373374
" static Number x() {\n" +
374375
" 42\n" +
375376
" }\n" +
@@ -380,7 +381,8 @@ public void testStaticReference14() {
380381

381382
@Test
382383
public void testStaticReference15() {
383-
String contents = "class C {\n" +
384+
String contents =
385+
"class C {\n" +
384386
" static Number x() {\n" +
385387
" 42\n" +
386388
" }\n" +
@@ -419,12 +421,12 @@ public void testStaticReference17() {
419421
public void testStaticReference18() {
420422
String contents =
421423
"class Parent {\n" +
422-
" static p() {}\n" +
424+
" static p() {}\n" +
423425
"}\n" +
424426
"class Child extends Parent {\n" +
425-
" def c() {\n" +
426-
" p()\n" +
427-
" }\n" +
427+
" def c() {\n" +
428+
" p()\n" +
429+
" }\n" +
428430
"}\n";
429431
assertDeclaringType(contents, "p()", "Parent");
430432
}
@@ -433,13 +435,13 @@ public void testStaticReference18() {
433435
public void testStaticReference19() {
434436
createUnit("Parent",
435437
"class Parent {\n" +
436-
" static p() {}\n" +
438+
" static p() {}\n" +
437439
"}\n");
438440
String contents =
439441
"class Child extends Parent {\n" +
440-
" def c() {\n" +
441-
" p()\n" +
442-
" }\n" +
442+
" def c() {\n" +
443+
" p()\n" +
444+
" }\n" +
443445
"}\n";
444446
assertDeclaringType(contents, "p()", "Parent");
445447
}
@@ -560,6 +562,30 @@ public void testStaticReference27() {
560562
assertKnown(contents, "name", "C", "java.lang.Object");
561563
}
562564

565+
@Test
566+
public void testStaticReference28() {
567+
String contents =
568+
"static getStaticProperty() {}\n" +
569+
"static staticMethod() {\n" +
570+
" getStaticProperty()\n" +
571+
" staticProperty\n" +
572+
"}\n";
573+
assertKnown(contents, "getStaticProperty", "Search", "java.lang.Object");
574+
assertKnown(contents, "staticProperty", "Search", "java.lang.Object");
575+
}
576+
577+
@Test
578+
public void testStaticReference29() {
579+
String contents =
580+
"static getStaticProperty() {}\n" +
581+
"def scriptMethod() {\n" +
582+
" getStaticProperty()\n" +
583+
" staticProperty\n" +
584+
"}\n";
585+
assertKnown(contents, "getStaticProperty", "Search", "java.lang.Object");
586+
assertKnown(contents, "staticProperty", "Search", "java.lang.Object");
587+
}
588+
563589
//
564590

565591
@Test // GRECLIPSE-855: should be able to find the type, but with unknown confidence

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java

+17
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,23 @@ public void testStaticProperty10() {
944944
runConformTest(sources, "3");
945945
}
946946

947+
@Test // GROOVY-5364
948+
public void testStaticProperty11() {
949+
//@formatter:off
950+
String[] sources = {
951+
"Main.groovy",
952+
"static getStaticProperty() { '!' }\n" +
953+
"static staticMethod() {\n" +
954+
" print getStaticProperty()\n" +
955+
" print staticProperty\n" +
956+
"}\n" +
957+
"staticMethod()\n",
958+
};
959+
//@formatter:on
960+
961+
runConformTest(sources, "!!");
962+
}
963+
947964
@Test
948965
public void testClash_GRE1076() {
949966
//@formatter:off

base/org.codehaus.groovy25/.checkstyle

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<file-match-pattern match-pattern="groovy/classgen/ExtendedVerifier.java" include-pattern="false" />
4343
<file-match-pattern match-pattern="groovy/classgen/InnerClass(CompletionVisitor|Visitor(Helper)?).java" include-pattern="false" />
4444
<file-match-pattern match-pattern="groovy/classgen/ReturnAdder.java" include-pattern="false" />
45+
<file-match-pattern match-pattern="groovy/classgen/VariableScopeVisitor.java" include-pattern="false" />
4546
<file-match-pattern match-pattern="groovy/classgen/Verifier.java" include-pattern="false" />
4647
<file-match-pattern match-pattern="groovy/classgen/asm/BinaryExpressionHelper.java" include-pattern="false" />
4748
<file-match-pattern match-pattern="groovy/classgen/asm/BytecodeHelper.java" include-pattern="false" />

0 commit comments

Comments
 (0)