Skip to content

Commit

Permalink
GROOVY-10280, GROOVY-10283
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 10, 2021
1 parent 2b8eff5 commit 12e7ac3
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.junit.Assume.assumeTrue;

import org.eclipse.jdt.groovy.core.tests.basic.GroovyCompilerTestSuite;
import org.junit.Ignore;
import org.junit.Test;

/**
Expand Down Expand Up @@ -3567,138 +3566,6 @@ public void testCompileStatic9063() {
runConformTest(sources, "5");
}

@Test @Ignore("https://issues.apache.org/jira/browse/GROOVY-9074")
public void testCompileStatic9074() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class Main {\n" +
" private static Collection<?> c = new ArrayList<String>()\n" +
" static main(args) {\n" +
" c.add(new Object())\n" +
" }\n" +
"}\n",
};
//@formatter:on

runNegativeTest(sources, "The method add(capture#1-of ?) in the type Collection<capture#1-of ?> is not applicable for the arguments (Object)");
}

@Test @Ignore("https://issues.apache.org/jira/browse/GROOVY-9074")
public void testCompileStatic9074a() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import java.awt.Canvas\n" +
"abstract class Shape {\n" +
" abstract void draw(Canvas c)\n" +
"}\n" +
"class Circle extends Shape {\n" +
" private int x, y, radius\n" +
" @Override void draw(Canvas c) {}\n" +
"}\n" +
"class Rectangle extends Shape {\n" +
" private int x, y, width, height\n" +
" @Override void draw(Canvas c) {}\n" +
"}\n" +
"\n" +
"@groovy.transform.CompileStatic\n" +
"void addRectangle(List<? extends Shape> shapes) {\n" +
" shapes.add(0, new Rectangle()) // TODO: compile-time error!\n" +
"}\n",
};
//@formatter:on

runNegativeTest(sources, "The method add(capture#1-of ?) in the type List<capture#1-of ?> is not applicable for the arguments (Rectangle)");
}

@Test
public void testCompileStatic9074b() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import java.awt.Canvas\n" +
"abstract class Shape {\n" +
" abstract void draw(Canvas c)\n" +
"}\n" +
"class Circle extends Shape {\n" +
" private int x, y, radius\n" +
" @Override void draw(Canvas c) {}\n" +
"}\n" +
"class Rectangle extends Shape {\n" +
" private int x, y, width, height\n" +
" @Override void draw(Canvas c) {}\n" +
"}\n" +
"\n" +
"@groovy.transform.CompileStatic\n" +
"void addRectangle(List<? super Shape> shapes) {\n" +
" shapes.add(0, new Rectangle())\n" +
"}\n",
};
//@formatter:on

runNegativeTest(sources, "");
}

@Test
public void testCompileStatic9074c() {
//@formatter:off
String[] sources = {
"Main.groovy",
"class Factory {\n" +
" public <T> T make(Class<T> type, ... args) {}\n" +
"}\n" +
"\n" +
"@groovy.transform.CompileStatic\n" +
"void test(Factory fact, Rule rule) {\n" +
" Type bean = fact.make(rule.type)\n" +
"}\n",

"Rule.java",
"public class Rule {\n" +
" public Class<? extends Type> getType() {\n" +
" return null;\n" +
" }\n" +
"}\n",

"Type.java",
"public interface Type {}\n",
};
//@formatter:on

runNegativeTest(sources, "");
}

@Test @Ignore("https://issues.apache.org/jira/browse/GROOVY-9074")
public void testCompileStatic9074d() {
//@formatter:off
String[] sources = {
"Main.groovy",
"class Factory {\n" +
" public <T> T make(Class<T> type, ... args) {}\n" +
"}\n" +
"\n" +
"@groovy.transform.CompileStatic\n" +
"void test(Factory fact, Rule rule) {\n" +
" Type bean = fact.make(rule.type)\n" +
"}\n",

"Rule.java",
"public class Rule {\n" +
" public Class<? super Type> getType() {\n" +
" return null;\n" +
" }\n" +
"}\n",

"Type.java",
"public interface Type {}\n",
};
//@formatter:on

runNegativeTest(sources, "cannot convert from capture#1-of ? super Type to Type");
}

@Test
public void testCompileStatic9086() {
//@formatter:off
Expand Down Expand Up @@ -5627,7 +5494,7 @@ public void testCompileStatic9737a() {
runConformTest(sources, "str");
}

@Test @Ignore
@Test(expected = AssertionError.class)
public void testCompileStatic9737b() {
//@formatter:off
String[] sources = {
Expand Down
Loading

0 comments on commit 12e7ac3

Please sign in to comment.