New J2K: do not merge methods if there are vararg parameters present
This commit is contained in:
@@ -48,6 +48,8 @@ class DefaultArgumentsConversion(context: NewJ2kConverterContext) : RecursiveApp
|
||||
|| callee.name != method.name.value
|
||||
|| calledMethod.returnType.type != method.returnType.type
|
||||
|| call.arguments.arguments.size <= method.parameters.size
|
||||
|| call.arguments.arguments.size < calledMethod.parameters.size //calledMethod has varargs param or call expr has errors
|
||||
|| calledMethod.parameters.any(JKParameter::isVarArgs)
|
||||
) {
|
||||
continue
|
||||
}
|
||||
@@ -141,7 +143,6 @@ class DefaultArgumentsConversion(context: NewJ2kConverterContext) : RecursiveApp
|
||||
}
|
||||
|
||||
return recurse(element)
|
||||
|
||||
}
|
||||
|
||||
private fun areTheSameExpressions(first: JKElement, second: JKElement): Boolean {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public final class Test {
|
||||
public static void checkState(boolean condition, String message, Object... args) {
|
||||
}
|
||||
|
||||
public static void checkState(boolean condition) {
|
||||
checkState(condition, "condition not met");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
object Test {
|
||||
fun checkState(condition: Boolean, message: String?, vararg args: Any?) {}
|
||||
fun checkState(condition: Boolean) {
|
||||
checkState(condition, "condition not met")
|
||||
}
|
||||
}
|
||||
+5
@@ -3591,6 +3591,11 @@ public class NewJavaToKotlinConverterSingleFileTestGenerated extends AbstractNew
|
||||
runTest("nj2k/testData/newJ2k/methodCallExpression/conflictJavaMethodCallWithExplicitImports.java");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParamsWithVararg.java")
|
||||
public void testDefaultParamsWithVararg() throws Exception {
|
||||
runTest("nj2k/testData/newJ2k/methodCallExpression/defaultParamsWithVararg.java");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyCall.java")
|
||||
public void testEmptyCall() throws Exception {
|
||||
runTest("nj2k/testData/newJ2k/methodCallExpression/emptyCall.java");
|
||||
|
||||
Reference in New Issue
Block a user