Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ private boolean hasAmbiguousConstructors(J.NewClass newClass) {
if (newClass.getArguments().isEmpty() || newClass.getConstructorType() == null) {
return false;
}

JavaType.FullyQualified type = TypeUtils.asFullyQualified(newClass.getType());
if (type == null) {
return false;
}

// Check if any argument contains a lambda or method reference
boolean hasLambdaOrMethodRef = false;
for (Expression arg : newClass.getArguments()) {
Expand All @@ -287,16 +287,16 @@ private boolean hasAmbiguousConstructors(J.NewClass newClass) {
break;
}
}

// If no lambdas/method references, no ambiguity
if (!hasLambdaOrMethodRef) {
return false;
}

// Check if there are multiple constructors with the same number of parameters
int argCount = newClass.getArguments().size();
int constructorsWithSameArgCount = 0;

for (JavaType.Method method : type.getMethods()) {
if (method.isConstructor() && method.getParameterTypes().size() == argCount) {
constructorsWithSameArgCount++;
Expand All @@ -306,7 +306,7 @@ private boolean hasAmbiguousConstructors(J.NewClass newClass) {
}
}
}

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.openrewrite.staticanalysis.groovy;

import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.ExpectedToFail;
import org.openrewrite.DocumentExample;
import org.openrewrite.Issue;
import org.openrewrite.staticanalysis.MinimumSwitchCases;
Expand Down