diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovyCompilerTestSuite.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovyCompilerTestSuite.java index 8ab571fd27..3417f2990d 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovyCompilerTestSuite.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovyCompilerTestSuite.java @@ -133,7 +133,7 @@ protected String[] getDefaultClassPaths() { String[] cps = super.getDefaultClassPaths(); String[] newcps = Arrays.copyOf(cps, cps.length + 2); - String[] groovyVersions = {"4.0.3", "3.0.11-indy", "2.5.17-indy"}; + String[] groovyVersions = {"4.0.3", "3.0.11-indy", "2.5.18-indy"}; String[] ivyVersions = {"2.5.0", "2.4.0"}; try { URL groovyJar = null; diff --git a/base/org.codehaus.groovy25/.classpath b/base/org.codehaus.groovy25/.classpath index a2eb74a571..e881ae7b53 100644 --- a/base/org.codehaus.groovy25/.classpath +++ b/base/org.codehaus.groovy25/.classpath @@ -9,14 +9,14 @@ - + - + - + - + diff --git a/base/org.codehaus.groovy25/META-INF/MANIFEST.MF b/base/org.codehaus.groovy25/META-INF/MANIFEST.MF index ed3588e274..fe0ebcc0fe 100644 --- a/base/org.codehaus.groovy25/META-INF/MANIFEST.MF +++ b/base/org.codehaus.groovy25/META-INF/MANIFEST.MF @@ -4,94 +4,94 @@ Bundle-SymbolicName: org.codehaus.groovy Automatic-Module-Name: org.codehaus.groovy Bundle-Name: Apache Groovy Bundle-Vendor: Pivotal Software, Inc. -Bundle-Version: 2.5.17.qualifier +Bundle-Version: 2.5.18.qualifier Bundle-ClassPath: eclipse-trace.jar, groovy-eclipse.jar, lib/ivy-2.5.0.jar, - lib/groovy-2.5.17-indy.jar, - lib/groovy-test-2.5.17-indy.jar -Export-Package: groovy.beans;version="2.5.17", - groovy.cli;version="2.5.17", - groovy.grape;version="2.5.17", - groovy.inspect;version="2.5.17", - groovy.io;version="2.5.17", - groovy.lang;version="2.5.17", - groovy.mock.interceptor;version="2.5.17", - groovy.security;version="2.5.17", - groovy.test;version="2.5.17", - groovy.time;version="2.5.17", - groovy.transform;version="2.5.17", - groovy.transform.builder;version="2.5.17", - groovy.transform.options;version="2.5.17", - groovy.transform.stc;version="2.5.17", - groovy.ui;version="2.5.17", - groovy.util;version="2.5.17", - groovy.util.logging;version="2.5.17", - groovy.xml;version="2.5.17", + lib/groovy-2.5.18-indy.jar, + lib/groovy-test-2.5.18-indy.jar +Export-Package: groovy.beans;version="2.5.18", + groovy.cli;version="2.5.18", + groovy.grape;version="2.5.18", + groovy.inspect;version="2.5.18", + groovy.io;version="2.5.18", + groovy.lang;version="2.5.18", + groovy.mock.interceptor;version="2.5.18", + groovy.security;version="2.5.18", + groovy.test;version="2.5.18", + groovy.time;version="2.5.18", + groovy.transform;version="2.5.18", + groovy.transform.builder;version="2.5.18", + groovy.transform.options;version="2.5.18", + groovy.transform.stc;version="2.5.18", + groovy.ui;version="2.5.18", + groovy.util;version="2.5.18", + groovy.util.logging;version="2.5.18", + groovy.xml;version="2.5.18", groovyjarjarantlr;x-friends:="org.codehaus.groovy.eclipse.refactoring", - org.apache.groovy.ast.tools;version="2.5.17", - org.apache.groovy.io;version="2.5.17", - org.apache.groovy.lang.annotation;version="2.5.17", - org.apache.groovy.metaclass;version="2.5.17", - org.apache.groovy.plugin;version="2.5.17", - org.apache.groovy.util;version="2.5.17", - org.apache.groovy.util.concurrentlinkedhashmap;version="2.5.17", - org.codehaus.groovy;version="2.5.17", - org.codehaus.groovy.antlr;version="2.5.17", - org.codehaus.groovy.antlr.parser;version="2.5.17", - org.codehaus.groovy.ast;version="2.5.17", - org.codehaus.groovy.ast.builder;version="2.5.17", - org.codehaus.groovy.ast.decompiled;version="2.5.17", - org.codehaus.groovy.ast.expr;version="2.5.17", - org.codehaus.groovy.ast.stmt;version="2.5.17", - org.codehaus.groovy.ast.tools;version="2.5.17", - org.codehaus.groovy.classgen;version="2.5.17", - org.codehaus.groovy.classgen.asm;version="2.5.17", - org.codehaus.groovy.classgen.asm.indy;version="2.5.17", - org.codehaus.groovy.classgen.asm.indy.sc;version="2.5.17", - org.codehaus.groovy.classgen.asm.sc;version="2.5.17", - org.codehaus.groovy.classgen.asm.util;version="2.5.17", - org.codehaus.groovy.control;version="2.5.17", - org.codehaus.groovy.control.customizers;version="2.5.17", - org.codehaus.groovy.control.customizers.builder;version="2.5.17", - org.codehaus.groovy.control.io;version="2.5.17", - org.codehaus.groovy.control.messages;version="2.5.17", + org.apache.groovy.ast.tools;version="2.5.18", + org.apache.groovy.io;version="2.5.18", + org.apache.groovy.lang.annotation;version="2.5.18", + org.apache.groovy.metaclass;version="2.5.18", + org.apache.groovy.plugin;version="2.5.18", + org.apache.groovy.util;version="2.5.18", + org.apache.groovy.util.concurrentlinkedhashmap;version="2.5.18", + org.codehaus.groovy;version="2.5.18", + org.codehaus.groovy.antlr;version="2.5.18", + org.codehaus.groovy.antlr.parser;version="2.5.18", + org.codehaus.groovy.ast;version="2.5.18", + org.codehaus.groovy.ast.builder;version="2.5.18", + org.codehaus.groovy.ast.decompiled;version="2.5.18", + org.codehaus.groovy.ast.expr;version="2.5.18", + org.codehaus.groovy.ast.stmt;version="2.5.18", + org.codehaus.groovy.ast.tools;version="2.5.18", + org.codehaus.groovy.classgen;version="2.5.18", + org.codehaus.groovy.classgen.asm;version="2.5.18", + org.codehaus.groovy.classgen.asm.indy;version="2.5.18", + org.codehaus.groovy.classgen.asm.indy.sc;version="2.5.18", + org.codehaus.groovy.classgen.asm.sc;version="2.5.18", + org.codehaus.groovy.classgen.asm.util;version="2.5.18", + org.codehaus.groovy.control;version="2.5.18", + org.codehaus.groovy.control.customizers;version="2.5.18", + org.codehaus.groovy.control.customizers.builder;version="2.5.18", + org.codehaus.groovy.control.io;version="2.5.18", + org.codehaus.groovy.control.messages;version="2.5.18", org.codehaus.groovy.eclipse, - org.codehaus.groovy.plugin;version="2.5.17", - org.codehaus.groovy.reflection;version="2.5.17", - org.codehaus.groovy.reflection.android;version="2.5.17", - org.codehaus.groovy.reflection.stdclasses;version="2.5.17", - org.codehaus.groovy.reflection.v7;version="2.5.17", - org.codehaus.groovy.runtime;version="2.5.17", - org.codehaus.groovy.runtime.callsite;version="2.5.17", - org.codehaus.groovy.runtime.dgmimpl;version="2.5.17", - org.codehaus.groovy.runtime.dgmimpl.arrays;version="2.5.17", - org.codehaus.groovy.runtime.m12n;version="2.5.17", - org.codehaus.groovy.runtime.memoize;version="2.5.17", - org.codehaus.groovy.runtime.metaclass;version="2.5.17", - org.codehaus.groovy.runtime.powerassert;version="2.5.17", - org.codehaus.groovy.runtime.typehandling;version="2.5.17", - org.codehaus.groovy.runtime.wrappers;version="2.5.17", - org.codehaus.groovy.syntax;version="2.5.17", - org.codehaus.groovy.tools;version="2.5.17", - org.codehaus.groovy.tools.ast;version="2.5.17", - org.codehaus.groovy.tools.gse;version="2.5.17", - org.codehaus.groovy.tools.javac;version="2.5.17", - org.codehaus.groovy.tools.shell;version="2.5.17", - org.codehaus.groovy.tools.shell.util;version="2.5.17", - org.codehaus.groovy.transform;version="2.5.17", - org.codehaus.groovy.transform.sc;version="2.5.17", - org.codehaus.groovy.transform.sc.transformers;version="2.5.17", - org.codehaus.groovy.transform.stc;version="2.5.17", - org.codehaus.groovy.transform.tailrec;version="2.5.17", - org.codehaus.groovy.transform.trait;version="2.5.17", - org.codehaus.groovy.util;version="2.5.17", - org.codehaus.groovy.vmplugin;version="2.5.17", - org.codehaus.groovy.vmplugin.v5;version="2.5.17", - org.codehaus.groovy.vmplugin.v6;version="2.5.17", - org.codehaus.groovy.vmplugin.v7;version="2.5.17", - org.codehaus.groovy.vmplugin.v8;version="2.5.17", - org.codehaus.groovy.vmplugin.v9;version="2.5.17" + org.codehaus.groovy.plugin;version="2.5.18", + org.codehaus.groovy.reflection;version="2.5.18", + org.codehaus.groovy.reflection.android;version="2.5.18", + org.codehaus.groovy.reflection.stdclasses;version="2.5.18", + org.codehaus.groovy.reflection.v7;version="2.5.18", + org.codehaus.groovy.runtime;version="2.5.18", + org.codehaus.groovy.runtime.callsite;version="2.5.18", + org.codehaus.groovy.runtime.dgmimpl;version="2.5.18", + org.codehaus.groovy.runtime.dgmimpl.arrays;version="2.5.18", + org.codehaus.groovy.runtime.m12n;version="2.5.18", + org.codehaus.groovy.runtime.memoize;version="2.5.18", + org.codehaus.groovy.runtime.metaclass;version="2.5.18", + org.codehaus.groovy.runtime.powerassert;version="2.5.18", + org.codehaus.groovy.runtime.typehandling;version="2.5.18", + org.codehaus.groovy.runtime.wrappers;version="2.5.18", + org.codehaus.groovy.syntax;version="2.5.18", + org.codehaus.groovy.tools;version="2.5.18", + org.codehaus.groovy.tools.ast;version="2.5.18", + org.codehaus.groovy.tools.gse;version="2.5.18", + org.codehaus.groovy.tools.javac;version="2.5.18", + org.codehaus.groovy.tools.shell;version="2.5.18", + org.codehaus.groovy.tools.shell.util;version="2.5.18", + org.codehaus.groovy.transform;version="2.5.18", + org.codehaus.groovy.transform.sc;version="2.5.18", + org.codehaus.groovy.transform.sc.transformers;version="2.5.18", + org.codehaus.groovy.transform.stc;version="2.5.18", + org.codehaus.groovy.transform.tailrec;version="2.5.18", + org.codehaus.groovy.transform.trait;version="2.5.18", + org.codehaus.groovy.util;version="2.5.18", + org.codehaus.groovy.vmplugin;version="2.5.18", + org.codehaus.groovy.vmplugin.v5;version="2.5.18", + org.codehaus.groovy.vmplugin.v6;version="2.5.18", + org.codehaus.groovy.vmplugin.v7;version="2.5.18", + org.codehaus.groovy.vmplugin.v8;version="2.5.18", + org.codehaus.groovy.vmplugin.v9;version="2.5.18" Require-Bundle: org.eclipse.core.runtime, org.junit;resolution:=optional Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/base/org.codehaus.groovy25/VERSION b/base/org.codehaus.groovy25/VERSION index a089ba8554..9fa4518a7f 100644 --- a/base/org.codehaus.groovy25/VERSION +++ b/base/org.codehaus.groovy25/VERSION @@ -23,3 +23,4 @@ 2021-09-06: GROOVY_2_5_15 2022-03-02: GROOVY_2_5_16 2022-05-31: GROOVY_2_5_17 +2022-07-20: GROOVY_2_5_18 diff --git a/base/org.codehaus.groovy25/about.html b/base/org.codehaus.groovy25/about.html index 3790fb29e5..ac736183cf 100644 --- a/base/org.codehaus.groovy25/about.html +++ b/base/org.codehaus.groovy25/about.html @@ -24,12 +24,12 @@

License

Third Party Content

-

groovy-2.5.17-indy.jar

-

groovy-test-2.5.17-indy.jar

+

groovy-2.5.18-indy.jar

+

groovy-test-2.5.18-indy.jar

-

groovy-cli-picocli-2.5.17.jar

-

groovy-console-2.5.17.jar

-

groovy-groovysh-2.5.17.jar

-

groovy-swing-2.5.17.jar

-

groovy-templates-2.5.17.jar

-

groovy-xml-2.5.17.jar

+

groovy-cli-picocli-2.5.18.jar

+

groovy-console-2.5.18.jar

+

groovy-groovysh-2.5.18.jar

+

groovy-swing-2.5.18.jar

+

groovy-templates-2.5.18.jar

+

groovy-xml-2.5.18.jar

picocli-4.3.2.jar

    -
  • Obtained from: https://dist.apache.org/repos/dist/release/groovy/2.5.17/distribution/apache-groovy-binary-2.5.17.zip
  • +
  • Obtained from: https://dist.apache.org/repos/dist/release/groovy/2.5.18/distribution/apache-groovy-binary-2.5.18.zip
  • License kind: ASL
  • License URL: https://www.apache.org/licenses/LICENSE-2.0.html
  • License text: asl2-license.txt
  • @@ -63,7 +63,7 @@

    picocli-4.3.2.jar

    jline-2.14.6.jar

      -
    • Obtained from: https://dist.apache.org/repos/dist/release/groovy/2.5.17/distribution/apache-groovy-binary-2.5.17.zip
    • +
    • Obtained from: https://dist.apache.org/repos/dist/release/groovy/2.5.18/distribution/apache-groovy-binary-2.5.18.zip
    • License kind: BSD
    • License URL: https://www.opensource.org/licenses/bsd-license.php
    • License text: jline2-license.txt
    • diff --git a/base/org.codehaus.groovy25/build.antlr2x b/base/org.codehaus.groovy25/build.antlr2x index 2ee0f3311c..b5021256f0 100644 --- a/base/org.codehaus.groovy25/build.antlr2x +++ b/base/org.codehaus.groovy25/build.antlr2x @@ -1,7 +1,7 @@ - + diff --git a/base/org.codehaus.groovy25/lib/console/groovy-cli-picocli-2.5.17.jar b/base/org.codehaus.groovy25/lib/console/groovy-cli-picocli-2.5.18.jar similarity index 93% rename from base/org.codehaus.groovy25/lib/console/groovy-cli-picocli-2.5.17.jar rename to base/org.codehaus.groovy25/lib/console/groovy-cli-picocli-2.5.18.jar index e3e25dd14e..ca720621b1 100644 Binary files a/base/org.codehaus.groovy25/lib/console/groovy-cli-picocli-2.5.17.jar and b/base/org.codehaus.groovy25/lib/console/groovy-cli-picocli-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/lib/console/groovy-console-2.5.17.jar b/base/org.codehaus.groovy25/lib/console/groovy-console-2.5.18.jar similarity index 93% rename from base/org.codehaus.groovy25/lib/console/groovy-console-2.5.17.jar rename to base/org.codehaus.groovy25/lib/console/groovy-console-2.5.18.jar index 4f8c3ae232..f676935b9a 100644 Binary files a/base/org.codehaus.groovy25/lib/console/groovy-console-2.5.17.jar and b/base/org.codehaus.groovy25/lib/console/groovy-console-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/lib/console/groovy-swing-2.5.17.jar b/base/org.codehaus.groovy25/lib/console/groovy-swing-2.5.18.jar similarity index 91% rename from base/org.codehaus.groovy25/lib/console/groovy-swing-2.5.17.jar rename to base/org.codehaus.groovy25/lib/console/groovy-swing-2.5.18.jar index 4e4f32807b..9e2be904a6 100644 Binary files a/base/org.codehaus.groovy25/lib/console/groovy-swing-2.5.17.jar and b/base/org.codehaus.groovy25/lib/console/groovy-swing-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/lib/console/groovy-templates-2.5.17.jar b/base/org.codehaus.groovy25/lib/console/groovy-templates-2.5.18.jar similarity index 91% rename from base/org.codehaus.groovy25/lib/console/groovy-templates-2.5.17.jar rename to base/org.codehaus.groovy25/lib/console/groovy-templates-2.5.18.jar index 6d47a48270..a915964bf8 100644 Binary files a/base/org.codehaus.groovy25/lib/console/groovy-templates-2.5.17.jar and b/base/org.codehaus.groovy25/lib/console/groovy-templates-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/lib/console/groovy-xml-2.5.17.jar b/base/org.codehaus.groovy25/lib/console/groovy-xml-2.5.18.jar similarity index 91% rename from base/org.codehaus.groovy25/lib/console/groovy-xml-2.5.17.jar rename to base/org.codehaus.groovy25/lib/console/groovy-xml-2.5.18.jar index 7b792997ec..6f6501d1e8 100644 Binary files a/base/org.codehaus.groovy25/lib/console/groovy-xml-2.5.17.jar and b/base/org.codehaus.groovy25/lib/console/groovy-xml-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/lib/groovy-2.5.17-indy.jar b/base/org.codehaus.groovy25/lib/groovy-2.5.18-indy.jar similarity index 89% rename from base/org.codehaus.groovy25/lib/groovy-2.5.17-indy.jar rename to base/org.codehaus.groovy25/lib/groovy-2.5.18-indy.jar index 7121fc3b0b..20f904ccc9 100644 Binary files a/base/org.codehaus.groovy25/lib/groovy-2.5.17-indy.jar and b/base/org.codehaus.groovy25/lib/groovy-2.5.18-indy.jar differ diff --git a/base/org.codehaus.groovy25/lib/groovy-2.5.17-javadoc.jar b/base/org.codehaus.groovy25/lib/groovy-2.5.18-javadoc.jar similarity index 50% rename from base/org.codehaus.groovy25/lib/groovy-2.5.17-javadoc.jar rename to base/org.codehaus.groovy25/lib/groovy-2.5.18-javadoc.jar index 9373b17fed..060195c4ce 100644 Binary files a/base/org.codehaus.groovy25/lib/groovy-2.5.17-javadoc.jar and b/base/org.codehaus.groovy25/lib/groovy-2.5.18-javadoc.jar differ diff --git a/base/org.codehaus.groovy25/lib/groovy-2.5.17-sources.jar b/base/org.codehaus.groovy25/lib/groovy-2.5.18-sources.jar similarity index 88% rename from base/org.codehaus.groovy25/lib/groovy-2.5.17-sources.jar rename to base/org.codehaus.groovy25/lib/groovy-2.5.18-sources.jar index c700043616..987ff07c3b 100644 Binary files a/base/org.codehaus.groovy25/lib/groovy-2.5.17-sources.jar and b/base/org.codehaus.groovy25/lib/groovy-2.5.18-sources.jar differ diff --git a/base/org.codehaus.groovy25/lib/groovy-test-2.5.17-indy.jar b/base/org.codehaus.groovy25/lib/groovy-test-2.5.18-indy.jar similarity index 91% rename from base/org.codehaus.groovy25/lib/groovy-test-2.5.17-indy.jar rename to base/org.codehaus.groovy25/lib/groovy-test-2.5.18-indy.jar index db207b1c3a..bc04c5c04c 100644 Binary files a/base/org.codehaus.groovy25/lib/groovy-test-2.5.17-indy.jar and b/base/org.codehaus.groovy25/lib/groovy-test-2.5.18-indy.jar differ diff --git a/base/org.codehaus.groovy25/lib/groovy-test-2.5.17-javadoc.jar b/base/org.codehaus.groovy25/lib/groovy-test-2.5.18-javadoc.jar similarity index 81% rename from base/org.codehaus.groovy25/lib/groovy-test-2.5.17-javadoc.jar rename to base/org.codehaus.groovy25/lib/groovy-test-2.5.18-javadoc.jar index 2ac0827251..e05e55d5b8 100644 Binary files a/base/org.codehaus.groovy25/lib/groovy-test-2.5.17-javadoc.jar and b/base/org.codehaus.groovy25/lib/groovy-test-2.5.18-javadoc.jar differ diff --git a/base/org.codehaus.groovy25/lib/groovy-test-2.5.17-sources.jar b/base/org.codehaus.groovy25/lib/groovy-test-2.5.18-sources.jar similarity index 89% rename from base/org.codehaus.groovy25/lib/groovy-test-2.5.17-sources.jar rename to base/org.codehaus.groovy25/lib/groovy-test-2.5.18-sources.jar index fd445733ce..b6b6e46a6a 100644 Binary files a/base/org.codehaus.groovy25/lib/groovy-test-2.5.17-sources.jar and b/base/org.codehaus.groovy25/lib/groovy-test-2.5.18-sources.jar differ diff --git a/base/org.codehaus.groovy25/lib/shell/groovy-cli-picocli-2.5.17.jar b/base/org.codehaus.groovy25/lib/shell/groovy-cli-picocli-2.5.18.jar similarity index 93% rename from base/org.codehaus.groovy25/lib/shell/groovy-cli-picocli-2.5.17.jar rename to base/org.codehaus.groovy25/lib/shell/groovy-cli-picocli-2.5.18.jar index e3e25dd14e..ca720621b1 100644 Binary files a/base/org.codehaus.groovy25/lib/shell/groovy-cli-picocli-2.5.17.jar and b/base/org.codehaus.groovy25/lib/shell/groovy-cli-picocli-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/lib/shell/groovy-groovysh-2.5.17.jar b/base/org.codehaus.groovy25/lib/shell/groovy-groovysh-2.5.18.jar similarity index 89% rename from base/org.codehaus.groovy25/lib/shell/groovy-groovysh-2.5.17.jar rename to base/org.codehaus.groovy25/lib/shell/groovy-groovysh-2.5.18.jar index be97eed181..4e3d81222c 100644 Binary files a/base/org.codehaus.groovy25/lib/shell/groovy-groovysh-2.5.17.jar and b/base/org.codehaus.groovy25/lib/shell/groovy-groovysh-2.5.18.jar differ diff --git a/base/org.codehaus.groovy25/pom.xml b/base/org.codehaus.groovy25/pom.xml index 681cb38bc7..aa86801451 100644 --- a/base/org.codehaus.groovy25/pom.xml +++ b/base/org.codehaus.groovy25/pom.xml @@ -8,7 +8,7 @@ org.codehaus.groovy.eclipse org.codehaus.groovy - 2.5.17-SNAPSHOT + 2.5.18-SNAPSHOT eclipse-plugin diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java index 1ad9d529f5..a9a16d674c 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/antlr/AntlrParserPlugin.java @@ -552,7 +552,9 @@ protected void importDef(AST importNode) { // GRECLIPSE end addImport(type, name, alias, annotations); imp = last(output.getImports()); - // GRECLIPSE edit + /* GRECLIPSE edit + configureAST(imp, importNode); + */ configureAST(imp, importNode, node, null); // GRECLIPSE end return; @@ -574,14 +576,18 @@ protected void importDef(AST importNode) { // GRECLIPSE end addStaticStarImport(type, packageName, annotations); imp = output.getStaticStarImports().get(packageName); - // GRECLIPSE edit + /* GRECLIPSE edit + configureAST(imp, importNode); + */ configureAST(imp, importNode, packageNode, null); // GRECLIPSE end } else { // import is like "import foo.*" addStarImport(packageName, annotations); imp = last(output.getStarImports()); - // GRECLIPSE edit + /* GRECLIPSE edit + configureAST(imp, importNode); + */ configureAST(imp, importNode, packageNode, null); // GRECLIPSE end } @@ -602,7 +608,9 @@ protected void importDef(AST importNode) { // GRECLIPSE end addStaticImport(type, name, alias, annotations); imp = output.getStaticImports().get(alias == null ? name : alias); - // GRECLIPSE edit + /* GRECLIPSE edit + configureAST(imp, importNode); + */ imp.setFieldNameExpr(literalExpression(nameNode, name)); configureAST(imp, importNode, packageNode, nameNode); // GRECLIPSE end @@ -622,7 +630,9 @@ protected void importDef(AST importNode) { // GRECLIPSE end addImport(type, name, alias, annotations); imp = last(output.getImports()); - // GRECLIPSE edit + /* GRECLIPSE edit + configureAST(imp, importNode); + */ configureAST(imp, importNode, packageNode, nameNode); // GRECLIPSE end } diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ASTNode.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ASTNode.java index c49f7b6fb9..82476bc137 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ASTNode.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ASTNode.java @@ -175,15 +175,8 @@ public void copyNodeMetaData(ASTNode other) { * data under that key */ public void setNodeMetaData(Object key, Object value) { - /* GRECLIPSE edit - if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+"."); - if (metaDataMap == null) { - metaDataMap = new ListHashMap(); - } - Object old = metaDataMap.put(key,value); - */ Object old = putNodeMetaData(key,value); - if (old!=null) throw new GroovyBugError("Tried to overwrite existing meta data "+this+"."); + if (old != null) throw new GroovyBugError("Tried to replace existing meta data on " + this + "."); } /** diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ClassNode.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ClassNode.java index 07654aefe3..309a848f31 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ClassNode.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ClassNode.java @@ -752,22 +752,6 @@ public FieldNode addFieldFirst(String name, int modifiers, ClassNode type, Expre } public void addInterface(ClassNode type) { - /* GRECLIPSE edit - boolean skip = false; - ClassNode[] interfaces = redirect().interfaces; - for (ClassNode existing : interfaces) { - if (type.equals(existing)) { - skip = true; - break; - } - } - if (!skip) { - ClassNode[] newInterfaces = new ClassNode[interfaces.length + 1]; - System.arraycopy(interfaces, 0, newInterfaces, 0, interfaces.length); - newInterfaces[interfaces.length] = type; - redirect().interfaces = newInterfaces; - } - */ ClassNode[] interfaces = getInterfaces(); for (ClassNode face : interfaces) { if (face.equals(type)) return; @@ -777,7 +761,6 @@ public void addInterface(ClassNode type) { System.arraycopy(interfaces, 0, interfaces = new ClassNode[n + 1], 0, n); interfaces[n] = type; // append interface setInterfaces(interfaces); - // GRECLIPSE end } public boolean equals(Object that) { diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java index 1bf1a7040e..76188520ce 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/GenericsType.java @@ -192,12 +192,8 @@ public void setPlaceHolder(boolean placeholder) { //-------------------------------------------------------------------------- /** - * Compares this generics type with the provided class node. If the provided - * class node is compatible with the generics specification, returns true. - * Otherwise, returns false. The check is complete, meaning that nested - * generics are also checked. - * - * @return if {@code classNode} is or is not compatible with this generics specification + * Determines if the provided type is compatible with this specification. + * The check is complete, meaning that nested generics are also checked. */ public boolean isCompatibleWith(final ClassNode classNode) { GenericsType[] genericsTypes = classNode.getGenericsTypes(); @@ -215,21 +211,24 @@ public boolean isCompatibleWith(final ClassNode classNode) { return name0.equals(getName()); } if (getLowerBound() != null) { + // check for "? super T" vs "T" if (name0.equals(getLowerBound().getUnresolvedName())) { return true; } } else if (getUpperBounds() != null) { + // check for "? extends T" vs "T" if (name0.equals(getUpperBounds()[0].getUnresolvedName())) { return true; } } + // check for "? extends/super X" vs "T extends/super X" return checkGenerics(classNode); } if (isWildcard() || isPlaceholder()) { // if the generics spec is a wildcard or a placeholder then check the bounds ClassNode lowerBound = getLowerBound(); if (lowerBound != null) { - // for a lower bound, perform the upper bound checks with reversed arguments + // test bound and type in reverse for lower bound vs upper bound if (!implementsInterfaceOrIsSubclassOf(lowerBound, classNode)) { return false; } @@ -243,19 +242,16 @@ public boolean isCompatibleWith(final ClassNode classNode) { return false; } } - // if the provided classnode is a subclass of the upper bound - // then check that the generic types supplied by the class node are compatible with - // this generics specification - // for example, we could have the spec saying List but provided classnode - // saying List + // if the provided type is a subclass of the upper bound(s) then + // check that the generic types supplied are compatible with this + // for example, this spec could be "Type" but type is "Type" return checkGenerics(classNode); } - // if there are no bounds, the generic type is basically Object, and everything is compatible + // if there are no bounds, the generic type is basically Object and everything is compatible return true; } - // last, we could have the spec saying List and a classnode saying List so - // we must check that generics are compatible - return getType().equals(classNode) && compareGenericsWithBound(classNode, type); + // not placeholder or wildcard; no covariance allowed for type or bound(s) + return classNode.equals(getType()) && compareGenericsWithBound(classNode, getType()); } private static boolean implementsInterfaceOrIsSubclassOf(final ClassNode type, final ClassNode superOrInterface) { @@ -313,16 +309,15 @@ private boolean checkGenerics(final ClassNode classNode) { * @return true if generics are compatible */ private static boolean compareGenericsWithBound(final ClassNode classNode, final ClassNode bound) { - if (classNode == null) { - return false; - } - // GRECLIPSE add -- GROOVY-10556: "T" vs "C>" bound - if (classNode.isGenericsPlaceHolder()) return true; - // GRECLIPSE end - if (bound.getGenericsTypes() == null || (classNode.getGenericsTypes() == null && classNode.redirect().getGenericsTypes() != null)) { - // if the bound is not using generics or the class node is a raw type, there's nothing to compare with + if (classNode == null) return false; + if (bound.getGenericsTypes() == null + // GRECLIPSE add -- GROOVY-10556: "T" vs "C>" bound + || classNode.isGenericsPlaceHolder() + // GRECLIPSE end + || (classNode.getGenericsTypes() == null && classNode.redirect().getGenericsTypes() != null)) + // if the bound is not using generics or the class node is a raw type, there's nothing to compare return true; - } + if (!classNode.equals(bound)) { // the class nodes are on different types // in this situation, we must choose the correct execution path : either the bound @@ -338,8 +333,10 @@ private static boolean compareGenericsWithBound(final ClassNode classNode, final // class node are not parameterized. This means that we must create a // new class node with the parameterized types that the current class node // has defined. - ClassNode node = GenericsUtils.parameterizeType(classNode, face); - return compareGenericsWithBound(node, bound); + if (face.getGenericsTypes() != null) { + face = GenericsUtils.parameterizeType(classNode, face); + } + return compareGenericsWithBound(face, bound); } } } @@ -355,9 +352,6 @@ private static boolean compareGenericsWithBound(final ClassNode classNode, final if (success) return true; } } - /* GRECLIPSE edit -- GROOVY-6232, GROOVY-9956 - return compareGenericsWithBound(getParameterizedSuperClass(classNode), bound); - */ if (classNode.equals(ClassHelper.OBJECT_TYPE)) { return false; } @@ -368,14 +362,14 @@ private static boolean compareGenericsWithBound(final ClassNode classNode, final superClass = GenericsUtils.parameterizeType(classNode, superClass); } return compareGenericsWithBound(superClass, bound); - // GRECLIPSE end } + GenericsType[] cnTypes = classNode.getGenericsTypes(); if (cnTypes == null) { cnTypes = classNode.redirect().getGenericsTypes(); } if (cnTypes == null) { - // may happen if generic type is Foo and classnode is Foo -> Foo + // may happen if generic type is Foo and ClassNode is Foo -> Foo return true; } @@ -464,7 +458,7 @@ private static boolean compareGenericsWithBound(final ClassNode classNode, final match = gt.checkGenerics(classNodeType.getLowerBound()); } else if (classNodeType.getUpperBounds() != null) { match = gt.checkGenerics(classNodeType.getUpperBounds()[0]); - } else { // GROOVY-10576: "?" vs "? extends Object" (citation required) or no match + } else { // GROOVY-10267, GROOVY-10576: "?" vs "? extends Object" (citation required) or no match match = (!gt.isPlaceholder() && !gt.isWildcard() && ClassHelper.OBJECT_TYPE.equals(gt.getType())); } } else { @@ -487,48 +481,6 @@ private static boolean compareGenericsWithBound(final ClassNode classNode, final return match; } - /** - * If you have a class which extends a class using generics, returns the superclass with parameterized types. For - * example, if you have: - * class MyList<T> extends LinkedList<T> - * def list = new MyList<String> - * - * then the parameterized superclass for MyList<String> is LinkedList<String> - * @param classNode the class for which we want to return the parameterized superclass - * @return the parameterized superclass - */ - /* GRECLIPSE edit - private static ClassNode getParameterizedSuperClass(final ClassNode classNode) { - if (ClassHelper.OBJECT_TYPE.equals(classNode)) return null; - ClassNode superClass = classNode.getUnresolvedSuperClass(); - if (superClass == null) return ClassHelper.OBJECT_TYPE; - - if (!classNode.isUsingGenerics() || !superClass.isUsingGenerics()) { - return superClass; - } - - GenericsType[] genericsTypes = classNode.getGenericsTypes(); - GenericsType[] redirectGenericTypes = classNode.redirect().getGenericsTypes(); - superClass = superClass.getPlainNodeReference(); - if (genericsTypes == null || redirectGenericTypes == null || superClass.getGenericsTypes() == null) { - return superClass; - } - for (int i = 0, genericsTypesLength = genericsTypes.length; i < genericsTypesLength; i += 1) { - if (redirectGenericTypes[i].isPlaceholder()) { - GenericsType genericsType = genericsTypes[i]; - GenericsType[] superGenericTypes = superClass.getGenericsTypes(); - for (int j = 0, superGenericTypesLength = superGenericTypes.length; j < superGenericTypesLength; j += 1) { - GenericsType superGenericType = superGenericTypes[j]; - if (superGenericType.isPlaceholder() && superGenericType.getName().equals(redirectGenericTypes[i].getName())) { - superGenericTypes[j] = genericsType; - } - } - } - } - return superClass; - } - */ - //-------------------------------------------------------------------------- public static class GenericsTypeName { diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/MethodNode.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/MethodNode.java index 3c25614440..266c8eda37 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/MethodNode.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/MethodNode.java @@ -207,12 +207,8 @@ public void setIsScriptBody() { } public String toString() { - /* GRECLIPSE edit - return "MethodNode@" + hashCode() + "[" + getDeclaringClass().getName() + "#" + getTypeDescriptor() + "]"; - */ ClassNode declaringClass = getDeclaringClass(); return super.toString() + "[" + getTypeDescriptor() + (declaringClass == null ? "" : " from " + ClassNodeUtils.formatTypeName(declaringClass)) + "]"; - // GRECLIPSE end } public void setReturnType(ClassNode returnType) { diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GeneralUtils.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GeneralUtils.java index 69c91762c0..3fd60cdf10 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GeneralUtils.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GeneralUtils.java @@ -410,18 +410,22 @@ public static List getInstancePropertyFields(final ClassNode cNode) { return result; } - public static Set getInterfacesAndSuperInterfaces(final ClassNode type) { - Set res = new LinkedHashSet(); - if (type.isInterface()) { - res.add(type); - return res; - } - ClassNode next = type; - while (next != null) { - res.addAll(next.getAllInterfaces()); - next = next.getSuperClass(); - } - return res; + public static Set getInterfacesAndSuperInterfaces(final ClassNode cNode) { + Set result = new LinkedHashSet(); + if (cNode.isInterface()) result.add(cNode); + addAllInterfaces(result, cNode); + return result; + } + + private static void addAllInterfaces(final Set result, final ClassNode source) { + for (ClassNode in : source.getInterfaces()) { + in = GenericsUtils.parameterizeType(source, in); + if (result.add(in)) addAllInterfaces(result, in); + } + ClassNode sc = source.redirect().getUnresolvedSuperClass(false); + if (sc != null && ClassHelper.OBJECT_TYPE != sc) { + addAllInterfaces(result, GenericsUtils.parameterizeType(source, sc)); + } } public static List getSuperNonPropertyFields(final ClassNode cNode) { diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GenericsUtils.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GenericsUtils.java index b6a4fd4ba6..bf14aafde5 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GenericsUtils.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/GenericsUtils.java @@ -20,7 +20,6 @@ import groovyjarjarantlr.RecognitionException; import groovyjarjarantlr.TokenStreamException; -import groovy.lang.Tuple2; import groovy.transform.stc.IncorrectTypeHintException; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.antlr.AntlrParserPlugin; @@ -142,86 +141,96 @@ public static GenericsType buildWildcardType(final ClassNode... types) { return gt; } - public static Map extractPlaceholders(ClassNode cn) { - Map ret = new HashMap<>(); - extractPlaceholders(cn, ret); - return ret; + /** + * Returns the type parameter/argument relationships of the specified type. + * + * @param type the class node to check + */ + public static Map extractPlaceholders(final ClassNode type) { + Map placeholders = new HashMap<>(); + extractPlaceholders(type, placeholders); + return placeholders; } /** - * For a given classnode, fills in the supplied map with the parameterized - * types it defines. + * Populates the supplied map with the type parameter/argument relationships + * of the specified type. * - * @param node the class node to check - * @param map the generics type information collector + * @param type the class node to check + * @param placeholders the generics type information collector */ - public static void extractPlaceholders(ClassNode node, Map map) { - if (node == null) return; + public static void extractPlaceholders(final ClassNode type, final Map placeholders) { + if (type == null) return; - if (node.isArray()) { - extractPlaceholders(node.getComponentType(), map); + if (type.isArray()) { + extractPlaceholders(type.getComponentType(), placeholders); return; } - if (!node.isUsingGenerics() || !node.isRedirectNode()) return; - GenericsType[] parameterized = node.getGenericsTypes(); - if (parameterized == null || parameterized.length == 0) return; - // GRECLIPSE add -- GROOVY-10067 - if (node.isGenericsPlaceHolder()) { + if (!type.isUsingGenerics() || !type.isRedirectNode()) return; + GenericsType[] parameterized = type.getGenericsTypes(); int n; + if (parameterized == null || (n = parameterized.length) == 0) return; + + // GROOVY-8609 + if (type.isGenericsPlaceHolder()) { GenericsType gt = parameterized[0]; - map.put(new GenericsType.GenericsTypeName(gt.getName()), gt); + GenericsType.GenericsTypeName name = new GenericsType.GenericsTypeName(gt.getName()); + /* GRECLIPSE edit -- GROOVY-10067 + if (!placeholders.containsKey(name)) placeholders.put(name, gt); + */ + placeholders.put(name, gt); ClassNode lowerBound = gt.getLowerBound(); if (lowerBound != null) { - extractPlaceholders(lowerBound, map); + extractPlaceholders(lowerBound, placeholders); } ClassNode[] upperBounds = gt.getUpperBounds(); if (upperBounds != null) { for (ClassNode upperBound : upperBounds) { - extractPlaceholders(upperBound, map); + extractPlaceholders(upperBound, placeholders); } } + // GRECLIPSE end return; } - // GRECLIPSE end - GenericsType[] redirectGenericsTypes = node.redirect().getGenericsTypes(); - if (redirectGenericsTypes == null || - (node.isGenericsPlaceHolder() && redirectGenericsTypes.length != parameterized.length) /* GROOVY-8609 */) { + + GenericsType[] redirectGenericsTypes = type.redirect().getGenericsTypes(); + if (redirectGenericsTypes == null) { redirectGenericsTypes = parameterized; - } - if (redirectGenericsTypes.length != parameterized.length) { + } else if (redirectGenericsTypes.length != n) { throw new GroovyBugError("Expected earlier checking to detect generics parameter arity mismatch" + - "\nExpected: " + node.getName() + toGenericTypesString(redirectGenericsTypes) + - "\nSupplied: " + node.getName() + toGenericTypesString(parameterized)); + "\nExpected: " + type.getName() + toGenericTypesString(redirectGenericsTypes) + + "\nSupplied: " + type.getName() + toGenericTypesString(parameterized)); } - List valueList = new LinkedList<>(); - for (int i = 0; i < redirectGenericsTypes.length; i++) { - GenericsType redirectType = redirectGenericsTypes[i]; - if (redirectType.isPlaceholder()) { - GenericsType.GenericsTypeName name = new GenericsType.GenericsTypeName(redirectType.getName()); - if (!map.containsKey(name)) { - GenericsType value = parameterized[i]; - map.put(name, value); - - valueList.add(value); + List typeArguments = new ArrayList<>(n); + for (int i = 0; i < n; i += 1) { + GenericsType rgt = redirectGenericsTypes[i]; + if (rgt.isPlaceholder()) { + GenericsType.GenericsTypeName name = new GenericsType.GenericsTypeName(rgt.getName()); + if (!placeholders.containsKey(name)) { + GenericsType typeArgument = parameterized[i]; + placeholders.put(name, typeArgument); + typeArguments.add(typeArgument); } } } - for (GenericsType value : valueList) { - if (value.isWildcard()) { - ClassNode lowerBound = value.getLowerBound(); + // examine non-placeholder type args + for (GenericsType gt : typeArguments) { + if (gt.isWildcard()) { + ClassNode lowerBound = gt.getLowerBound(); if (lowerBound != null) { - extractPlaceholders(lowerBound, map); - } - ClassNode[] upperBounds = value.getUpperBounds(); - if (upperBounds != null) { - for (ClassNode upperBound : upperBounds) { - extractPlaceholders(upperBound, map); + extractPlaceholders(lowerBound, placeholders); + } else { + ClassNode[] upperBounds = gt.getUpperBounds(); + if (upperBounds != null) { + for (ClassNode upperBound : upperBounds) { + extractPlaceholders(upperBound, placeholders); + } } } - } else if (!value.isPlaceholder()) { - extractPlaceholders(value.getType(), map); + } else if (!gt.isPlaceholder()) { + extractPlaceholders(gt.getType(), placeholders); } } } @@ -344,12 +353,15 @@ public static ClassNode makeClassSafeWithGenerics(ClassNode type, GenericsType.. if (type.isArray()) { return makeClassSafeWithGenerics(type.getComponentType(), genericTypes).makeArray(); } - GenericsType[] gtypes = EMPTY_GENERICS_ARRAY; - if (genericTypes != null) { - gtypes = new GenericsType[genericTypes.length]; - System.arraycopy(genericTypes, 0, gtypes, 0, gtypes.length); + int nTypes = (genericTypes == null ? 0 : genericTypes.length); + GenericsType[] gTypes; + if (nTypes == 0) { + gTypes = EMPTY_GENERICS_ARRAY; + } else { + gTypes = new GenericsType[nTypes]; + System.arraycopy(genericTypes, 0, gTypes, 0, nTypes); } - return makeClassSafe0(type, gtypes); + return makeClassSafe0(type, gTypes); } public static MethodNode correctToGenericsSpec(Map genericsSpec, MethodNode mn) { @@ -368,7 +380,7 @@ public static MethodNode correctToGenericsSpec(Map genericsSp } public static ClassNode correctToGenericsSpecRecurse(Map genericsSpec, ClassNode type) { - return correctToGenericsSpecRecurse(genericsSpec, type, new ArrayList()); + return correctToGenericsSpecRecurse(genericsSpec, type, Collections.emptyList()); } /** @@ -379,7 +391,7 @@ public static ClassNode[] correctToGenericsSpecRecurse(Map ge ClassNode[] newTypes = new ClassNode[types.length]; boolean modified = false; for (int i = 0; i < types.length; i++) { - newTypes[i] = correctToGenericsSpecRecurse(genericsSpec, types[i], new ArrayList()); + newTypes[i] = correctToGenericsSpecRecurse(genericsSpec, types[i], Collections.emptyList()); modified = modified || (types[i] != newTypes[i]); } if (!modified) return types; @@ -394,28 +406,24 @@ public static ClassNode correctToGenericsSpecRecurse(Map gene String name = type.getGenericsTypes()[0].getName(); exclusions = plus(exclusions, name); // GROOVY-7722 type = genericsSpec.get(name); - /* GRECLIPSE edit -- GROOVY-9059 - if (type != null && type.isGenericsPlaceHolder() && type.getGenericsTypes() == null) { - ClassNode placeholder = ClassHelper.makeWithoutCaching(type.getUnresolvedName()); - placeholder.setGenericsPlaceHolder(true); - type = makeClassSafeWithGenerics(type, new GenericsType(placeholder)); - } - */ if (type != null && type.isGenericsPlaceHolder()) { + // GRECLIPSE add -- GROOVY-9059 if (type.hasMultiRedirect()) { // convert "S -> T -> U" to "T -> U" type = type.asGenericsType().getUpperBounds()[0]; // continue to resolve "T -> U" if "T" is a placeholder return correctToGenericsSpecRecurse(genericsSpec, type, exclusions); } + // GRECLIPSE end if (type.getGenericsTypes() == null) { // correct "T -> U" (no generics) ClassNode placeholder = ClassHelper.makeWithoutCaching(type.getUnresolvedName()); placeholder.setGenericsPlaceHolder(true); return makeClassSafeWithGenerics(type, new GenericsType(placeholder)); + } else if (!name.equals(type.getUnresolvedName())) { + return correctToGenericsSpecRecurse(genericsSpec, type, exclusions); } } - // GRECLIPSE end } if (type == null) type = ClassHelper.OBJECT_TYPE; GenericsType[] oldgTypes = type.getGenericsTypes(); @@ -474,15 +482,18 @@ public static ClassNode correctToGenericsSpec(Map genericsSpe if (type.isArray()) { return correctToGenericsSpec(genericsSpec, type.getComponentType()).makeArray(); } - if (type.isGenericsPlaceHolder()) { + if (type.isGenericsPlaceHolder() && type.getGenericsTypes() != null) { String name = type.getGenericsTypes()[0].getName(); type = genericsSpec.get(name); - // GRECLIPSE add -- GROOVY-9059 - if (type != null && type.isGenericsPlaceHolder() && type.hasMultiRedirect()) { + if (type != null && type.isGenericsPlaceHolder() + /* GRECLIPSE edit -- GROOVY-9059 + && !name.equals(type.getUnresolvedName())) { + */ + && type.hasMultiRedirect()) { type = type.asGenericsType().getUpperBounds()[0]; + // GRECLIPSE end return correctToGenericsSpec(genericsSpec, type); } - // GRECLIPSE end } if (type == null) type = ClassHelper.OBJECT_TYPE; return type; @@ -521,35 +532,37 @@ public static Map createGenericsSpec(ClassNode current, Map addMethodGenerics(MethodNode current, Map oldSpec) { - Map ret = new HashMap(oldSpec); - // ret starts with the original type specs, now add gts for the current method if any - GenericsType[] sgts = current.getGenericsTypes(); - if (sgts != null) { - for (GenericsType sgt : sgts) { - String name = sgt.getName(); + Map newSpec = new HashMap(oldSpec); + GenericsType[] gts = current.getGenericsTypes(); + if (gts != null) { + for (GenericsType gt : gts) { + String name = gt.getName(); + ClassNode type = gt.getType(); /* GRECLIPSE edit - if (sgt.isPlaceholder()) { + if (gt.isPlaceholder()) { ClassNode redirect; - if (sgt.getUpperBounds() != null) { - redirect = sgt.getUpperBounds()[0]; - } else if (sgt.getLowerBound() != null) { - redirect = sgt.getLowerBound(); + if (gt.getUpperBounds() != null) { + redirect = gt.getUpperBounds()[0]; + } else if (gt.getLowerBound() != null) { + redirect = gt.getLowerBound(); } else { redirect = ClassHelper.OBJECT_TYPE; } - ClassNode type = ClassHelper.makeWithoutCaching(name); - type.setGenericsPlaceHolder(true); - type.setRedirect(redirect); - ret.put(name, type); - } else { - ret.put(name, sgt.getType()); + if (redirect.isGenericsPlaceHolder()) { + // "T extends U" or "T super U" + type = redirect; // GROOVY-9059 + } else { + // "T" or "T extends Type" or "T super Type" + type = ClassHelper.makeWithoutCaching(name); + type.setGenericsPlaceHolder(true); + type.setRedirect(redirect); + } } */ - ret.put(name, sgt.getType()); - // GRECLIPSE end + newSpec.put(name, type); } } - return ret; + return newSpec; } public static void extractSuperClassGenerics(ClassNode type, ClassNode target, Map spec) { @@ -581,19 +594,11 @@ public static void extractSuperClassGenerics(ClassNode type, ClassNode target, M } } - public static ClassNode getSuperClass(ClassNode type, ClassNode target) { - ClassNode superClass = ClassHelper.getNextSuperClass(type, target); - - if (superClass == null) { - if (ClassHelper.isPrimitiveType(type)) { - superClass = ClassHelper.getNextSuperClass(ClassHelper.getWrapper(type), target); - } - } - - return superClass; + public static ClassNode getSuperClass(final ClassNode type, final ClassNode target) { + return ClassHelper.getNextSuperClass(ClassHelper.isPrimitiveType(type) ? ClassHelper.getWrapper(type) : type, target); } - private static void extractSuperClassGenerics(GenericsType[] usage, GenericsType[] declaration, Map spec) { + private static void extractSuperClassGenerics(final GenericsType[] usage, final GenericsType[] declaration, final Map spec) { // if declaration does not provide generics, there is no connection to make if (declaration == null || declaration.length == 0) return; @@ -768,32 +773,6 @@ public static GenericsType[] applyGenericsContextToPlaceHolders(Map sr = PARAMETERIZED_TYPE_CACHE.getAndPut(new ParameterizedTypeCacheKey(genericsClass, actualType), new EvictableCache.ValueProvider>() { - @Override - public SoftReference provide(ParameterizedTypeCacheKey key) { - return new SoftReference<>(findParameterizedType(key.getGenericsClass(), key.getActualType(), tryToFindExactType)); - } - }); - - return null == sr ? null : sr.get(); - } - /** * Get the parameterized type by search the whole class hierarchy according to generics class and actual receiver. * {@link #findParameterizedTypeFromCache(ClassNode, ClassNode)} is strongly recommended for better performance. @@ -877,16 +856,6 @@ public static boolean hasUnresolvedGenerics(final ClassNode type) { return false; } - private static final EvictableCache> PARAMETERIZED_TYPE_CACHE = new ConcurrentSoftCache<>(64); - - /** - * Clear the parameterized type cache - * It is useful to IDE as the type being compiled are continuously being edited/altered, see GROOVY-8675 - */ - public static void clearParameterizedTypeCache() { - PARAMETERIZED_TYPE_CACHE.clearAll(); - } - /** * map declaring generics type to actual generics type, e.g. GROOVY-7204: * declaring generics types: T, S extends Serializable @@ -900,8 +869,8 @@ public static void clearParameterizedTypeCache() { * The resolved types can not help us to choose methods correctly if the argument is a string: T: Object, S: Serializable * so we need actual types: T: String, S: Long */ - public static Map makeDeclaringAndActualGenericsTypeMap(ClassNode declaringClass, ClassNode actualReceiver) { - return doMakeDeclaringAndActualGenericsTypeMap(declaringClass, actualReceiver, false).getFirst(); + public static Map makeDeclaringAndActualGenericsTypeMap(final ClassNode declaringClass, final ClassNode actualReceiver) { + return doMakeDeclaringAndActualGenericsTypeMap(declaringClass, actualReceiver, false); } /** @@ -914,141 +883,62 @@ public static Map makeDeclaringAndActualGenericsType * @param declaringClass the generics class node declaring the generics types * @param actualReceiver the sub-class class node * @return the placeholder-to-actualtype mapping + * * @since 2.5.9 */ - public static Map makeDeclaringAndActualGenericsTypeMapOfExactType(ClassNode declaringClass, ClassNode actualReceiver) { - /* GRECLIPSE edit -- GROOVY-10282 - List parameterizedTypeList = new LinkedList<>(); - - Map result = makeDeclaringAndActualGenericsTypeMapOfExactType(declaringClass, actualReceiver, parameterizedTypeList); - - return connectGenericsTypes(result); - */ - return doMakeDeclaringAndActualGenericsTypeMap(declaringClass, actualReceiver, true).getFirst(); - // GRECLIPSE end - } - - /* GRECLIPSE edit - private static Map makeDeclaringAndActualGenericsTypeMapOfExactType(ClassNode declaringClass, ClassNode actualReceiver, List parameterizedTypeList) { - Tuple2, ClassNode> resultAndParameterizedTypeTuple = doMakeDeclaringAndActualGenericsTypeMap(declaringClass, actualReceiver, true); - ClassNode parameterizedType = resultAndParameterizedTypeTuple.getSecond(); - Map result = resultAndParameterizedTypeTuple.getFirst(); - - if (hasPlaceHolders(parameterizedType) && !parameterizedTypeList.contains(parameterizedType)) { - parameterizedTypeList.add(parameterizedType); - result.putAll(makeDeclaringAndActualGenericsTypeMapOfExactType(parameterizedType, actualReceiver, parameterizedTypeList)); - } - - return connectGenericsTypes(result); + public static Map makeDeclaringAndActualGenericsTypeMapOfExactType(final ClassNode declaringClass, final ClassNode actualReceiver) { + return doMakeDeclaringAndActualGenericsTypeMap(declaringClass, actualReceiver, true); } - */ - private static Tuple2, ClassNode> doMakeDeclaringAndActualGenericsTypeMap(ClassNode declaringClass, ClassNode actualReceiver, boolean tryToFindExactType) { + private static Map doMakeDeclaringAndActualGenericsTypeMap(final ClassNode declaringClass, final ClassNode actualReceiver, final boolean tryToFindExactType) { + Map map = Collections.emptyMap(); ClassNode parameterizedType = findParameterizedTypeFromCache(declaringClass, actualReceiver, tryToFindExactType); - /* GRECLIPSE edit -- GROOVY-10166 - if (parameterizedType == null) { - return new Tuple2<>(Collections.emptyMap(), parameterizedType); - } - - Map result = new LinkedHashMap<>(); - result.putAll(makePlaceholderAndParameterizedTypeMap(declaringClass)); - result.putAll(makePlaceholderAndParameterizedTypeMap(parameterizedType)); - - result = connectGenericsTypes(result); - - return new Tuple2<>(result, parameterizedType); - */ - if (parameterizedType != null && parameterizedType.isRedirectNode() && !parameterizedType.isGenericsPlaceHolder()) { - // declaringClass may be "List -> List" and parameterizedType may be "List -> List" + if (parameterizedType != null && parameterizedType.isRedirectNode() && !parameterizedType.isGenericsPlaceHolder()) { // GROOVY-10166 + // declaringClass may be "List -> List" and parameterizedType may be "List -> List" or "List<> -> List" GenericsType[] targetGenericsTypes = parameterizedType.redirect().getGenericsTypes(); if (targetGenericsTypes != null) { GenericsType[] sourceGenericsTypes = parameterizedType.getGenericsTypes(); if (sourceGenericsTypes == null) sourceGenericsTypes = EMPTY_GENERICS_ARRAY; - Map map = new LinkedHashMap<>(); + map = new LinkedHashMap(); for (int i = 0, m = sourceGenericsTypes.length, n = targetGenericsTypes.length; i < n; i += 1) { map.put(targetGenericsTypes[i], i < m ? sourceGenericsTypes[i] : targetGenericsTypes[i]); } - return new Tuple2<>(map, parameterizedType); - } - } - return new Tuple2<>(Collections.emptyMap(), parameterizedType); - // GRECLIPSE end - } - - /* GRECLIPSE edit - private static Map connectGenericsTypes(Map genericsTypeMap) { - Map result = new LinkedHashMap<>(); - - outer: - for (Map.Entry entry : genericsTypeMap.entrySet()) { - GenericsType key = entry.getKey(); - GenericsType value = entry.getValue(); - - if (value.isPlaceholder()) { - for (Map.Entry genericsTypeMapEntry : genericsTypeMap.entrySet()) { - GenericsType genericsTypeMapEntryValue = genericsTypeMapEntry.getValue(); - if (!genericsTypeMapEntryValue.isPlaceholder() && (genericsTypeMapEntry.getKey().getName().equals(value.getName()))) { - result.put(key, genericsTypeMapEntryValue); // connected to actual type - continue outer; - } - } } - - result.put(key, value); } - - return result; + return map; } - */ - public static boolean hasPlaceHolders(ClassNode parameterizedType) { - return checkPlaceHolders(parameterizedType, GenericsType::isPlaceholder); + /** + * Checks if the type has any placeholder (aka unresolved) generics. + * + * @since 2.5.10 + */ + public static boolean hasPlaceHolders(final ClassNode type) { + return checkPlaceHolders(type, GenericsType::isPlaceholder); } - private static boolean checkPlaceHolders(ClassNode parameterizedType, java.util.function.Predicate p) { - if (parameterizedType == null) return false; - - GenericsType[] genericsTypes = parameterizedType.getGenericsTypes(); - - if (genericsTypes == null) return false; - - for (GenericsType genericsType : genericsTypes) { - if (p.test(genericsType)) { - return true; + private static boolean checkPlaceHolders(final ClassNode type, final java.util.function.Predicate p) { + if (type != null) { + GenericsType[] genericsTypes = type.getGenericsTypes(); + if (genericsTypes != null) { + for (GenericsType genericsType : genericsTypes) { + if (p.test(genericsType)) { + return true; + } + } } } - return false; } - /* GRECLIPSE edit - private static Map makePlaceholderAndParameterizedTypeMap(ClassNode declaringClass) { - if (declaringClass == null) { - return Collections.emptyMap(); - } - - ClassNode redirectDeclaringClass = declaringClass.redirect(); - GenericsType[] declaringGenericsTypes = declaringClass.getGenericsTypes(); - GenericsType[] redirectDeclaringGenericsTypes = redirectDeclaringClass.getGenericsTypes(); - - Map result = new LinkedHashMap<>(); - if (declaringGenericsTypes != null && redirectDeclaringGenericsTypes != null) { - for (int i = 0, n = declaringGenericsTypes.length; i < n; i += 1) { - result.put(redirectDeclaringGenericsTypes[i], declaringGenericsTypes[i]); - } - } - return result; - } - */ - /** - * Get the actual type according to the placeholder name + * Gets the actual type according to the placeholder name. * - * @param placeholderName the placeholder name, e.g. T, E + * @param placeholderName the placeholder name (i.e. "T", "E", etc.) * @param genericsPlaceholderAndTypeMap the result of {@link #makeDeclaringAndActualGenericsTypeMap(ClassNode, ClassNode)} * @return the actual type */ - public static ClassNode findActualTypeByGenericsPlaceholderName(String placeholderName, Map genericsPlaceholderAndTypeMap) { + public static ClassNode findActualTypeByGenericsPlaceholderName(final String placeholderName, final Map genericsPlaceholderAndTypeMap) { for (Map.Entry entry : genericsPlaceholderAndTypeMap.entrySet()) { if (placeholderName.equals(entry.getKey().getName())) { GenericsType gt = entry.getValue(); @@ -1066,6 +956,44 @@ public static ClassNode findActualTypeByGenericsPlaceholderName(String placehold return null; } + //-------------------------------------------------------------------------- + + /** + * Clears the parameterized type cache. + *

      + * It is useful to IDE as the type being compiled are continuously being edited/altered, see GROOVY-8675 + */ + public static void clearParameterizedTypeCache() { + PARAMETERIZED_TYPE_CACHE.clearAll(); + } + + /** + * Try to get the parameterized type from the cache. If no cached item found, + * cache and return the result of {@link #findParameterizedType(ClassNode, ClassNode)} + */ + public static ClassNode findParameterizedTypeFromCache(final ClassNode genericsClass, final ClassNode actualType) { + return findParameterizedType(genericsClass, actualType, false); + } + + private static ClassNode findParameterizedTypeFromCache(final ClassNode genericsClass, final ClassNode actualType, final boolean tryToFindExactType) { + if (!PARAMETERIZED_TYPE_CACHE_ENABLED) { + return findParameterizedType(genericsClass, actualType, tryToFindExactType); + } + + SoftReference sr = PARAMETERIZED_TYPE_CACHE.getAndPut(new ParameterizedTypeCacheKey(genericsClass, actualType), new EvictableCache.ValueProvider>() { + @Override + public SoftReference provide(ParameterizedTypeCacheKey key) { + return new SoftReference<>(findParameterizedType(key.getGenericsClass(), key.getActualType(), tryToFindExactType)); + } + }); + + return sr == null ? null : sr.get(); + } + + private static final EvictableCache> PARAMETERIZED_TYPE_CACHE = new ConcurrentSoftCache<>(64); + + private static final boolean PARAMETERIZED_TYPE_CACHE_ENABLED = Boolean.getBoolean("groovy.enable.parameterized.type.cache"); + private static class ParameterizedTypeCacheKey { private ClassNode genericsClass; private ClassNode actualType; diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/ExtendedVerifier.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/ExtendedVerifier.java index b80a78f3a7..a838b790d6 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/ExtendedVerifier.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/ExtendedVerifier.java @@ -21,7 +21,6 @@ import org.codehaus.groovy.ast.AnnotatedNode; import org.codehaus.groovy.ast.AnnotationNode; import org.codehaus.groovy.ast.ClassCodeVisitorSupport; -import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.ConstructorNode; import org.codehaus.groovy.ast.FieldNode; @@ -36,7 +35,6 @@ import org.codehaus.groovy.ast.expr.ListExpression; import org.codehaus.groovy.ast.stmt.ReturnStatement; import org.codehaus.groovy.ast.stmt.Statement; -import org.codehaus.groovy.ast.tools.ParameterUtils; import org.codehaus.groovy.control.AnnotationConstantsVisitor; import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.control.ErrorCollector; @@ -44,15 +42,15 @@ import groovyjarjarasm.asm.Opcodes; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import static org.codehaus.groovy.ast.tools.GeneralUtils.getInterfacesAndSuperInterfaces; import static org.codehaus.groovy.ast.tools.GenericsUtils.correctToGenericsSpec; import static org.codehaus.groovy.ast.tools.GenericsUtils.correctToGenericsSpecRecurse; import static org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec; +import static org.codehaus.groovy.ast.tools.ParameterUtils.parametersEqual; /** * A specialized Groovy AST visitor meant to perform additional verifications upon the @@ -272,32 +270,25 @@ private void visitOverride(AnnotatedNode node, AnnotationNode visited) { } } - private static boolean isOverrideMethod(MethodNode method) { - ClassNode cNode = method.getDeclaringClass(); - ClassNode next = cNode; + private static boolean isOverrideMethod(final MethodNode method) { + ClassNode declaringClass = method.getDeclaringClass(); + ClassNode next = declaringClass; outer: while (next != null) { - Map genericsSpec = createGenericsSpec(next); - MethodNode mn = correctToGenericsSpec(genericsSpec, method); - if (next != cNode) { - ClassNode correctedNext = correctToGenericsSpecRecurse(genericsSpec, next); - MethodNode found = getDeclaredMethodCorrected(genericsSpec, mn, correctedNext); - if (found != null) break; + Map nextSpec = createGenericsSpec(next); + MethodNode mn = correctToGenericsSpec(nextSpec, method); + if (next != declaringClass) { + if (getDeclaredMethodCorrected(nextSpec, mn, next) != null) break; } - List ifaces = new ArrayList(Arrays.asList(next.getInterfaces())); - while (!ifaces.isEmpty()) { - ClassNode origInterface = ifaces.remove(0); - if (!origInterface.equals(ClassHelper.OBJECT_TYPE)) { - genericsSpec = createGenericsSpec(origInterface, genericsSpec); - ClassNode iNode = correctToGenericsSpecRecurse(genericsSpec, origInterface); - MethodNode found2 = getDeclaredMethodCorrected(genericsSpec, mn, iNode); - if (found2 != null) break outer; - Collections.addAll(ifaces, iNode.getInterfaces()); - } + + for (ClassNode face : getInterfacesAndSuperInterfaces(next)) { + Map faceSpec = createGenericsSpec(face, nextSpec); + if (getDeclaredMethodCorrected(faceSpec, mn, face) != null) break outer; } + ClassNode superClass = next.getUnresolvedSuperClass(); if (superClass != null) { - next = correctToGenericsSpecRecurse(genericsSpec, superClass); + next = correctToGenericsSpecRecurse(nextSpec, superClass); } else { next = null; } @@ -305,10 +296,10 @@ private static boolean isOverrideMethod(MethodNode method) { return next != null; } - private static MethodNode getDeclaredMethodCorrected(Map genericsSpec, MethodNode mn, ClassNode correctedNext) { - for (MethodNode declared : correctedNext.getDeclaredMethods(mn.getName())) { + private static MethodNode getDeclaredMethodCorrected(final Map genericsSpec, final MethodNode mn, final ClassNode cn) { + for (MethodNode declared : cn.getDeclaredMethods(mn.getName())) { MethodNode corrected = correctToGenericsSpec(genericsSpec, declared); - if (ParameterUtils.parametersEqual(corrected.getParameters(), mn.getParameters())) { + if (parametersEqual(corrected.getParameters(), mn.getParameters())) { return corrected; } } diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/Verifier.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/Verifier.java index f052b5fd3e..8960b98085 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/Verifier.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/classgen/Verifier.java @@ -120,12 +120,12 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.castX; import static org.codehaus.groovy.ast.tools.GeneralUtils.ctorThisX; import static org.codehaus.groovy.ast.tools.GeneralUtils.declS; +import static org.codehaus.groovy.ast.tools.GeneralUtils.getInterfacesAndSuperInterfaces; import static org.codehaus.groovy.ast.tools.GeneralUtils.localVarX; import static org.codehaus.groovy.ast.tools.GeneralUtils.varX; import static org.codehaus.groovy.ast.tools.GenericsUtils.addMethodGenerics; import static org.codehaus.groovy.ast.tools.GenericsUtils.correctToGenericsSpec; import static org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec; -import static org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeType; import static org.codehaus.groovy.ast.tools.PropertyNodeUtils.adjustPropertyModifiersForMethod; /** @@ -320,23 +320,8 @@ public void variableNotAlwaysInitialized(final VariableExpression var) { } // GRECLIPSE add - private static void addAllInterfaces(final Set result, final ClassNode source) { - for (ClassNode in : source.getInterfaces()) { - in = parameterizeType(source, in); - if (result.add(in)) - addAllInterfaces(result, in); - } - ClassNode sc = source.redirect().getUnresolvedSuperClass(false); - if (sc != null && !sc.equals(ClassHelper.OBJECT_TYPE)) { - addAllInterfaces(result, parameterizeType(source, sc)); - } - } - private static Set getAllInterfaces(final ClassNode cn) { - Set result = new HashSet<>(); - if (cn.isInterface()) result.add(cn); - addAllInterfaces(result, cn); - return result; + return getInterfacesAndSuperInterfaces(cn); } private static void checkForDuplicateInterfaces(final ClassNode cn) { diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/control/CompilerConfiguration.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/control/CompilerConfiguration.java index 0e49024b0e..76c6894694 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/control/CompilerConfiguration.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/control/CompilerConfiguration.java @@ -107,11 +107,17 @@ public class CompilerConfiguration { JDK15, Opcodes.V15 ); - /** The valid targetBytecode values. */ + /** + * The valid targetBytecode values. + */ public static final String[] ALLOWED_JDKS = JDK_TO_BYTECODE_VERSION_MAP.keySet().toArray(new String[JDK_TO_BYTECODE_VERSION_MAP.size()]); + + /** + * The ASM API version used when loading/parsing classes and generating proxy adapter classes. + */ + public static final int ASM_API_VERSION = Opcodes.ASM9; + /* GRECLIPSE edit - public static final int ASM_API_VERSION = Opcodes.ASM8; - @Deprecated public static final String CURRENT_JVM_VERSION = JDK7; */ public static final String DEFAULT_SOURCE_ENCODING = "UTF-8"; diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index 3fe690db07..e5ddf7bba6 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -69,7 +69,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.Set; import java.util.TreeSet; @@ -163,13 +162,15 @@ import static org.codehaus.groovy.syntax.Types.RIGHT_SHIFT_UNSIGNED_EQUAL; /** - * Static support methods for {@link StaticTypeCheckingVisitor}. + * Support methods for {@link StaticTypeCheckingVisitor}. */ public abstract class StaticTypeCheckingSupport { - protected static final ClassNode Collection_TYPE = makeWithoutCaching(Collection.class); - protected static final ClassNode Deprecated_TYPE = makeWithoutCaching(Deprecated.class); + protected static final ClassNode Matcher_TYPE = makeWithoutCaching(Matcher.class); protected static final ClassNode ArrayList_TYPE = makeWithoutCaching(ArrayList.class); + protected static final ClassNode Collection_TYPE = makeWithoutCaching(Collection.class); + protected static final ClassNode Deprecated_TYPE = makeWithoutCaching(Deprecated.class); + protected static final ExtensionMethodCache EXTENSION_METHOD_CACHE = new ExtensionMethodCache(); protected static final Map NUMBER_TYPES = Collections.unmodifiableMap( new HashMap() { @@ -1625,7 +1626,7 @@ private static boolean isOuterClassOf(ClassNode receiver, ClassNode type) { private static Set extractResolvedPlaceHolders(Map resolvedMethodGenerics) { if (resolvedMethodGenerics.isEmpty()) return Collections.EMPTY_SET; Set result = new HashSet(); - for (Entry entry : resolvedMethodGenerics.entrySet()) { + for (Map.Entry entry : resolvedMethodGenerics.entrySet()) { GenericsType value = entry.getValue(); if (value.isPlaceholder()) continue; result.add(entry.getKey()); @@ -1681,7 +1682,7 @@ private static GenericsType buildWildcardType(GenericsType origin) { } private static boolean compatibleConnections(Map connections, Map resolvedMethodGenerics, Set fixedGenericsPlaceHolders) { - for (Entry entry : connections.entrySet()) { + for (Map.Entry entry : connections.entrySet()) { GenericsType resolved = resolvedMethodGenerics.get(entry.getKey()); if (resolved == null) continue; GenericsType connection = entry.getValue(); @@ -1745,7 +1746,7 @@ private static boolean compatibleConnection(GenericsType resolved, GenericsType } private static void addMissingEntries(Map connections, Map resolved) { - for (Entry entry : connections.entrySet()) { + for (Map.Entry entry : connections.entrySet()) { if (resolved.containsKey(entry.getKey())) continue; GenericsType gt = entry.getValue(); ClassNode cn = gt.getType(); @@ -2149,21 +2150,6 @@ static ClassNode getCombinedBoundType(GenericsType genericsType) { return genericsType.getType(); } - /* GRECLIPSE edit - private static void applyContextGenerics(Map resolvedPlaceholders, Map placeholdersFromContext) { - if (placeholdersFromContext == null) return; - for (Entry entry : resolvedPlaceholders.entrySet()) { - GenericsType gt = entry.getValue(); - if (gt.isPlaceholder()) { - GenericsTypeName name = new GenericsTypeName(gt.getName()); - GenericsType outer = placeholdersFromContext.get(name); - if (outer == null) continue; - entry.setValue(outer); - } - } - } - */ - private static Map getGenericsParameterMapOfThis(ClassNode cn) { if (cn == null) return null; Map map = null; diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index e65649c993..f515408ba5 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -99,6 +99,7 @@ import org.codehaus.groovy.classgen.asm.InvocationWriter; import org.codehaus.groovy.control.CompilationUnit; import org.codehaus.groovy.control.ErrorCollector; +import org.codehaus.groovy.control.ResolveVisitor; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.control.messages.SyntaxErrorMessage; import org.codehaus.groovy.runtime.DefaultGroovyMethods; @@ -181,7 +182,6 @@ import static org.codehaus.groovy.ast.ClassHelper.isPrimitiveType; import static org.codehaus.groovy.ast.ClassHelper.isSAMType; import static org.codehaus.groovy.ast.ClassHelper.long_TYPE; -import static org.codehaus.groovy.ast.ClassHelper.make; import static org.codehaus.groovy.ast.ClassHelper.short_TYPE; import static org.codehaus.groovy.ast.ClassHelper.void_WRAPPER_TYPE; import static org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe; @@ -304,11 +304,11 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { protected static final MethodNode GET_THISOBJECT = CLOSURE_TYPE.getGetterMethod("getThisObject"); protected static final ClassNode DELEGATES_TO = ClassHelper.make(DelegatesTo.class); protected static final ClassNode DELEGATES_TO_TARGET = ClassHelper.make(DelegatesTo.Target.class); - protected static final ClassNode LINKEDHASHMAP_CLASSNODE = make(LinkedHashMap.class); - protected static final ClassNode CLOSUREPARAMS_CLASSNODE = make(ClosureParams.class); - protected static final ClassNode NAMED_PARAMS_CLASSNODE = make(NamedParams.class); - protected static final ClassNode MAP_ENTRY_TYPE = make(Map.Entry.class); - protected static final ClassNode ENUMERATION_TYPE = make(Enumeration.class); + protected static final ClassNode LINKEDHASHMAP_CLASSNODE = ClassHelper.make(LinkedHashMap.class); + protected static final ClassNode CLOSUREPARAMS_CLASSNODE = ClassHelper.make(ClosureParams.class); + protected static final ClassNode NAMED_PARAMS_CLASSNODE = ClassHelper.make(NamedParams.class); + protected static final ClassNode MAP_ENTRY_TYPE = ClassHelper.make(Map.Entry.class); + protected static final ClassNode ENUMERATION_TYPE = ClassHelper.make(Enumeration.class); // GRECLIPSE add private static final ClassNode STREAM_TYPE = ClassHelper.make(Stream.class); private static final ClassNode SET_TYPE = ClassHelper.makeWithoutCaching(Set.class); @@ -317,61 +317,44 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { public static final Statement GENERATED_EMPTY_STATEMENT = new EmptyStatement(); - public static final MethodNode CLOSURE_CALL_NO_ARG; - public static final MethodNode CLOSURE_CALL_ONE_ARG; - public static final MethodNode CLOSURE_CALL_VARGS; - - static { - // Cache closure call methods - CLOSURE_CALL_NO_ARG = CLOSURE_TYPE.getDeclaredMethod("call", Parameter.EMPTY_ARRAY); - CLOSURE_CALL_ONE_ARG = CLOSURE_TYPE.getDeclaredMethod("call", new Parameter[]{ - new Parameter(OBJECT_TYPE, "arg") - }); - CLOSURE_CALL_VARGS = CLOSURE_TYPE.getDeclaredMethod("call", new Parameter[]{ - new Parameter(OBJECT_TYPE.makeArray(), "args") - }); - } - - private static final String[] EMPTY_STRING_ARRAY = new String[0]; + // Cache closure call methods + public static final MethodNode CLOSURE_CALL_NO_ARG = CLOSURE_TYPE.getDeclaredMethod("call", Parameter.EMPTY_ARRAY); + public static final MethodNode CLOSURE_CALL_ONE_ARG = CLOSURE_TYPE.getDeclaredMethod("call", new Parameter[]{new Parameter(OBJECT_TYPE, "arg")}); + public static final MethodNode CLOSURE_CALL_VARGS = CLOSURE_TYPE.getDeclaredMethod("call", new Parameter[]{new Parameter(OBJECT_TYPE.makeArray(), "args")}); protected final ReturnAdder.ReturnStatementListener returnListener = new ReturnAdder.ReturnStatementListener() { @Override public void returnStatementAdded(final ReturnStatement returnStatement) { - if (!isNullConstant(returnStatement.getExpression())) { - ClassNode returnType = checkReturnType(returnStatement); - if (typeCheckingContext.getEnclosingClosure() != null) { - addClosureReturnType(returnType); - } else if (typeCheckingContext.getEnclosingMethod() != null) { - // TODO - } else { - throw new GroovyBugError("Unexpected return statement at " + returnStatement.getLineNumber() + ":" + returnStatement.getColumnNumber() + " " + returnStatement.getText()); - } + if (isNullConstant(returnStatement.getExpression())) return; + ClassNode returnType = checkReturnType(returnStatement); + if (typeCheckingContext.getEnclosingClosure() != null) { + addClosureReturnType(returnType); + } else if (typeCheckingContext.getEnclosingMethod() == null) { + throw new GroovyBugError("Unexpected return statement at " + returnStatement.getLineNumber() + ":" + returnStatement.getColumnNumber() + " " + returnStatement.getText()); } } }; protected final ReturnAdder returnAdder = new ReturnAdder(returnListener); - protected TypeCheckingContext typeCheckingContext; - protected DefaultTypeCheckingExtension extension; protected FieldNode currentField; protected PropertyNode currentProperty; + protected DefaultTypeCheckingExtension extension; + protected TypeCheckingContext typeCheckingContext; - public StaticTypeCheckingVisitor(SourceUnit source, ClassNode cn) { + public StaticTypeCheckingVisitor(final SourceUnit source, final ClassNode classNode) { this.typeCheckingContext = new TypeCheckingContext(this); - this.extension = createDefaultTypeCheckingExtension(); - this.typeCheckingContext.source = source; - this.typeCheckingContext.pushEnclosingClassNode(cn); - this.typeCheckingContext.pushErrorCollector(source.getErrorCollector()); + this.typeCheckingContext.pushEnclosingClassNode(classNode); this.typeCheckingContext.pushTemporaryTypeInfo(); - } + this.typeCheckingContext.pushErrorCollector( + source.getErrorCollector()); + this.typeCheckingContext.source = source; - private DefaultTypeCheckingExtension createDefaultTypeCheckingExtension() { - DefaultTypeCheckingExtension ext = new DefaultTypeCheckingExtension(this); - ext.addHandler(new TraitTypeCheckingExtension(this)); - return ext; + this.extension = new DefaultTypeCheckingExtension(this); + this.extension.addHandler(new TraitTypeCheckingExtension(this)); } + @Override protected SourceUnit getSourceUnit() { return typeCheckingContext.getSource(); } @@ -697,21 +680,21 @@ public void visitVariableExpression(VariableExpression vexp) { if (!(accessedVariable instanceof DynamicVariable)) { /* GRECLIPSE edit -- GROOVY-9907 - if (typeCheckingContext.getEnclosingClosure() == null) { + if (enclosingClosure == null) { */ { // GRECLIPSE end VariableExpression variable = null; if (accessedVariable instanceof Parameter) { - variable = new ParameterVariableExpression((Parameter) accessedVariable); + Parameter parameter = (Parameter) accessedVariable; + variable = new ParameterVariableExpression(parameter); } else if (accessedVariable instanceof VariableExpression) { variable = (VariableExpression) accessedVariable; } - if (variable != null) { ClassNode inferredType = getInferredTypeFromTempInfo(variable, (ClassNode) variable.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE)); /* GRECLIPSE edit -- GROOVY-10102, GROOVY-10179, GROOVY-10217, GROOVY-10308, et al. - if (inferredType != null && !inferredType.getName().equals("java.lang.Object")) { + if (inferredType != null && !inferredType.getName().equals(ClassHelper.OBJECT)) { vexp.putNodeMetaData(StaticTypesMarker.INFERRED_RETURN_TYPE, inferredType); } */ @@ -1044,8 +1027,9 @@ && isAssignment(enclosingBinaryExpression.getOperation().getType())) { } /** - * Given a binary expression corresponding to an assignment, will check that the type of the RHS matches one - * of the possible setters and if not, throw a type checking error. + * Given a binary expression corresponding to an assignment, will check that + * the type of the RHS matches one of the possible setters and if not, throw + * a type checking error. * * @param expression the assignment expression * @param leftExpression left expression of the assignment @@ -1186,48 +1170,45 @@ protected void inferDiamondType(final ConstructorCallExpression cce, final Class ClassNode cceType = cce.getType(), inferredType = lType; // check if constructor call expression makes use of the diamond operator if (cceType.getGenericsTypes() != null && cceType.getGenericsTypes().length == 0) { - ArgumentListExpression argumentListExpression = InvocationWriter.makeArgumentList(cce.getArguments()); - /* GRECLIPSE edit -- GROOVY-9948, GROOVY-9983, GROOVY-10291, GROOVY-10367, GROOVY-10368, et al. - if (argumentListExpression.getExpressions().isEmpty()) { - adjustGenerics(lType, cceType); - } else { - ClassNode type = getType(argumentListExpression.getExpression(0)); - if (type.isUsingGenerics()) { - adjustGenerics(type, cceType); - } - } - // store inferred type on CCE - storeType(cce, cceType); - */ + ArgumentListExpression argumentList = InvocationWriter.makeArgumentList(cce.getArguments()); ConstructorNode constructor = cce.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET); - if (!argumentListExpression.getExpressions().isEmpty() && constructor != null) { + if (constructor != null && !argumentList.getExpressions().isEmpty()) { ClassNode type = GenericsUtils.parameterizeType(cceType, cceType); - type = inferReturnTypeGenerics(type, constructor, argumentListExpression); + type = inferReturnTypeGenerics(type, constructor, argumentList); + /* GRECLIPSE edit + if (type.isUsingGenerics()) { + // GROOVY-6232, GROOVY-9956: if cce not assignment compatible, process target as additional type witness + if (checkCompatibleAssignmentTypes(lType, type, cce) && !GenericsUtils.buildWildcardType(lType).isCompatibleWith(type)) { + */ // process target as additional type witness, if ... if (lType.getGenericsTypes() != null // has generics && (type.toString(false).indexOf('#') > 0 // unresolved generics // GROOVY-6232, GROOVY-9956, etc.: cce not assignment compatible || checkCompatibleAssignmentTypes(lType, type, cce) && !GenericsUtils.buildWildcardType(lType).isCompatibleWith(type))) { - // allow covariance of each type parameter, but maintain semantics for nested generics + // GRECLIPSE end + // allow covariance of each type parameter, but maintain semantics for nested generics - ClassNode pType = GenericsUtils.parameterizeType(lType, type); - GenericsType[] lhs = pType.getGenericsTypes(), rhs = type.getGenericsTypes(); - if (lhs == null || rhs == null || lhs.length != rhs.length) throw new GroovyBugError( - "Parameterization failed: " + prettyPrintType(pType) + " ~ " + prettyPrintType(type)); + ClassNode pType = GenericsUtils.parameterizeType(lType, type); + GenericsType[] lhs = pType.getGenericsTypes(), rhs = type.getGenericsTypes(); + if (lhs == null || rhs == null || lhs.length != rhs.length) throw new GroovyBugError( + "Parameterization failed: " + prettyPrintType(pType) + " ~ " + prettyPrintType(type)); - if (IntStream.range(0, lhs.length).allMatch(i -> - GenericsUtils.buildWildcardType(getCombinedBoundType(lhs[i])).isCompatibleWith(rhs[i].getType()))) { - type = pType; // lType proved to be a viable type witness + boolean allMatch = true; + for (int i = 0, n = lhs.length; i < n && allMatch; i += 1) { + if (!GenericsUtils.buildWildcardType(getCombinedBoundType(lhs[i])).isCompatibleWith(rhs[i].getType())) { // GROOVY-10368 + allMatch = false; + } + } + if (allMatch) type = pType; // lType proved to be a viable type witness } - } - inferredType = type; + inferredType = type; + //} } if (inferredType.isGenericsPlaceHolder()) // GROOVY-10344: "T t = new C<>()" inferredType = getCombinedBoundType(inferredType.getGenericsTypes()[0]); adjustGenerics(inferredType, cceType); storeType(cce, cceType); - // GRECLIPSE end } } @@ -1273,7 +1254,7 @@ private void adjustGenerics(final ClassNode source, final ClassNode target) { } /** - * Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited + * Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited. * * @param objectOfInstanceOf the expression which must be checked against instanceof * @param typeExpression the expression which represents the target type @@ -1387,7 +1368,7 @@ private static ClassNode adjustTypeForSpreading(ClassNode inferredRightExpressio if (leftExpression instanceof PropertyExpression && ((PropertyExpression) leftExpression).isSpreadSafe()) { wrappedRHS = LIST_TYPE.getPlainNodeReference(); wrappedRHS.setGenericsTypes(new GenericsType[]{ - new GenericsType(getWrapper(inferredRightExpressionType)) + new GenericsType(wrapTypeIfNecessary(inferredRightExpressionType)) }); } return wrappedRHS; @@ -1640,7 +1621,8 @@ protected static boolean hasRHSIncompleteGenericTypeInfo(final ClassNode inferre } /** - * Checks that a constructor style expression is valid regarding the number of arguments and the argument types. + * Checks that a constructor style expression is valid regarding the number + * of arguments and the argument types. * * @param node the class node for which we will try to find a matching constructor * @param arguments the constructor arguments @@ -1652,7 +1634,8 @@ protected void checkGroovyStyleConstructor(final ClassNode node, final ClassNode } /** - * Checks that a constructor style expression is valid regarding the number of arguments and the argument types. + * Checks that a constructor style expression is valid regarding the number + * of arguments and the argument types. * * @param node the class node for which we will try to find a matching constructor * @param arguments the constructor arguments @@ -1686,8 +1669,9 @@ protected MethodNode checkGroovyStyleConstructor(final ClassNode node, final Cla } /** - * When instanceof checks are found in the code, we store temporary type information data in the {@link - * TypeCheckingContext#temporaryIfBranchTypeInformation} table. This method computes the key which must be used to store this type + * When instanceof checks are found in the code, we store temporary type + * information data in the {@link TypeCheckingContext#temporaryIfBranchTypeInformation} + * table. This method computes the key which must be used to store this type * info. * * @param expression the expression for which to compute the key @@ -1708,7 +1692,7 @@ protected Object extractTemporaryTypeInfoKey(final Expression expression) { * otherwise falls back to the provided type class. */ protected ClassNode findCurrentInstanceOfClass(final Expression expr, final ClassNode type) { - if (!typeCheckingContext.temporaryIfBranchTypeInformation.empty()) { + if (!typeCheckingContext.temporaryIfBranchTypeInformation.isEmpty()) { List nodes = getTemporaryTypesForExpression(expr); if (nodes != null && nodes.size() == 1) return nodes.get(0); } @@ -1841,7 +1825,7 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re // skip property/accessor checks for "x.@field" if (storeField(field, isAttributeExpression, pexp, receiverType, visitor, receiver.getData(), !readMode)) { /* GRECLIPSE edit -- GROOVY-5450 - pexp.removeNodeMetaData(READONLY_PROPERTY); + pexp.removeNodeMetaData(StaticTypesMarker.READONLY_PROPERTY); */ return true; } else if (isAttributeExpression) { @@ -1851,7 +1835,7 @@ protected boolean existsProperty(final PropertyExpression pexp, final boolean re // skip property/accessor checks for "field", "this.field", "this.with { field }", etc. in declaring class of field if (storeField(field, enclosingTypes.contains(current), pexp, receiverType, visitor, receiver.getData(), !readMode)) { /* GRECLIPSE edit -- GROOVY-5450 - pexp.removeNodeMetaData(READONLY_PROPERTY); + pexp.removeNodeMetaData(StaticTypesMarker.READONLY_PROPERTY); */ return true; } @@ -3462,9 +3446,9 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres if (annotations != null && !annotations.isEmpty()) { for (AnnotationNode annotation : annotations) { Expression hintClass = annotation.getMember("value"); - Expression options = annotation.getMember("options"); - Expression resolverClass = annotation.getMember("conflictResolutionStrategy"); if (hintClass instanceof ClassExpression) { + Expression options = annotation.getMember("options"); + Expression resolverClass = annotation.getMember("conflictResolutionStrategy"); doInferClosureParameterTypes(receiver, arguments, expression, selectedMethod, hintClass, resolverClass, options); } } @@ -3788,57 +3772,27 @@ private ClassNode[] resolveGenericsFromTypeHint(final ClassNode receiver, final dummyMN.setDeclaringClass(orig.getDeclaringClass()); dummyMN.setGenericsTypes(orig.getGenericsTypes()); } - ClassNode classNode = inferReturnTypeGenerics(receiver, dummyMN, arguments); - /* GRECLIPSE edit -- GROOVY-9968, GROOVY-10327, GROOVY-10528 - ClassNode[] inferred = new ClassNode[classNode.getGenericsTypes().length]; - for (int i = 0; i < classNode.getGenericsTypes().length; i++) { - GenericsType genericsType = classNode.getGenericsTypes()[i]; - ClassNode value = createUsableClassNodeFromGenericsType(genericsType); - inferred[i] = value; - } - */ - GenericsType[] returnTypeGenerics = classNode.getGenericsTypes(); + ClassNode returnType = inferReturnTypeGenerics(receiver, dummyMN, arguments); + GenericsType[] returnTypeGenerics = returnType.getGenericsTypes(); ClassNode[] inferred = new ClassNode[returnTypeGenerics.length]; for (int i = 0, n = returnTypeGenerics.length; i < n; i += 1) { + /* GRECLIPSE edit -- GROOVY-9968, GROOVY-10327, GROOVY-10528 + inferred[i] = getCombinedBoundType(returnTypeGenerics[i]); + */ GenericsType gt = returnTypeGenerics[i]; if (!gt.isPlaceholder()) { inferred[i] = getCombinedBoundType(gt); } else { inferred[i] = gt.getUpperBounds() != null ? gt.getUpperBounds()[0] : gt.getType().redirect(); } + // GRECLIPSE end } - // GRECLIPSE end return inferred; } - /** - * Given a GenericsType instance, returns a ClassNode which can be used as an inferred type. - * - * @param genericsType a {@link org.codehaus.groovy.ast.GenericsType} representing either a type, a placeholder or a wildcard - * @return a class node usable as an inferred type - */ - /* GRECLIPSE edit - private static ClassNode createUsableClassNodeFromGenericsType(final GenericsType genericsType) { - ClassNode value = genericsType.getType(); - if (genericsType.isPlaceholder()) { - value = value.isRedirectNode() ? value.redirect() : OBJECT_TYPE; // GROOVY-9968 - } - ClassNode lowerBound = genericsType.getLowerBound(); - if (lowerBound != null) { - value = lowerBound; - } else { - ClassNode[] upperBounds = genericsType.getUpperBounds(); - if (upperBounds != null) { - value = lowestUpperBound(Arrays.asList(upperBounds)); - } - } - return value; - } - */ - private static String[] convertToStringArray(final Expression options) { if (options == null) { - return EMPTY_STRING_ARRAY; + return ResolveVisitor.EMPTY_STRING_ARRAY; } if (options instanceof ConstantExpression) { return new String[]{options.getText()}; @@ -6324,27 +6278,8 @@ private Map extractGenericsConnectionsFromArgume * method target of "m", {@code T} could be resolved. */ private void resolvePlaceholdersFromImplicitTypeHints(final ClassNode[] actuals, final ArgumentListExpression argumentList, final Parameter[] parameterArray) { - /* GRECLIPSE edit - for (int i = 0, n = actuals.length; i < n; i += 1) { - Expression a = argumentList.getExpression(i); - // check for method call without type arguments, with a known target - if (!(a instanceof MethodCall) || (a instanceof MethodCallExpression - && ((MethodCallExpression) a).isUsingGenerics())) continue; - MethodNode aNode = a.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET); - if (aNode == null || aNode.getGenericsTypes() == null) continue; - - // and unknown generics - ClassNode at = actuals[i]; - if (!GenericsUtils.hasUnresolvedGenerics(at)) continue; - - int np = parameterArray.length; - Parameter p = parameterArray[Math.min(i, np - 1)]; - - ClassNode pt = p.getOriginType(); - if (i >= (np - 1) && pt.isArray() && !at.isArray()) pt = pt.getComponentType(); - */ int np = parameterArray.length; - for (int i = 0, n = actuals.length; np > 0 && i < n; i += 1) { + for (int i = 0, n = actuals.length; i < n && np > 0; i += 1) { Expression a = argumentList.getExpression(i); Parameter p = parameterArray[Math.min(i, np - 1)]; @@ -6352,12 +6287,14 @@ private void resolvePlaceholdersFromImplicitTypeHints(final ClassNode[] actuals, if (!isUsingGenericsOrIsArrayUsingGenerics(pt)) continue; if (i >= (np - 1) && pt.isArray() && !at.isArray()) pt = pt.getComponentType(); - if (a instanceof ListExpression) { + if (a instanceof ConstructorCallExpression) { + inferDiamondType((ConstructorCallExpression) a, pt); // GROOVY-10086, GROOVY-10316 + } + // GRECLIPSE add + else if (a instanceof ListExpression) { actuals[i] = getLiteralResultType(pt, at, ArrayList_TYPE); } else if (a instanceof MapExpression) { actuals[i] = getLiteralResultType(pt, at, LINKEDHASHMAP_CLASSNODE); - } else if (a instanceof ConstructorCallExpression) { - inferDiamondType((ConstructorCallExpression) a, pt); // GROOVY-10086 } else if (a instanceof TernaryExpression && at.getGenericsTypes() != null && at.getGenericsTypes().length == 0) { // GROOVY-9983: double diamond scenario -- "m(flag ? new Type<>(...) : new Type<>(...))" typeCheckingContext.pushEnclosingBinaryExpression(assignX(varX(p), a, a)); @@ -6365,6 +6302,7 @@ private void resolvePlaceholdersFromImplicitTypeHints(final ClassNode[] actuals, typeCheckingContext.popEnclosingBinaryExpression(); actuals[i] = getType(a); } + // GRECLIPSE end // check for method call without type arguments, with a known target if (!(a instanceof MethodCall) || (a instanceof MethodCallExpression @@ -6379,7 +6317,6 @@ private void resolvePlaceholdersFromImplicitTypeHints(final ClassNode[] actuals, ClassNode sc = GenericsUtils.getSuperClass(at, pt); at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), sc); } - // GRECLIPSE end // try to resolve placeholder(s) in argument type using parameter type @@ -6943,7 +6880,6 @@ protected static ClassNode[] extractTypesFromParameters(final Parameter[] parame * This method differs from {@link ClassHelper#getWrapper(org.codehaus.groovy.ast.ClassNode)} as it will * return the same instance if the provided type is not a generic type. * - * @param type * @return the wrapped type */ protected static ClassNode wrapTypeIfNecessary(ClassNode type) { @@ -6959,6 +6895,7 @@ protected static boolean isClassInnerClassOrEqualTo(ClassNode toBeChecked, Class return false; } + //-------------------------------------------------------------------------- protected class VariableExpressionTypeMemoizer extends ClassCodeVisitorSupport { private final boolean onlySharedVariables; @@ -6991,7 +6928,7 @@ public void visitVariableExpression(final VariableExpression expression) { } } - // ------------------- codecs for method return type signatures ------------------------------ + //-------------------------------------------------------------------------- public static class SignatureCodecFactory { public static SignatureCodec getCodec(int version, final ClassLoader classLoader) { @@ -7018,7 +6955,6 @@ private SetterInfo(final ClassNode receiverType, final String name, final List T getNodeMetaData(Object key) { + public T getNodeMetaData(final Object key) { return parameter.getNodeMetaData(key); } - + // GRECLIPSE add @Override - /* GRECLIPSE edit - public void setNodeMetaData(Object key, Object value) { - parameter.setNodeMetaData(key, value); - */ - public T getNodeMetaData(Object key, Function valFn) { + public T getNodeMetaData(final Object key, final Function valFn) { return parameter.getNodeMetaData(key, valFn); + } // GRECLIPSE end + + @Override + public Object putNodeMetaData(final Object key, final Object value) { + return parameter.putNodeMetaData(key, value); } } } diff --git a/base/org.eclipse.jdt.groovy.core/META-INF/MANIFEST.MF b/base/org.eclipse.jdt.groovy.core/META-INF/MANIFEST.MF index 3719a27315..6acee5a51a 100644 --- a/base/org.eclipse.jdt.groovy.core/META-INF/MANIFEST.MF +++ b/base/org.eclipse.jdt.groovy.core/META-INF/MANIFEST.MF @@ -15,7 +15,7 @@ Export-Package: org.codehaus.jdt.groovy.ast, org.eclipse.jdt.groovy.core.util, org.eclipse.jdt.groovy.search Import-Package: org.eclipse.jdt.launching -Require-Bundle: org.codehaus.groovy;bundle-version="[2.5.17,5)";visibility:=reexport, +Require-Bundle: org.codehaus.groovy;bundle-version="[2.5.18,5)";visibility:=reexport, org.eclipse.core.expressions;visibility:=reexport, org.eclipse.core.filesystem;visibility:=reexport, org.eclipse.core.resources;visibility:=reexport, diff --git a/docs/Manual-Setup.md b/docs/Manual-Setup.md index 72688444d0..250df692c1 100644 --- a/docs/Manual-Setup.md +++ b/docs/Manual-Setup.md @@ -12,7 +12,7 @@ On the Eclipse menu bar, select *Help -> Install New Software...*. In the *Inst ### Setup Groovy Compiler -If you installed extra Groovy compiler versions, then you must activate Groovy 2.5 compiler for Groovy-Eclipse. On the Eclipse menu bar, select *Window -> Preferences*. In the *Preferences* window, go to *Groovy -> Compiler*. Click the *Switch to 2.5.17* button, and let Eclipse restart. +If you installed extra Groovy compiler versions, then you must activate Groovy 2.5 compiler for Groovy-Eclipse. On the Eclipse menu bar, select *Window -> Preferences*. In the *Preferences* window, go to *Groovy -> Compiler*. Click the *Switch to 2.5.18* button, and let Eclipse restart. ### Install Execution Environment Descriptions diff --git a/extras/Feature-org.codehaus.groovy.m2eclipse/feature.xml b/extras/Feature-org.codehaus.groovy.m2eclipse/feature.xml index 7ac5fc8b3d..ecb7d14b0e 100644 --- a/extras/Feature-org.codehaus.groovy.m2eclipse/feature.xml +++ b/extras/Feature-org.codehaus.groovy.m2eclipse/feature.xml @@ -19,7 +19,7 @@ - + diff --git a/extras/groovy-eclipse-batch-builder/build.properties b/extras/groovy-eclipse-batch-builder/build.properties index 32a80da620..3e4c28e79b 100644 --- a/extras/groovy-eclipse-batch-builder/build.properties +++ b/extras/groovy-eclipse-batch-builder/build.properties @@ -1,5 +1,5 @@ # version numbers -version2.5=2.5.17-02 +version2.5=2.5.18-01 version3.0=3.0.11-03 version4.0=4.0.3-02 diff --git a/extras/groovy-eclipse-maven-tests/pom.xml b/extras/groovy-eclipse-maven-tests/pom.xml index b696bf4fd0..ea522129d9 100644 --- a/extras/groovy-eclipse-maven-tests/pom.xml +++ b/extras/groovy-eclipse-maven-tests/pom.xml @@ -37,7 +37,7 @@ org.codehaus.groovy groovy indy - 2.5.17 + 2.5.18 @@ -72,7 +72,7 @@ org.codehaus.groovy groovy-eclipse-batch - 2.5.17-02 + 2.5.18-01 diff --git a/extras/groovy-eclipse-quickstart/src/main/resources/archetype-resources/pom.xml b/extras/groovy-eclipse-quickstart/src/main/resources/archetype-resources/pom.xml index 9eb5f09cbe..c4995b246e 100755 --- a/extras/groovy-eclipse-quickstart/src/main/resources/archetype-resources/pom.xml +++ b/extras/groovy-eclipse-quickstart/src/main/resources/archetype-resources/pom.xml @@ -19,13 +19,13 @@ org.codehaus.groovy groovy - 2.5.17 + 2.5.18 indy org.codehaus.groovy groovy-test - 2.5.17 + 2.5.18 indy @@ -64,7 +64,7 @@ org.codehaus.groovy groovy-eclipse-batch - 2.5.17-02 + 2.5.18-01 diff --git a/ide-test/org.codehaus.groovy.eclipse.dsl.tests/testResources/DSLD_meta_script.dsld b/ide-test/org.codehaus.groovy.eclipse.dsl.tests/testResources/DSLD_meta_script.dsld index ca587ba21f..66c1bad882 100644 --- a/ide-test/org.codehaus.groovy.eclipse.dsl.tests/testResources/DSLD_meta_script.dsld +++ b/ide-test/org.codehaus.groovy.eclipse.dsl.tests/testResources/DSLD_meta_script.dsld @@ -25,7 +25,7 @@ import org.codehaus.groovy.eclipse.dsl.script.PointcutFactory // first thing to do is to check that versions are correct // for this script to be evaluated any further, all conditions must be met // also supports grailsTooling and sts, which are synonyms and correspond to the STS version eg- 2.6.0 -assertVersion(groovy: '2.5.17', groovyEclipse: '3.0.0') +assertVersion(groovy: '2.5.18', groovyEclipse: '3.0.0') // You can store shared pointcuts in a variable // This particular pointcut matches all join points that are inside of a diff --git a/ide/Feature-org.codehaus.groovy25.feature/feature.xml b/ide/Feature-org.codehaus.groovy25.feature/feature.xml index 5fde14eb5c..cff7dd93f8 100644 --- a/ide/Feature-org.codehaus.groovy25.feature/feature.xml +++ b/ide/Feature-org.codehaus.groovy25.feature/feature.xml @@ -22,7 +22,7 @@ id="org.codehaus.groovy" download-size="0" install-size="0" - version="2.5.17.qualifier" + version="2.5.18.qualifier" />