Permalink
Browse files

GROOVY-4954: Currying closure with null as argument fails with NPE

Conflicts:

	src/test/groovy/ClosureCurryTest.groovy
  • Loading branch information...
1 parent 135b979 commit 6344429b8db756caf4f036e2d84dceb8337becb5 @paulk-asert paulk-asert committed with melix Sep 26, 2011
Showing with 12 additions and 2 deletions.
  1. +11 −0 src/main/groovy/lang/Closure.java
  2. +1 −2 src/test/groovy/ClosureCurryTest.groovy
@@ -530,6 +530,17 @@ public void run() {
}
/**
+ * Support for Closure currying.
+ *
+ * @param argument the argument to bind
+ * @return the new closure with the argument bound
+ * @see #curry(Object...)
+ */
+ public Closure<V> curry(final Object argument) {
+ return curry(new Object[]{argument});
+ }
+
+ /**
* Support for Closure "right" currying.
* Parameters are supplied on the right rather than left as per the normal curry() method.
* Typical usage:
@@ -205,7 +205,6 @@ class ClosureCurryTest extends GroovyTestCase {
}
}
- /* reverted for the sake of Grails
void testNullVariants() {
assert { x, y -> x ?: y }.curry(null)(null) == null
assert { x, y -> x ?: y }.curry(null)(2) == 2
@@ -223,5 +222,5 @@ class ClosureCurryTest extends GroovyTestCase {
assert { x, y -> x ?: y }(1, 2) == 1
assert { x, y -> x ?: y }.curry([null] as Object[])(2) == 2
- }*/
+ }
}

0 comments on commit 6344429

Please sign in to comment.