diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 7573447fca..d9b55cf20d 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1794,7 +1794,7 @@ void FormalParameter() : } { ( "final" {jjtThis.setFinal(true);} | Annotation() )* - Type() ("|" Type())* + Type() // TODO there may be annotations before the "..." of the varargs // the ... is treated analogously to a pair of brackets // the sensible way to parse it would probably be to push an ArrayType with ArrayTypeDim for the "..." @@ -2999,7 +2999,7 @@ void UnionType() #UnionType(isUnion): // Annotations of the first class type belong to the // catch parameter (the variable) because of syntactic ambiguity // This is similar to how a local var type works. - ClassOrInterfaceType() ( "|" {isUnion=true; checkForBadMultipleExceptionsCatching();} AnnotatedClassOrInterfaceType() )* + ClassOrInterfaceType() ( "|" {isUnion=true;} AnnotatedClassOrInterfaceType() )* } void FinallyClause() : diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTFormalParameter.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTFormalParameter.java index 4b0bc86474..b7408a1c5a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTFormalParameter.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTFormalParameter.java @@ -11,16 +11,14 @@ import net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefin /** * Formal parameter node. Used in the {@link ASTFormalParameters} * production of {@link ASTMethodDeclarator} to represent a - * method's formal parameter. Also used in the {@link ASTCatchClause} - * production to represent the declared exception variable. - * Also used in LambdaExpressions for the LambdaParameters. + * method's formal parameter. * *
  *
- * FormalParameter ::= ( "final" | {@link ASTAnnotation Annotation} )* {@link ASTType Type} ( "|" {@link ASTType Type} )* [ "..." ] {@link ASTVariableDeclaratorId VariableDeclaratorId}
+ * FormalParameter ::= ( "final" | {@link ASTAnnotation Annotation} )* {@link ASTType Type} [ "..." ] {@link ASTVariableDeclaratorId VariableDeclaratorId}
  * 
*/ -public class ASTFormalParameter extends AbstractJavaAccessTypeNode implements Dimensionable { +public class ASTFormalParameter extends AbstractJavaAccessTypeNode implements Dimensionable, Annotatable { private boolean isVarargs; @@ -50,12 +48,12 @@ public class ASTFormalParameter extends AbstractJavaAccessTypeNode implements Di /** * If true, this formal parameter represents one without explit types. - * This can appear as part of a lambda expression with java11 using "var". * - * @see ASTVariableDeclaratorId#isTypeInferred() + * @deprecated Returns false always, since lambda expressions use {@link ASTLambdaParameter}. */ + @Deprecated public boolean isTypeInferred() { - return getTypeNode() == null; + return false; } @Override diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/MethodNameDeclaration.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/MethodNameDeclaration.java index 3f34afe72c..6d9e92d25f 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/MethodNameDeclaration.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/MethodNameDeclaration.java @@ -120,10 +120,8 @@ public class MethodNameDeclaration extends AbstractNameDeclaration { int hash = declaration.getName().hashCode() * 31 + declaration.getArity(); for (ASTFormalParameter myParam : declaration.getFormalParameters()) { - if (!myParam.isTypeInferred()) { - String myTypeImg = myParam.getTypeNode().getTypeImage(); - hash = hash * 31 + myTypeImg.hashCode(); - } + String myTypeImg = myParam.getTypeNode().getTypeImage(); + hash = hash * 31 + myTypeImg.hashCode(); } return hash;