[FE 1.0] Don't use BuilderInferenceSubstitutionConstraintPosition for declared upper bound constraint with no substituted upper bound
It leads to further infer type variable into those upper bounds which is forbidden Substituted upper bounds is ok because specific substituted types came from constraints of other proper positions, or if specific substituted type is from declared upper bound too, then there should be another declared upper bound with no substitution ^KT-51464 Fixed ^KT-47986 Fixed
This commit is contained in:
committed by
teamcity
parent
c3b5d83f31
commit
848075192c
+30
@@ -14219,6 +14219,30 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986.kt")
|
||||
public void testKt47986() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_2.kt")
|
||||
public void testKt47986_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_3.kt")
|
||||
public void testKt47986_3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_4.kt")
|
||||
public void testKt47986_4() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_4.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49285.kt")
|
||||
public void testKt49285() throws Exception {
|
||||
@@ -14255,6 +14279,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51148.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51464.kt")
|
||||
public void testKt51464() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51464.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
+30
@@ -14219,6 +14219,30 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986.kt")
|
||||
public void testKt47986() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_2.kt")
|
||||
public void testKt47986_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_3.kt")
|
||||
public void testKt47986_3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_4.kt")
|
||||
public void testKt47986_4() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_4.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49285.kt")
|
||||
public void testKt49285() throws Exception {
|
||||
@@ -14255,6 +14279,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51148.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51464.kt")
|
||||
public void testKt51464() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51464.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
+30
@@ -14219,6 +14219,30 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986.kt")
|
||||
public void testKt47986() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_2.kt")
|
||||
public void testKt47986_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_3.kt")
|
||||
public void testKt47986_3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_4.kt")
|
||||
public void testKt47986_4() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_4.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49285.kt")
|
||||
public void testKt49285() throws Exception {
|
||||
@@ -14255,6 +14279,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51148.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51464.kt")
|
||||
public void testKt51464() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51464.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
+7
-1
@@ -589,11 +589,17 @@ class BuilderInferenceSession(
|
||||
|
||||
if (lowerSubstituted == a && upperSubstituted == b) return this
|
||||
|
||||
val resultingPosition = if (upperSubstituted == b && position is DeclaredUpperBoundConstraintPosition<*>) {
|
||||
position
|
||||
} else {
|
||||
BuilderInferenceSubstitutionConstraintPositionImpl(lambdaArgument, this)
|
||||
}
|
||||
|
||||
return InitialConstraint(
|
||||
lowerSubstituted,
|
||||
upperSubstituted,
|
||||
constraintKind,
|
||||
BuilderInferenceSubstitutionConstraintPositionImpl(lambdaArgument, this)
|
||||
resultingPosition
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo<K>
|
||||
|
||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||
|
||||
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||
|
||||
fun main() {
|
||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||
bar()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> buildFoo(/*0*/ builderAction: Foo<K>.() -> kotlin.Unit): Foo<K>
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ K> Foo<K>.bar(/*0*/ x: kotlin.Int = ...): kotlin.Unit
|
||||
|
||||
public final class Foo</*0*/ K> {
|
||||
public constructor Foo</*0*/ K>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo<K>
|
||||
|
||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||
|
||||
fun <L> Foo<L>.bar() {}
|
||||
|
||||
fun <K> id(x: K) = x
|
||||
|
||||
fun main() {
|
||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> { // can't infer
|
||||
val y = id(::bar)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> buildFoo(/*0*/ builderAction: Foo<K>.() -> kotlin.Unit): Foo<K>
|
||||
public fun </*0*/ K> id(/*0*/ x: K): K
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ L> Foo<L>.bar(): kotlin.Unit
|
||||
|
||||
public final class Foo</*0*/ K> {
|
||||
public constructor Foo</*0*/ K>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo<K>
|
||||
|
||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||
|
||||
fun <K: N, N> Foo<K>.bar(x: Int = 1) {}
|
||||
|
||||
fun main() {
|
||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||
bar()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> buildFoo(/*0*/ builderAction: Foo<K>.() -> kotlin.Unit): Foo<K>
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ K : N, /*1*/ N> Foo<K>.bar(/*0*/ x: kotlin.Int = ...): kotlin.Unit
|
||||
|
||||
public final class Foo</*0*/ K> {
|
||||
public constructor Foo</*0*/ K>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo<K>
|
||||
|
||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||
|
||||
class Bar<K>
|
||||
|
||||
fun <K: Bar<N>, N: Bar<K>> Foo<K>.bar(x: Int = 1) {}
|
||||
|
||||
fun main() {
|
||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||
bar()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> buildFoo(/*0*/ builderAction: Foo<K>.() -> kotlin.Unit): Foo<K>
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ K : Bar<N>, /*1*/ N : Bar<K>> Foo<K>.bar(/*0*/ x: kotlin.Int = ...): kotlin.Unit
|
||||
|
||||
public final class Bar</*0*/ K> {
|
||||
public constructor Bar</*0*/ K>()
|
||||
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 Foo</*0*/ K> {
|
||||
public constructor Foo</*0*/ K>()
|
||||
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
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import kotlinx.coroutines.flow.transform
|
||||
|
||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||
|
||||
interface FlowCollector<in T> {}
|
||||
|
||||
interface Flow<out T>
|
||||
|
||||
fun <T, R> Flow<T>.transform(transform: FlowCollector<R>.(T) -> Unit): Flow<R> = TODO()
|
||||
|
||||
fun f() {
|
||||
fun <T> doEmit(collector: FlowCollector<T>) {}
|
||||
flowOf(1).<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>transform<!> { doEmit(this) }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||
|
||||
interface FlowCollector<in T> {}
|
||||
|
||||
interface Flow<out T>
|
||||
|
||||
fun <T, R> Flow<T>.transform(transform: FlowCollector<R>.(T) -> Unit): Flow<R> = TODO()
|
||||
|
||||
fun f() {
|
||||
fun <T> doEmit(collector: FlowCollector<T>) {}
|
||||
flowOf(1).<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>transform<!> { doEmit(this) }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package
|
||||
|
||||
public fun f(): kotlin.Unit
|
||||
public fun </*0*/ T> flowOf(/*0*/ value: T): Flow<T>
|
||||
public fun </*0*/ T, /*1*/ R> Flow<T>.transform(/*0*/ transform: FlowCollector<R>.(T) -> kotlin.Unit): Flow<R>
|
||||
|
||||
public interface Flow</*0*/ out 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 interface FlowCollector</*0*/ in 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
|
||||
}
|
||||
Generated
+30
@@ -14225,6 +14225,30 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986.kt")
|
||||
public void testKt47986() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_2.kt")
|
||||
public void testKt47986_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_3.kt")
|
||||
public void testKt47986_3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47986_4.kt")
|
||||
public void testKt47986_4() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986_4.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49285.kt")
|
||||
public void testKt49285() throws Exception {
|
||||
@@ -14261,6 +14285,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51148.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51464.kt")
|
||||
public void testKt51464() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt51464.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user