Skip to content

Commit

Permalink
Fix SortCompilationUnitElementsTests.test012
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <[email protected]>
  • Loading branch information
Rob Stryker committed Mar 26, 2024
1 parent a8b2a67 commit abe8942
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,19 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent)
String javacName = javac.getName().toString();
String methodDeclName = getMethodDeclName(javac, parent);
boolean methodDeclNameMatchesInit = Objects.equals(methodDeclName, Names.instance(this.context).init.toString());
boolean javacNameMatchesInitAndMethodNameMatchesTypeName = javacName.equals("<init>") && methodDeclName.equals(getNodeName(parent));
boolean javacNameMatchesInit = javacName.equals("<init>");
boolean javacNameMatchesInitAndMethodNameMatchesTypeName = javacNameMatchesInit && methodDeclName.equals(getNodeName(parent));
boolean isConstructor = methodDeclNameMatchesInit || javacNameMatchesInitAndMethodNameMatchesTypeName;

res.setConstructor(isConstructor);
boolean malformed = false;
if(isConstructor && !javacNameMatchesInitAndMethodNameMatchesTypeName) {
malformed = true;
}
if( javacNameMatchesInit && !isConstructor ) {
malformed = true;
}

if( malformed ) {
res.setFlags(res.getFlags() | ASTNode.MALFORMED);
}
Expand Down

0 comments on commit abe8942

Please sign in to comment.