Skip to content

Commit

Permalink
GROOVY-9239 pre-work: add support at grammar level
Browse files Browse the repository at this point in the history
We still need to do something with the generics term
  • Loading branch information
paulk-asert committed Jan 15, 2024
1 parent 1fe3186 commit d8726d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/antlr/GroovyParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ pathElement returns [int t]
|
METHOD_POINTER nls // Method pointer operator: foo.&y == foo.metaClass.getMethodPointer(foo, "y")
|
METHOD_REFERENCE nls // Method reference: System.out::println
METHOD_REFERENCE nls (nonWildcardTypeArguments)? // Method reference: System.out::println
)
namePart
{ $t = 1; }
Expand Down
8 changes: 8 additions & 0 deletions src/test-resources/core/MethodReference_01x.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import java.util.function.Function
import java.util.function.Supplier
import java.util.stream.Stream

import static java.util.stream.Collectors.toList
Expand Down Expand Up @@ -109,3 +111,9 @@ assert a.class == b.class && a == b
a = String[][][][]::new(1, 2)
b = new String[1][2][][]
assert a.class == b.class && a == b

static <T extends CharSequence> T chars() { 'foo' }
Supplier foo = this::<String>chars
assert foo() == 'foo'
Function sz = ArrayList::<Integer>size
assert sz([1, 2, 3, 4]) == 4

0 comments on commit d8726d7

Please sign in to comment.