Skip to content

Commit

Permalink
identification of relocated method bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Nov 7, 2020
1 parent 19879dc commit a3fc12b
Show file tree
Hide file tree
Showing 6 changed files with 879 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,64 @@ public void testDelegatesToGenericTypeIndex3() {
//@formatter:on
assertType(contents, "delegate", "java.lang.Object");
}

@Test
public void testMemoized1() {
//@formatter:off
String contents =
"class C {\n" +
" private static final int n = 42\n" +
" @groovy.transform.Memoized\n" +
" int f() {\n" +
" n * 2\n" +
" }\n" +
"}\n";
//@formatter:on
assertType(contents, "n", "java.lang.Integer");
}

@Test
public void testMemoized2() {
//@formatter:off
String contents =
"class C {\n" +
" private static final int n = 42\n" +
" @groovy.transform.Memoized\n" +
" int f(int p) {\n" +
" n * p\n" +
" }\n" +
"}\n";
//@formatter:on
assertType(contents, "n", "java.lang.Integer");
assertType(contents, "p", "java.lang.Integer");
}

@Test
public void testMemoized3() {
//@formatter:off
String contents =
"class C {\n" +
" @groovy.transform.Memoized\n" +
" static int f(int p) {\n" +
" 42 * p\n" +
" }\n" +
"}\n";
//@formatter:on
assertType(contents, "p", "java.lang.Integer");
}

@Test
public void testMemoized4() {
//@formatter:off
String contents =
"class C {\n" +
" private static final int n = 42\n" +
" @groovy.transform.Memoized\n" +
" void f() {\n" + // no effect
" print n * 2\n" +
" }\n" +
"}\n";
//@formatter:on
assertType(contents, "n", "java.lang.Integer");
}
}
1 change: 1 addition & 0 deletions base/org.codehaus.groovy25/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<file-match-pattern match-pattern="groovy/transform/ASTTestTransformation.groovy" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/ASTTransformationCollectorCodeVisitor.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/ASTTransformationVisitor.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/DelegateASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/FieldASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/LazyASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/LogASTTransformation.java" include-pattern="false" />
Expand Down
Loading

0 comments on commit a3fc12b

Please sign in to comment.