Prevent recursion on captured recursive type parameters of inner classes during computing bound for them
^KT-47459 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
e071281b20
commit
ad89d43186
+6
@@ -21442,6 +21442,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47459.kt")
|
||||||
|
public void testKt47459() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/kt47459.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nonGenericRawMember.kt")
|
@TestMetadata("nonGenericRawMember.kt")
|
||||||
public void testNonGenericRawMember() throws Exception {
|
public void testNonGenericRawMember() throws Exception {
|
||||||
|
|||||||
+6
@@ -21442,6 +21442,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47459.kt")
|
||||||
|
public void testKt47459() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/kt47459.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nonGenericRawMember.kt")
|
@TestMetadata("nonGenericRawMember.kt")
|
||||||
public void testNonGenericRawMember() throws Exception {
|
public void testNonGenericRawMember() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// FILE: MapObjectManager.java
|
||||||
|
abstract class MapObjectManager<C extends MapObjectManager.Collection> {
|
||||||
|
public class Collection {
|
||||||
|
|
||||||
|
}
|
||||||
|
public C getCollection(String id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: MarkerManager.java
|
||||||
|
public class MarkerManager extends MapObjectManager<MarkerManager.Collection> {
|
||||||
|
public class Collection extends MapObjectManager.Collection {
|
||||||
|
public void setOnMarkerClickListener() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun foo(markerManager: MarkerManager) {
|
||||||
|
val test: MarkerManager.Collection = markerManager.getCollection("FOO")!!
|
||||||
|
test.setOnMarkerClickListener()
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun foo(/*0*/ markerManager: MarkerManager): kotlin.Unit
|
||||||
|
|
||||||
|
public/*package*/ abstract class MapObjectManager</*0*/ C : MapObjectManager<(raw) MapObjectManager<*>.Collection>.Collection!> {
|
||||||
|
public/*package*/ constructor MapObjectManager</*0*/ C : MapObjectManager<(raw) MapObjectManager<*>.Collection>.Collection!>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun getCollection(/*0*/ id: kotlin.String!): C!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public open inner class Collection /*captured type parameters: /*0*/ C : MapObjectManager<(raw) MapObjectManager<*>.Collection>.Collection!*/ {
|
||||||
|
public constructor Collection()
|
||||||
|
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 open class MarkerManager : MapObjectManager<MarkerManager.Collection!> {
|
||||||
|
public constructor MarkerManager()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun getCollection(/*0*/ id: kotlin.String!): MarkerManager.Collection!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public open inner class Collection : MapObjectManager<(raw) MapObjectManager<*>.Collection!>.Collection {
|
||||||
|
public constructor Collection()
|
||||||
|
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 fun setOnMarkerClickListener(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -21448,6 +21448,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47459.kt")
|
||||||
|
public void testKt47459() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/kt47459.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nonGenericRawMember.kt")
|
@TestMetadata("nonGenericRawMember.kt")
|
||||||
public void testNonGenericRawMember() throws Exception {
|
public void testNonGenericRawMember() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -346,7 +346,7 @@ internal fun TypeParameterDescriptor.getErasedUpperBound(
|
|||||||
): KotlinType {
|
): KotlinType {
|
||||||
val visitedTypeParameters = typeAttr.visitedTypeParameters
|
val visitedTypeParameters = typeAttr.visitedTypeParameters
|
||||||
|
|
||||||
if (visitedTypeParameters != null && this in visitedTypeParameters) return defaultValue()
|
if (visitedTypeParameters != null && original in visitedTypeParameters) return defaultValue()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should do erasure of containing type parameters with their erasure to avoid creating inconsistent types.
|
* We should do erasure of containing type parameters with their erasure to avoid creating inconsistent types.
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ private fun KotlinType.extractTypeParametersFromUpperBounds(
|
|||||||
} else {
|
} else {
|
||||||
val typeParameters = (constructor.declarationDescriptor as? ClassifierDescriptorWithTypeParameters)?.declaredTypeParameters
|
val typeParameters = (constructor.declarationDescriptor as? ClassifierDescriptorWithTypeParameters)?.declaredTypeParameters
|
||||||
for ((i, argument) in arguments.withIndex()) {
|
for ((i, argument) in arguments.withIndex()) {
|
||||||
val typeParameter = typeParameters?.get(i)
|
val typeParameter = typeParameters?.getOrNull(i) // TODO: support inner classes' type parameters
|
||||||
val isTypeParameterVisited = typeParameter != null && visitedTypeParameters != null && typeParameter in visitedTypeParameters
|
val isTypeParameterVisited = typeParameter != null && visitedTypeParameters != null && typeParameter in visitedTypeParameters
|
||||||
if (isTypeParameterVisited || argument.isStarProjection) continue
|
if (isTypeParameterVisited || argument.isStarProjection) continue
|
||||||
if (argument.type.constructor.declarationDescriptor in to || argument.type.constructor == baseType.constructor) continue
|
if (argument.type.constructor.declarationDescriptor in to || argument.type.constructor == baseType.constructor) continue
|
||||||
|
|||||||
+12
@@ -21436,6 +21436,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("intermediateRecursion.kt")
|
||||||
|
public void testIntermediateRecursion() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/intermediateRecursion.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47459.kt")
|
||||||
|
public void testKt47459() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/kt47459.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nonGenericRawMember.kt")
|
@TestMetadata("nonGenericRawMember.kt")
|
||||||
public void testNonGenericRawMember() throws Exception {
|
public void testNonGenericRawMember() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user