[NI] Remove deep types in commosn super type for recursive types
#KT-30411 Fixed
This commit is contained in:
+5
@@ -9703,6 +9703,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveTypes.kt")
|
||||
public void testRecursiveTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt")
|
||||
public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
|
||||
|
||||
+8
-1
@@ -212,7 +212,14 @@ object NewCommonSuperTypeCalculator {
|
||||
if (thereIsStar || typeProjections.isEmpty()) {
|
||||
createStarProjection(parameter)
|
||||
} else {
|
||||
calculateArgument(parameter, typeProjections, depth)
|
||||
val argument = calculateArgument(parameter, typeProjections, depth)
|
||||
val argumentType = argument.getType().asSimpleType()
|
||||
val argumentConstructor = argumentType?.typeConstructor()
|
||||
if (argument.getVariance() == TypeVariance.OUT && argumentConstructor == constructor && argumentType.asArgumentList()[index].isStarProjection()) {
|
||||
createStarProjection(parameter)
|
||||
} else {
|
||||
argument
|
||||
}
|
||||
}
|
||||
|
||||
arguments.add(argument)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val x: kotlin.Enum<out kotlin.Enum<out kotlin.Enum<out kotlin.Enum<out kotlin.Enum<out kotlin.Enum<*>>>>>>
|
||||
public val x: kotlin.Enum<*>
|
||||
|
||||
public final enum class A : kotlin.Enum<A> {
|
||||
enum entry A
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
interface RecursiveGeneric<T : RecursiveGeneric<T, U>, U>
|
||||
|
||||
class A : RecursiveGeneric<A, Int>
|
||||
class B : RecursiveGeneric<B, Int>
|
||||
class C : RecursiveGeneric<C, Unit>
|
||||
|
||||
fun <K> select(x: K, y: K): K = x
|
||||
|
||||
fun foo(a: A, b: B, c: C) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("RecursiveGeneric<*, kotlin.Int>")!>select(a, b)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("RecursiveGeneric<*, out kotlin.Any>")!>select(a, c)<!>
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ a: A, /*1*/ b: B, /*2*/ c: C): kotlin.Unit
|
||||
public fun </*0*/ K> select(/*0*/ x: K, /*1*/ y: K): K
|
||||
|
||||
public final class A : RecursiveGeneric<A, kotlin.Int> {
|
||||
public constructor A()
|
||||
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 B : RecursiveGeneric<B, kotlin.Int> {
|
||||
public constructor 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 final class C : RecursiveGeneric<C, kotlin.Unit> {
|
||||
public constructor C()
|
||||
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 RecursiveGeneric</*0*/ T : RecursiveGeneric<T, U>, /*1*/ U> {
|
||||
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
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -9710,6 +9710,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveTypes.kt")
|
||||
public void testRecursiveTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt")
|
||||
public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
|
||||
|
||||
Generated
+5
@@ -9705,6 +9705,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveTypes.kt")
|
||||
public void testRecursiveTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt")
|
||||
public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
|
||||
|
||||
Reference in New Issue
Block a user