[java] Support generics in method references
- Fixes #207 - Extend the Java grammar to support generics in method references: `Type::<Generic>method`
This commit is contained in:
Juan Martín Sotuyo Dodero
committed by
Andreas Dangel
parent
c63347508e
commit
33fd84d521
@ -1,4 +1,9 @@
|
||||
/**
|
||||
* Allow method references to specify generics.
|
||||
* Bug #207
|
||||
*
|
||||
* Juan Martin Sotuyo Dodero 01/2017
|
||||
*====================================================================
|
||||
* Fix for regression introduced in previous changeset.
|
||||
* The syntactic lookahead was not properly handled by javacc,
|
||||
* so it was converted to a semantic one
|
||||
@ -1806,7 +1811,7 @@ Token t;
|
||||
void MethodReference() :
|
||||
{Token t; checkForBadMethodReferenceUsage();}
|
||||
{
|
||||
"::" ("new" {jjtThis.setImage("new");} | t=<IDENTIFIER> {jjtThis.setImage(t.image);} )
|
||||
"::" ("new" {jjtThis.setImage("new");} | [TypeArguments()] t=<IDENTIFIER> {jjtThis.setImage(t.image);} )
|
||||
}
|
||||
|
||||
void PrimaryPrefix() :
|
||||
|
@ -136,6 +136,12 @@ public class ParserCornersTest extends ParserTst {
|
||||
String c = IOUtils.toString(this.getClass().getResourceAsStream("Bug1530.java"));
|
||||
parseJava18(c);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubBug207() throws Exception {
|
||||
String c = IOUtils.toString(this.getClass().getResourceAsStream("GitHubBug207.java"));
|
||||
parseJava18(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* This triggered bug #1484 UnusedLocalVariable - false positive - parenthesis
|
||||
|
@ -0,0 +1,5 @@
|
||||
public class GitHubBug207 {
|
||||
private static HttpMessageWriter<Resource> resourceHttpMessageWriter(BodyInserter.Context context) {
|
||||
return context.map(BodyInserters::<Resource>cast);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user