Prevent leaking of type parameter erasion results cache into static scope
This commit is contained in:
committed by
teamcityserver
parent
6706ee87ad
commit
20d50cfee7
+12
@@ -21826,6 +21826,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParameters.kt")
|
||||||
|
public void testInterdependentTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParametersFromKotlin.kt")
|
||||||
|
public void testInterdependentTypeParametersFromKotlin() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParametersFromKotlin.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateRecursion.kt")
|
@TestMetadata("intermediateRecursion.kt")
|
||||||
public void testIntermediateRecursion() throws Exception {
|
public void testIntermediateRecursion() throws Exception {
|
||||||
|
|||||||
+12
@@ -21826,6 +21826,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParameters.kt")
|
||||||
|
public void testInterdependentTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParametersFromKotlin.kt")
|
||||||
|
public void testInterdependentTypeParametersFromKotlin() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParametersFromKotlin.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateRecursion.kt")
|
@TestMetadata("intermediateRecursion.kt")
|
||||||
public void testIntermediateRecursion() throws Exception {
|
public void testIntermediateRecursion() throws Exception {
|
||||||
|
|||||||
+3
-6
@@ -1,4 +1,4 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// TARGET_BACKEND: JVM
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
|
||||||
// FILE: AbstractAssert.java
|
// FILE: AbstractAssert.java
|
||||||
@@ -61,11 +61,9 @@ extends AbstractAssertWithOriginWithColumnsAndRows<S, A, D, A, C, CV, R, RV> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FILE: AbstractValueAssert.java
|
// FILE: AbstractValueAssert.java
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
public abstract class AbstractValueAssert<D extends AbstractDbData<D>, A extends AbstractDbAssert<D, A, C, CV, R, RV>, S extends AbstractSubAssert<D, A, S, V, C, CV, R, RV>, V extends AbstractValueAssert<D, A, S, V, C, CV, R, RV>, C extends AbstractColumnAssert<D, A, C, CV, R, RV>, CV extends AbstractColumnValueAssert<D, A, C, CV, R, RV>, R extends AbstractRowAssert<D, A, C, CV, R, RV>, RV extends AbstractRowValueAssert<D, A, C, CV, R, RV>>
|
public abstract class AbstractValueAssert<D extends AbstractDbData<D>, A extends AbstractDbAssert<D, A, C, CV, R, RV>, S extends AbstractSubAssert<D, A, S, V, C, CV, R, RV>, V extends AbstractValueAssert<D, A, S, V, C, CV, R, RV>, C extends AbstractColumnAssert<D, A, C, CV, R, RV>, CV extends AbstractColumnValueAssert<D, A, C, CV, R, RV>, R extends AbstractRowAssert<D, A, C, CV, R, RV>, RV extends AbstractRowValueAssert<D, A, C, CV, R, RV>>
|
||||||
extends AbstractAssertWithOriginWithColumnsAndRows<V, S, D, A, C, CV, R, RV> {
|
extends AbstractAssertWithOriginWithColumnsAndRows<V, S, D, A, C, CV, R, RV> {
|
||||||
public V isEqualTo(LocalDateTime expected) {
|
public V isEqualTo(String expected) {
|
||||||
return (V) new RequestRowValueAssert();
|
return (V) new RequestRowValueAssert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,10 +113,9 @@ public interface RowElement {}
|
|||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
fun test(x: RequestAssert) {
|
fun test(x: RequestAssert) {
|
||||||
val timestamp = LocalDateTime.now()
|
|
||||||
x.hasNumberOfRows(1)
|
x.hasNumberOfRows(1)
|
||||||
.row()
|
.row()
|
||||||
.value("message_time").isEqualTo(timestamp)
|
.value("message_time").isEqualTo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// FILE: Boo.java
|
||||||
|
public class Boo<N> {}
|
||||||
|
|
||||||
|
// FILE: Foo.java
|
||||||
|
public class Foo<P1 extends Boo<P2, P3, P4>, P2 extends Boo<P1, P3, P4>, P3 extends Boo<P1, P2, P4>, P4 extends Boo<P1, P2, P3>> {
|
||||||
|
static Foo test1() { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main() {
|
||||||
|
val x = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Boo<*>..Boo<*>?!, Boo<*>..Boo<*>?!, Boo<*>..Boo<*>?!, Boo<*>..Boo<*>?!>..Foo<*, *, *, *>?!")!>Foo.test1()<!>
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// FILE: Boo.java
|
||||||
|
public class Boo<N> {}
|
||||||
|
|
||||||
|
// FILE: Foo.java
|
||||||
|
public class Foo<P1 extends Boo<P2, P3, P4>, P2 extends Boo<P1, P3, P4>, P3 extends Boo<P1, P2, P4>, P4 extends Boo<P1, P2, P3>> {
|
||||||
|
static Foo test1() { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main() {
|
||||||
|
val x = <!DEBUG_INFO_EXPRESSION_TYPE("raw (Foo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?), (Boo<*>..Boo<*>?), (Boo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?)>..Boo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?)>?), (Boo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?)>..Boo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?)>?)>..Foo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?), out (Boo<*>..Boo<*>?), out (Boo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?)>..Boo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?)>?), out (Boo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?)>..Boo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?)>?)>?)")!>Foo.test1()<!>
|
||||||
|
}
|
||||||
Vendored
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public open class Boo</*0*/ N : kotlin.Any!> {
|
||||||
|
public constructor Boo</*0*/ N : kotlin.Any!>()
|
||||||
|
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 Foo</*0*/ P1 : Boo<P2!>!, /*1*/ P2 : Boo<P1!>!, /*2*/ P3 : Boo<P1!>!, /*3*/ P4 : Boo<P1!>!> {
|
||||||
|
public constructor Foo</*0*/ P1 : Boo<P2!>!, /*1*/ P2 : Boo<P1!>!, /*2*/ P3 : Boo<P1!>!, /*3*/ P4 : Boo<P1!>!>()
|
||||||
|
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
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ open fun test1(): (Foo<(raw) Boo<Boo<*>!>!, (raw) Boo<*>!, (raw) Boo<Boo<Boo<*>!>!>!, (raw) Boo<Boo<Boo<*>!>!>!>..Foo<out Boo<out Boo<*>!>!, out Boo<*>!, out Boo<out Boo<out Boo<*>!>!>!, out Boo<out Boo<out Boo<*>!>!>!>?)
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// FILE: Boo.java
|
||||||
|
public class Boo<P2, P3, P4> {
|
||||||
|
static Foo test1() { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Foo.kt
|
||||||
|
class Foo<P1 : Boo<P2, P3, P4>, P2 : Boo<P1, P3, P4>, P3 : Boo<P1, P2, P4>, P4 : Boo<P1, P2, P3>> {}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main() {
|
||||||
|
val x = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Boo<*, *, *>, Boo<*, *, *>, Boo<*, *, *>, Boo<*, *, *>>..Foo<out Boo<*, *, *>, out Boo<*, *, *>, out Boo<*, *, *>, out Boo<*, *, *>>?!")!>Boo.test1()<!>
|
||||||
|
}
|
||||||
compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParametersFromKotlin.kt
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// FILE: Boo.java
|
||||||
|
public class Boo<P2, P3, P4> {
|
||||||
|
static Foo test1() { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Foo.kt
|
||||||
|
class Foo<P1 : Boo<P2, P3, P4>, P2 : Boo<P1, P3, P4>, P3 : Boo<P1, P2, P4>, P4 : Boo<P1, P2, P3>> {}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main() {
|
||||||
|
val x = <!DEBUG_INFO_EXPRESSION_TYPE("raw (Foo<Boo<Boo<*, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>, Boo<*, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>..Foo<out Boo<out Boo<*, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>, out Boo<*, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>?)")!>Boo.test1()<!>
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
public open class Boo</*0*/ P2 : kotlin.Any!, /*1*/ P3 : kotlin.Any!, /*2*/ P4 : kotlin.Any!> {
|
||||||
|
public constructor Boo</*0*/ P2 : kotlin.Any!, /*1*/ P3 : kotlin.Any!, /*2*/ P4 : kotlin.Any!>()
|
||||||
|
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
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public/*package*/ open fun test1(): (Foo<(raw) Boo<Boo<*, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>, (raw) Boo<*, Boo<*, *, Boo<*, *, *>>, Boo<*, *, *>>, (raw) Boo<*, *, Boo<*, *, *>>, (raw) Boo<*, *, *>>..Foo<out Boo<out Boo<*, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>, out Boo<*, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>, out Boo<*, *, out Boo<*, *, *>>, out Boo<*, *, *>>?)
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Foo</*0*/ P1 : Boo<P2, P3, P4>, /*1*/ P2 : Boo<P1, P3, P4>, /*2*/ P3 : Boo<P1, P2, P4>, /*3*/ P4 : Boo<P1, P2, P3>> {
|
||||||
|
public constructor Foo</*0*/ P1 : Boo<P2, P3, P4>, /*1*/ P2 : Boo<P1, P3, P4>, /*2*/ P3 : Boo<P1, P2, P4>, /*3*/ P4 : Boo<P1, P2, P3>>()
|
||||||
|
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
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// FILE: Boo.java
|
||||||
|
public class Boo<N> {}
|
||||||
|
|
||||||
|
// FILE: Foo.java
|
||||||
|
public class Foo<T extends Boo<K>, K extends Boo<X>, X extends Boo<K>> {
|
||||||
|
T test2() { return null; }
|
||||||
|
static Foo test1() { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main() {
|
||||||
|
val x = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Boo<*>..Boo<*>?!, Boo<*>..Boo<*>?!, Boo<*>..Boo<*>?!>..Foo<*, *, *>?!")!>Foo.test1()<!>.test2()
|
||||||
|
}
|
||||||
+1
-2
@@ -1,4 +1,3 @@
|
|||||||
// FIR_IDENTICAL
|
|
||||||
// FILE: Boo.java
|
// FILE: Boo.java
|
||||||
public class Boo<N> {}
|
public class Boo<N> {}
|
||||||
|
|
||||||
@@ -10,5 +9,5 @@ public class Foo<T extends Boo<K>, K extends Boo<X>, X extends Boo<K>> {
|
|||||||
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main() {
|
fun main() {
|
||||||
val x = Foo.test1().test2()
|
val x = <!DEBUG_INFO_EXPRESSION_TYPE("raw (Foo<(Boo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?)>..Boo<(Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?)>?), (Boo<(Boo<*>..Boo<*>?)>..Boo<(Boo<*>..Boo<*>?)>?), (Boo<*>..Boo<*>?)>..Foo<out (Boo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?)>..Boo<out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?)>?), out (Boo<out (Boo<*>..Boo<*>?)>..Boo<out (Boo<*>..Boo<*>?)>?), out (Boo<*>..Boo<*>?)>?)")!>Foo.test1()<!>.test2()
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+12
@@ -21832,6 +21832,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interClassesRecursion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParameters.kt")
|
||||||
|
public void testInterdependentTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParametersFromKotlin.kt")
|
||||||
|
public void testInterdependentTypeParametersFromKotlin() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParametersFromKotlin.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateRecursion.kt")
|
@TestMetadata("intermediateRecursion.kt")
|
||||||
public void testIntermediateRecursion() throws Exception {
|
public void testIntermediateRecursion() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ class ErasedOverridabilityCondition : ExternalOverridabilityCondition {
|
|||||||
|
|
||||||
if (signatureTypes.any { it.arguments.isNotEmpty() && it.unwrap() !is RawTypeImpl }) return Result.UNKNOWN
|
if (signatureTypes.any { it.arguments.isNotEmpty() && it.unwrap() !is RawTypeImpl }) return Result.UNKNOWN
|
||||||
|
|
||||||
var erasedSuper = superDescriptor.substitute(RawSubstitution.buildSubstitutor()) ?: return Result.UNKNOWN
|
var erasedSuper = superDescriptor.substitute(RawSubstitution().buildSubstitutor()) ?: return Result.UNKNOWN
|
||||||
|
|
||||||
if (erasedSuper is SimpleFunctionDescriptor && erasedSuper.typeParameters.isNotEmpty()) {
|
if (erasedSuper is SimpleFunctionDescriptor && erasedSuper.typeParameters.isNotEmpty()) {
|
||||||
// Only simple functions are supported now for erased overrides
|
// Only simple functions are supported now for erased overrides
|
||||||
|
|||||||
+3
-2
@@ -41,7 +41,8 @@ class JavaTypeResolver(
|
|||||||
private val c: LazyJavaResolverContext,
|
private val c: LazyJavaResolverContext,
|
||||||
private val typeParameterResolver: TypeParameterResolver
|
private val typeParameterResolver: TypeParameterResolver
|
||||||
) {
|
) {
|
||||||
val typeParameterUpperBoundEraser = TypeParameterUpperBoundEraser()
|
private val typeParameterUpperBoundEraser = TypeParameterUpperBoundEraser()
|
||||||
|
private val rawSubstitution = RawSubstitution(typeParameterUpperBoundEraser)
|
||||||
|
|
||||||
fun transformJavaType(javaType: JavaType?, attr: JavaTypeAttributes): KotlinType {
|
fun transformJavaType(javaType: JavaType?, attr: JavaTypeAttributes): KotlinType {
|
||||||
return when (javaType) {
|
return when (javaType) {
|
||||||
@@ -237,7 +238,7 @@ class JavaTypeResolver(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
RawSubstitution.computeProjection(
|
rawSubstitution.computeProjection(
|
||||||
parameter,
|
parameter,
|
||||||
// if erasure happens due to invalid arguments number, use star projections instead
|
// if erasure happens due to invalid arguments number, use star projections instead
|
||||||
if (isRaw) attr else attr.withFlexibility(INFLEXIBLE),
|
if (isRaw) attr else attr.withFlexibility(INFLEXIBLE),
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class RawTypeImpl private constructor(lowerBound: SimpleType, upperBound: Simple
|
|||||||
get() {
|
get() {
|
||||||
val classDescriptor = constructor.declarationDescriptor as? ClassDescriptor
|
val classDescriptor = constructor.declarationDescriptor as? ClassDescriptor
|
||||||
?: error("Incorrect classifier: ${constructor.declarationDescriptor}")
|
?: error("Incorrect classifier: ${constructor.declarationDescriptor}")
|
||||||
return classDescriptor.getMemberScope(RawSubstitution)
|
return classDescriptor.getMemberScope(RawSubstitution())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||||
@@ -101,14 +101,11 @@ class RawTypeImpl private constructor(lowerBound: SimpleType, upperBound: Simple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object RawSubstitution : TypeSubstitution() {
|
internal class RawSubstitution(typeParameterUpperBoundEraser: TypeParameterUpperBoundEraser? = null) : TypeSubstitution() {
|
||||||
|
private val typeParameterUpperBoundEraser = typeParameterUpperBoundEraser ?: TypeParameterUpperBoundEraser(this)
|
||||||
|
|
||||||
override fun get(key: KotlinType) = TypeProjectionImpl(eraseType(key))
|
override fun get(key: KotlinType) = TypeProjectionImpl(eraseType(key))
|
||||||
|
|
||||||
private val typeParameterUpperBoundEraser = TypeParameterUpperBoundEraser()
|
|
||||||
|
|
||||||
private val lowerTypeAttr = TypeUsage.COMMON.toAttributes().withFlexibility(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND)
|
|
||||||
private val upperTypeAttr = TypeUsage.COMMON.toAttributes().withFlexibility(JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND)
|
|
||||||
|
|
||||||
private fun eraseType(type: KotlinType, attr: JavaTypeAttributes = JavaTypeAttributes(TypeUsage.COMMON)): KotlinType {
|
private fun eraseType(type: KotlinType, attr: JavaTypeAttributes = JavaTypeAttributes(TypeUsage.COMMON)): KotlinType {
|
||||||
return when (val declaration = type.constructor.declarationDescriptor) {
|
return when (val declaration = type.constructor.declarationDescriptor) {
|
||||||
is TypeParameterDescriptor ->
|
is TypeParameterDescriptor ->
|
||||||
@@ -153,7 +150,7 @@ internal object RawSubstitution : TypeSubstitution() {
|
|||||||
|
|
||||||
if (type.isError) return ErrorUtils.createErrorType("Raw error type: ${type.constructor}") to false
|
if (type.isError) return ErrorUtils.createErrorType("Raw error type: ${type.constructor}") to false
|
||||||
|
|
||||||
val memberScope = declaration.getMemberScope(RawSubstitution)
|
val memberScope = declaration.getMemberScope(this)
|
||||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
type.annotations, declaration.typeConstructor,
|
type.annotations, declaration.typeConstructor,
|
||||||
declaration.typeConstructor.parameters.map { parameter ->
|
declaration.typeConstructor.parameters.map { parameter ->
|
||||||
@@ -199,4 +196,9 @@ internal object RawSubstitution : TypeSubstitution() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun isEmpty() = false
|
override fun isEmpty() = false
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val lowerTypeAttr = TypeUsage.COMMON.toAttributes().withFlexibility(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND)
|
||||||
|
private val upperTypeAttr = TypeUsage.COMMON.toAttributes().withFlexibility(JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -13,11 +13,12 @@ import org.jetbrains.kotlin.types.typeUtil.extractTypeParametersFromUpperBounds
|
|||||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjectionOrMapped
|
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjectionOrMapped
|
||||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
||||||
|
|
||||||
class TypeParameterUpperBoundEraser {
|
internal class TypeParameterUpperBoundEraser(rawSubstitution: RawSubstitution? = null) {
|
||||||
private val storage = LockBasedStorageManager("Type parameter upper bound erasion results")
|
private val storage = LockBasedStorageManager("Type parameter upper bound erasion results")
|
||||||
private val erroneousErasedBound by lazy {
|
private val erroneousErasedBound by lazy {
|
||||||
ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`")
|
ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`")
|
||||||
}
|
}
|
||||||
|
private val rawSubstitution = rawSubstitution ?: RawSubstitution(this)
|
||||||
|
|
||||||
private data class DataToEraseUpperBound(
|
private data class DataToEraseUpperBound(
|
||||||
val typeParameter: TypeParameterDescriptor,
|
val typeParameter: TypeParameterDescriptor,
|
||||||
@@ -83,7 +84,7 @@ class TypeParameterUpperBoundEraser {
|
|||||||
*/
|
*/
|
||||||
val erasedUpperBounds = typeParameter.defaultType.extractTypeParametersFromUpperBounds(visitedTypeParameters).associate {
|
val erasedUpperBounds = typeParameter.defaultType.extractTypeParametersFromUpperBounds(visitedTypeParameters).associate {
|
||||||
val boundProjection = if (visitedTypeParameters == null || it !in visitedTypeParameters) {
|
val boundProjection = if (visitedTypeParameters == null || it !in visitedTypeParameters) {
|
||||||
RawSubstitution.computeProjection(
|
rawSubstitution.computeProjection(
|
||||||
it,
|
it,
|
||||||
// if erasure happens due to invalid arguments number, use star projections instead
|
// if erasure happens due to invalid arguments number, use star projections instead
|
||||||
if (isRaw) typeAttr else typeAttr.withFlexibility(JavaTypeFlexibility.INFLEXIBLE),
|
if (isRaw) typeAttr else typeAttr.withFlexibility(JavaTypeFlexibility.INFLEXIBLE),
|
||||||
|
|||||||
+12
@@ -21826,6 +21826,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("interdependentTypeParameters.kt")
|
||||||
|
public void testInterdependentTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("interdependentTypeParametersFromKotlin.kt")
|
||||||
|
public void testInterdependentTypeParametersFromKotlin() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/interdependentTypeParametersFromKotlin.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateRecursion.kt")
|
@TestMetadata("intermediateRecursion.kt")
|
||||||
public void testIntermediateRecursion() throws Exception {
|
public void testIntermediateRecursion() throws Exception {
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
-5
@@ -18664,11 +18664,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/platformTypes/inferenceFlexibleTToNullable.kt");
|
runTest("compiler/testData/codegen/box/platformTypes/inferenceFlexibleTToNullable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt47785.kt")
|
|
||||||
public void testKt47785() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/box/platformTypes/kt47785.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/platformTypes/primitives")
|
@TestMetadata("compiler/testData/codegen/box/platformTypes/primitives")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
-5
@@ -18070,11 +18070,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/platformTypes/inferenceFlexibleTToNullable.kt");
|
runTest("compiler/testData/codegen/box/platformTypes/inferenceFlexibleTToNullable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt47785.kt")
|
|
||||||
public void testKt47785() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/box/platformTypes/kt47785.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/platformTypes/primitives")
|
@TestMetadata("compiler/testData/codegen/box/platformTypes/primitives")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
-5
@@ -18135,11 +18135,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/platformTypes/inferenceFlexibleTToNullable.kt");
|
runTest("compiler/testData/codegen/box/platformTypes/inferenceFlexibleTToNullable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt47785.kt")
|
|
||||||
public void testKt47785() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/box/platformTypes/kt47785.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/platformTypes/primitives")
|
@TestMetadata("compiler/testData/codegen/box/platformTypes/primitives")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user