Merge branch 'issue-309' into pmd/5.5.x
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.
|
* Provide a better fix for CastExpression, getting rid of most hacks.
|
||||||
* Bug #257
|
* Bug #257
|
||||||
*
|
*
|
||||||
@ -1839,7 +1844,7 @@ Token t;
|
|||||||
void MethodReference() :
|
void MethodReference() :
|
||||||
{Token t; checkForBadMethodReferenceUsage();}
|
{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() :
|
void PrimaryPrefix() :
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package net.sourceforge.pmd.lang.java.ast;
|
package net.sourceforge.pmd.lang.java.ast;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
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());
|
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
|
* This triggered bug #1484 UnusedLocalVariable - false positive - parenthesis
|
||||||
* @throws Exception
|
* @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
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,8 @@ The PMD team is pleased to announce PMD 5.5.5.
|
|||||||
|
|
||||||
* general:
|
* general:
|
||||||
* [#305](https://github.com/pmd/pmd/issues/305): \[core] PMD not executing under git bash
|
* [#305](https://github.com/pmd/pmd/issues/305): \[core] PMD not executing under git bash
|
||||||
|
* java
|
||||||
|
* [#309](https://github.com/pmd/pmd/issues/309): \[java] Parse error on method reference
|
||||||
* java-design
|
* java-design
|
||||||
* [#274](https://github.com/pmd/pmd/issues/274): \[java] AccessorMethodGeneration: Method inside static inner class incorrectly reported
|
* [#274](https://github.com/pmd/pmd/issues/274): \[java] AccessorMethodGeneration: Method inside static inner class incorrectly reported
|
||||||
* [#275](https://github.com/pmd/pmd/issues/275): \[java] FinalFieldCouldBeStatic: Constant in @interface incorrectly reported as "could be made static"
|
* [#275](https://github.com/pmd/pmd/issues/275): \[java] FinalFieldCouldBeStatic: Constant in @interface incorrectly reported as "could be made static"
|
||||||
|
Reference in New Issue
Block a user