Potential fix for some random errors about "cannot choose between equals invoke functions".
This commit is contained in:
+6
-3
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.lang.AssertionError
|
||||
import java.util.*
|
||||
|
||||
class OverloadingConflictResolver<C : Any>(
|
||||
@@ -63,7 +64,7 @@ class OverloadingConflictResolver<C : Any>(
|
||||
if (candidates.size == 1) return candidates
|
||||
|
||||
val fixedCandidates = if (getVariableCandidates(candidates.first()) != null) {
|
||||
findMaximallySpecificVariableAsFunctionCalls(candidates) ?: return candidates
|
||||
findMaximallySpecificVariableAsFunctionCalls(candidates, isDebuggerContext) ?: return candidates
|
||||
}
|
||||
else {
|
||||
candidates
|
||||
@@ -137,13 +138,15 @@ class OverloadingConflictResolver<C : Any>(
|
||||
}
|
||||
|
||||
// null means ambiguity between variables
|
||||
private fun findMaximallySpecificVariableAsFunctionCalls(candidates: Set<C>): Set<C>? {
|
||||
private fun findMaximallySpecificVariableAsFunctionCalls(candidates: Set<C>, isDebuggerContext: Boolean): Set<C>? {
|
||||
val variableCalls = candidates.mapTo(newResolvedCallSet(candidates.size)) {
|
||||
getVariableCandidates(it) ?: throw AssertionError("Regular call among variable-as-function calls: $it")
|
||||
}
|
||||
|
||||
val maxSpecificVariableCall = findMaximallySpecificCall(variableCalls, false, false) ?: return null
|
||||
val maxSpecificVariableCalls = chooseMaximallySpecificCandidates(variableCalls, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
isDebuggerContext = isDebuggerContext, discriminateGenerics = false)
|
||||
|
||||
val maxSpecificVariableCall = maxSpecificVariableCalls.singleOrNull() ?: return null
|
||||
return candidates.filterTo(newResolvedCallSet(2)) {
|
||||
getVariableCandidates(it)!!.resultingDescriptor == maxSpecificVariableCall.resultingDescriptor
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/test.kt] => [[Temp]/test.jar]
|
||||
[exec] 6
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,12 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/test.kt" classpath="${test.data}/valInside.jar" output="${temp}/test.jar" nowarn="true" />
|
||||
|
||||
<exec executable="java">
|
||||
<arg line="-classpath ${temp}/test.jar bar.TestKt"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,10 @@
|
||||
package bar
|
||||
|
||||
@Suppress("REDECLARATION")
|
||||
val foo: Int = 6
|
||||
|
||||
operator fun Int.invoke() = this
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(foo())
|
||||
}
|
||||
Binary file not shown.
@@ -131,6 +131,12 @@ public class AntTaskTestGenerated extends AbstractAntTaskTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valWithInvoke")
|
||||
public void testValWithInvoke() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/valWithInvoke/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("verbose")
|
||||
public void testVerbose() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/verbose/");
|
||||
|
||||
Reference in New Issue
Block a user