Fixes #309: [java] Parse error on method reference
This commit is contained in:
@ -1,4 +1,9 @@
|
||||
/**
|
||||
* Allow method references to specify generics also for
|
||||
* constructor references ("new").
|
||||
* Bug #309
|
||||
* Andreas Dangel 03/2017
|
||||
*====================================================================
|
||||
* Provide a better fix for CastExpression, getting rid of most hacks.
|
||||
* Bug #257
|
||||
*
|
||||
@ -1831,7 +1836,7 @@ Token t;
|
||||
void MethodReference() :
|
||||
{Token t; checkForBadMethodReferenceUsage();}
|
||||
{
|
||||
"::" ("new" {jjtThis.setImage("new");} | [TypeArguments()] t=<IDENTIFIER> {jjtThis.setImage(t.image);} )
|
||||
"::" [TypeArguments()] ( "new" {jjtThis.setImage("new");} | t=<IDENTIFIER> {jjtThis.setImage(t.image);} )
|
||||
}
|
||||
|
||||
void PrimaryPrefix() :
|
||||
|
@ -4,6 +4,7 @@
|
||||
package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -172,6 +173,13 @@ public class ParserCornersTest extends ParserTst {
|
||||
assertEquals("A cast was found when none expected", 0, compilationUnit.findDescendantsOfType(ASTCastExpression.class).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubBug309() throws Exception {
|
||||
String code = readAsString("GitHubBug309.java");
|
||||
ASTCompilationUnit compilationUnit = parseJava18(code);
|
||||
assertNotNull(compilationUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* This triggered bug #1484 UnusedLocalVariable - false positive - parenthesis
|
||||
* @throws Exception
|
||||
|
@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
public class GitHubBug309 {
|
||||
public static void main(String[] args) {
|
||||
Runnable r11 = Main::<String>new;
|
||||
IntFunction<int[]> r13 = int[]::<String>new; // produces the same results
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ This is a bug fixing release.
|
||||
* general:
|
||||
* [#305](https://github.com/pmd/pmd/issues/305): \[core] PMD not executing under git bash
|
||||
* java-design:
|
||||
* [#309](https://github.com/pmd/pmd/issues/309): \[java] Parse error on method reference
|
||||
* [#275](https://github.com/pmd/pmd/issues/275): \[java] FinalFieldCouldBeStatic: Constant in @interface incorrectly reported as "could be made static"
|
||||
* java-junit
|
||||
* [#285](https://github.com/pmd/pmd/issues/285): \[java] JUnitTestsShouldIncludeAssertRule should support @Rule as well as @Test(expected = ...)
|
||||
|
Reference in New Issue
Block a user