#1429 Java - Parse Error: Cast in return expression
This commit is contained in:
@ -1,4 +1,9 @@
|
||||
/**
|
||||
* Fix for Cast Expression not detected properly in Return statements
|
||||
* Bug #1429
|
||||
*
|
||||
* Andreas Dangel 10/2015
|
||||
*====================================================================
|
||||
* Fix for Lambda expressions without variables.
|
||||
*
|
||||
* Andreas Dangel 11/2014
|
||||
@ -1725,6 +1730,7 @@ void UnaryExpressionNotPlusMinus() #UnaryExpressionNotPlusMinus((jjtn000.getImag
|
||||
{
|
||||
( "~" {jjtThis.setImage("~");} | "!" {jjtThis.setImage("!");} ) UnaryExpression()
|
||||
| LOOKAHEAD( CastExpression() ) CastExpression()
|
||||
| LOOKAHEAD("(" Type() ")" "(") CastExpression()
|
||||
| PostfixExpression()
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,12 @@ public class ParserCornersTest extends ParserTst {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug1429ParseError() throws Exception {
|
||||
String c = IOUtils.toString(this.getClass().getResourceAsStream("Bug1429.java"));
|
||||
parseJava18(c);
|
||||
}
|
||||
|
||||
private String readAsString(String resource) {
|
||||
InputStream in = ParserCornersTest.class.getResourceAsStream(resource);
|
||||
try {
|
||||
|
@ -0,0 +1,18 @@
|
||||
public class Bug1429 {
|
||||
public Set<String> getAttributeTuples() {
|
||||
return (Set<String>) (this.attributes == null ? Collections.<String> emptySet() : new HashSet<String>(
|
||||
CollectionUtils.collect(this.attributes.keySet(), new Transformer() {
|
||||
@Override
|
||||
public Object transform(final Object obj) {
|
||||
final String key = (String) obj;
|
||||
final String value = HGXLIFFTypeConfiguration.this.attributes.get(key);
|
||||
|
||||
String result = key;
|
||||
if (StringUtils.isNotEmpty(value)) {
|
||||
result = result.concat(":").concat(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
})));
|
||||
}
|
||||
}
|
@ -12,4 +12,6 @@
|
||||
|
||||
**Bugfixes:**
|
||||
|
||||
* [#1429](https://sourceforge.net/p/pmd/bugs/1429/): Java - Parse Error: Cast in return expression
|
||||
|
||||
**API Changes:**
|
||||
|
Reference in New Issue
Block a user