Merge branch 'issue-309'
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
|
||||
*
|
||||
@ -1837,7 +1842,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() :
|
||||
|
@ -5,6 +5,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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -439,6 +439,7 @@ You need to use this, if you have a large project with many files, and you hit t
|
||||
* [#207](https://github.com/pmd/pmd/issues/207): \[java] Parse error on method reference with generics
|
||||
* [#208](https://github.com/pmd/pmd/issues/208): \[java] Parse error with local class with 2 or more annotations
|
||||
* [#213](https://github.com/pmd/pmd/issues/213): \[java] CPD: OutOfMemory when analyzing Lucene
|
||||
* [#309](https://github.com/pmd/pmd/issues/309): \[java] Parse error on method reference
|
||||
* [#1542](https://sourceforge.net/p/pmd/bugs/1542/): \[java] CPD throws an NPE when parsing enums with -ignore-identifiers
|
||||
* [#1545](https://sourceforge.net/p/pmd/bugs/1545/): \[java] Symbol Table fails to resolve inner classes
|
||||
* java-basic
|
||||
|
Reference in New Issue
Block a user