Repository: groovy
Updated Branches:
  refs/heads/master 40d878f12 -> e56a13056


GROOVY-7905: ListWithDefault DGM methods aren't type inference friendly


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/dc2f94a4
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/dc2f94a4
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/dc2f94a4

Branch: refs/heads/master
Commit: dc2f94a45c48a230523a0e1c6b64e00cf8ced54a
Parents: 40d878f
Author: paulk <pa...@asert.com.au>
Authored: Fri Aug 12 12:53:31 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sun Sep 18 20:14:33 2016 +1000

----------------------------------------------------------------------
 src/main/groovy/lang/ListWithDefault.java                      | 4 ++--
 src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | 6 +++---
 .../groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/dc2f94a4/src/main/groovy/lang/ListWithDefault.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/ListWithDefault.java 
b/src/main/groovy/lang/ListWithDefault.java
index b0d2950..6b87548 100644
--- a/src/main/groovy/lang/ListWithDefault.java
+++ b/src/main/groovy/lang/ListWithDefault.java
@@ -56,7 +56,7 @@ public final class ListWithDefault<T> implements List<T> {
         return initClosure != null ? (Closure) initClosure.clone() : null;
     }
 
-    public static <T> List<T> newInstance(List<T> items, boolean 
lazyDefaultValues, Closure initClosure) {
+    public static <T> ListWithDefault<T> newInstance(List<T> items, boolean 
lazyDefaultValues, Closure initClosure) {
         if (items == null)
             throw new IllegalArgumentException("Parameter \"items\" must not 
be null");
         if (initClosure == null)
@@ -251,7 +251,7 @@ public final class ListWithDefault<T> implements List<T> {
      * @param toIndex   upper endpoint of the subList (exclusive)
      * @return a view of a specified range within this list, keeping all lazy 
list settings
      */
-    public List<T> subList(int fromIndex, int toIndex) {
+    public ListWithDefault<T> subList(int fromIndex, int toIndex) {
         return new ListWithDefault<T>(delegate.subList(fromIndex, toIndex), 
lazyDefaultValues, (Closure) initClosure.clone());
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/dc2f94a4/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 
b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 664b67c..18a715e 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -7899,7 +7899,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      * @see #withEagerDefault(java.util.List, groovy.lang.Closure)
      * @since 1.8.7
      */
-    public static <T> List<T> withDefault(List<T> self, 
@ClosureParams(value=SimpleType.class, options="int") Closure<T> init) {
+    public static <T> ListWithDefault<T> withDefault(List<T> self, 
@ClosureParams(value=SimpleType.class, options = "int") Closure<T> init) {
         return withLazyDefault(self, init);
     }
 
@@ -7945,7 +7945,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      * @return the decorated List
      * @since 1.8.7
      */
-    public static <T> List<T> withLazyDefault(List<T> self, 
@ClosureParams(value=SimpleType.class, options="int") Closure<T> init) {
+    public static <T> ListWithDefault<T> withLazyDefault(List<T> self, 
@ClosureParams(value=SimpleType.class, options="int") Closure<T> init) {
         return ListWithDefault.newInstance(self, true, init);
     }
 
@@ -7985,7 +7985,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      * @return the wrapped List
      * @since 1.8.7
      */
-    public static <T> List<T> withEagerDefault(List<T> self, 
@ClosureParams(value=SimpleType.class, options="int") Closure<T> init) {
+    public static <T> ListWithDefault<T> withEagerDefault(List<T> self, 
@ClosureParams(value=SimpleType.class, options="int") Closure<T> init) {
         return ListWithDefault.newInstance(self, false, init);
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/dc2f94a4/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy 
b/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy
index d6aeb35..3ea6a4d 100644
--- a/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy
@@ -140,7 +140,7 @@ class DefaultGroovyMethodsSTCTest extends 
StaticTypeCheckingTestCase {
     void testListWithDefaultInfersInt() {
         assertScript '''
             def list = [].withDefault{ it.longValue() }
-            list[0] = list.get(3) // TODO why doesn't getAt work?
+            list[0] = list[3]
             assert list[0] == 3 && list[0].class == Long
         '''
     }

Reply via email to