Drop unneeded condition that leads to error
This check is obsolete but leads to problems. It appears when resolving recursive calls (see sameTypeParameterUse.kt): `foo<R>(x: R, y: R)` within call `foo<R>(x, "")` after substitution has R as type of it's second argument, and when checking value arguments, x is not checked because supposed to be dependent on type parameter of candidate (that is effectively false), so there are two successful candidates in resolution results and wrong OVERLOAD_RESOLUTION_AMBIGUITY error.
This commit is contained in:
@@ -516,9 +516,6 @@ public class CandidateResolver {
|
||||
if (expression == null) continue;
|
||||
|
||||
JetType expectedType = getEffectiveExpectedType(parameterDescriptor, argument);
|
||||
if (TypeUtils.dependsOnTypeParameters(expectedType, candidateCall.getCandidateDescriptor().getTypeParameters())) {
|
||||
expectedType = NO_EXPECTED_TYPE;
|
||||
}
|
||||
|
||||
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument))
|
||||
.replaceBindingTrace(trace).replaceExpectedType(expectedType);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
fun <R> foo(x: R, y: String) {}
|
||||
fun <R> foo(x: R, y: R) {
|
||||
foo<R>(x, "") // ok, resolved foo(x: R, y: String)
|
||||
foo(x, "") // ok, foo(x: R, y: String)
|
||||
foo<R>(x, x) // ok, resolved foo(x: R, y: R)
|
||||
foo(x, x) // ok, resolved foo(x: R, y: R)
|
||||
}
|
||||
|
||||
class Q<R>(x: R) {
|
||||
fun foo() {
|
||||
Q<R>("")
|
||||
}
|
||||
}
|
||||
fun <R> Q(x: String) {}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
internal fun </*0*/ R> Q(/*0*/ x: kotlin.String): kotlin.Unit
|
||||
internal fun </*0*/ R> foo(/*0*/ x: R, /*1*/ y: R): kotlin.Unit
|
||||
internal fun </*0*/ R> foo(/*0*/ x: R, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
|
||||
internal final class Q</*0*/ R> {
|
||||
public constructor Q</*0*/ R>(/*0*/ x: R)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
internal final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -5095,6 +5095,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sameTypeParameterUse.kt")
|
||||
public void testSameTypeParameterUse() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/sameTypeParameterUse.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/generics/starProjections")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user