KT-9461: Inference failed: type parameter fixed early

#KT-9461 Fixed
This commit is contained in:
Stanislav Erokhin
2015-10-05 17:11:15 +03:00
parent 493108eca1
commit b69197962d
4 changed files with 54 additions and 1 deletions
@@ -260,7 +260,7 @@ class GenericCandidateResolver(
return
}
}
val expectedTypeWithoutReturnType = if (hasExpectedReturnType) replaceReturnTypeByUnknown(expectedType) else expectedType
val expectedTypeWithoutReturnType = replaceReturnTypeByUnknown(expectedType)
val newContext = context.replaceExpectedType(expectedTypeWithoutReturnType).replaceDataFlowInfo(dataFlowInfoForArgument)
.replaceContextDependency(INDEPENDENT)
val type = argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type
@@ -0,0 +1,17 @@
interface In<in I>
interface B : In<B>
interface C<I, T>
fun <I, T> In<I>.foo(<!UNUSED_PARAMETER!>f<!>: () -> C<I, T>) {}
fun <I, T, Self: In<I>> Self.foo2(<!UNUSED_PARAMETER!>f<!>: () -> C<I, T>) {}
class E : B // e <: In<B> <: In<E>
fun test(c: C<E, Int>, e: E) {
e.foo<E, Int> { c }
e.foo { c } // error here: expected C<B, ???> but must be C<??? : B, ???>
e.foo2 { c }
e.foo2 ({ c })
}
@@ -0,0 +1,30 @@
package
public fun test(/*0*/ c: C<E, kotlin.Int>, /*1*/ e: E): kotlin.Unit
public fun </*0*/ I, /*1*/ T> In<I>.foo(/*0*/ f: () -> C<I, T>): kotlin.Unit
public fun </*0*/ I, /*1*/ T, /*2*/ Self : In<I>> Self.foo2(/*0*/ f: () -> C<I, T>): kotlin.Unit
public interface B : In<B> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C</*0*/ I, /*1*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class E : B {
public constructor E()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface In</*0*/ in I> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -7796,6 +7796,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("kt9461.kt")
public void testKt9461() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt9461.kt");
doTest(fileName);
}
@TestMetadata("kt948.kt")
public void testKt948() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt948.kt");