FIR: Properly deserialize upper bounds of classes type parameters

^KT-46661 Fixed
This commit is contained in:
Denis.Zharkov
2021-05-14 14:39:24 +03:00
committed by teamcityserver
parent 858e3584a9
commit d4586cefb4
17 changed files with 24 additions and 49 deletions
@@ -81,7 +81,7 @@ public final class CharRange : R|kotlin/ranges/CharProgression|, R|kotlin/ranges
}
public abstract interface ClosedRange<T> : R|kotlin/Any| {
public abstract interface ClosedRange<T : R|kotlin/Comparable<T>|> : R|kotlin/Any| {
public open operator fun contains(value: R|T|): R|kotlin/Boolean|
public open fun isEmpty(): R|kotlin/Boolean|
+4 -4
View File
@@ -12,9 +12,9 @@ public final fun doubleArrayOf(vararg elements: R|kotlin/DoubleArray|): R|kotlin
public final inline fun <reified T> emptyArray(): R|kotlin/Array<T>|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T> enumValueOf(name: R|kotlin/String|): R|T|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T : R|kotlin/Enum<T>|> enumValueOf(name: R|kotlin/String|): R|T|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T> enumValues(): R|kotlin/Array<T>|
@R|kotlin/SinceKotlin|(version = String(1.1)) public final inline fun <reified T : R|kotlin/Enum<T>|> enumValues(): R|kotlin/Array<T>|
public final fun floatArrayOf(vararg elements: R|kotlin/FloatArray|): R|kotlin/FloatArray|
@@ -529,7 +529,7 @@ public final class DoubleArray : R|kotlin/Any|, R|kotlin/Cloneable|, R|java/io/S
}
public abstract class Enum<E> : R|kotlin/Comparable<E>|, R|java/io/Serializable| {
public abstract class Enum<E : R|kotlin/Enum<E>|> : R|kotlin/Comparable<E>|, R|java/io/Serializable| {
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|kotlin/Enum.Companion|
@@ -551,7 +551,7 @@ public abstract class Enum<E> : R|kotlin/Comparable<E>|, R|java/io/Serializable|
public final val ordinal: R|kotlin/Int|
public get(): R|kotlin/Int|
public constructor<E>(name: R|kotlin/String| = STUB, ordinal: R|kotlin/Int| = STUB): R|kotlin/Enum<E>|
public constructor<E : R|kotlin/Enum<E>|>(name: R|kotlin/String| = STUB, ordinal: R|kotlin/Int| = STUB): R|kotlin/Enum<E>|
}
@@ -5,7 +5,7 @@ FILE: kt40131.kt
}
public final val <T : R|kotlin/reflect/KClass<*>|> R|T|.myJava1: R|java/lang/Class<*>|
public get(): R|java/lang/Class<*>| {
^ this@R|/myJava1|.R|/javaImpl|<R|kotlin/Any?|>
^ this@R|/myJava1|.R|/javaImpl|<R|kotlin/Any|>
}
public final val <E : R|kotlin/Any|, T : R|kotlin/reflect/KClass<E>|> R|T|.myJava2: R|java/lang/Class<E>|
public get(): R|java/lang/Class<E>| {
@@ -6,7 +6,7 @@ val <U> KClass<U>.javaImpl: Class<U>
get() = null!!
val <T : KClass<*>> T.myJava1: Class<*>
get() = <!DEBUG_INFO_EXPRESSION_TYPE("java.lang.Class<out kotlin.Any?>")!>javaImpl<!>
get() = <!DEBUG_INFO_EXPRESSION_TYPE("java.lang.Class<out kotlin.Any>")!>javaImpl<!>
val <E : Any, T : KClass<E>> T.myJava2: Class<E>
get() = <!DEBUG_INFO_EXPRESSION_TYPE("java.lang.Class<E>")!>javaImpl<!>
@@ -80,7 +80,7 @@ class FirTypeDeserializer(
for ((index, proto) in typeParameterProtos.withIndex()) {
val builder = builders[index]
builder.apply {
proto.upperBoundList.mapTo(bounds) {
proto.upperBounds(typeTable).mapTo(bounds) {
buildResolvedTypeRef { type = type(it) }
}
addDefaultBoundIfNecessary()
@@ -1,23 +0,0 @@
// KT-16291 Smart cast doesn't work when getting class of instance
import kotlin.reflect.KClass
class Foo {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other === null || other::class != this::class) return false
return true
}
}
fun test(f: Foo?): KClass<out Foo>? = if (f != null) f::class else null
fun test2(): KClass<out Foo>? {
var f: Foo? = null
if (f != null) {
run { f = null }
return <!RETURN_TYPE_MISMATCH!><!EXPRESSION_OF_NULLABLE_TYPE_IN_CLASS_LITERAL_LHS!>f<!>::class<!>
}
return null
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// KT-16291 Smart cast doesn't work when getting class of instance
import kotlin.reflect.KClass
@@ -21,9 +21,9 @@ interface<!SYNTAX!><!> {
}
enum class<!SYNTAX!><!> {
<!UPPER_BOUND_VIOLATED!>enum class<!SYNTAX!><!> {
}
}<!>
annotation class<!SYNTAX!><!> {
@@ -48,9 +48,9 @@ class Outer {
}
enum class<!SYNTAX!><!> {
<!UPPER_BOUND_VIOLATED!>enum class<!SYNTAX!><!> {
}
}<!>
annotation class<!SYNTAX!><!> {
@@ -1,7 +1,8 @@
// COMPARE_WITH_LIGHT_TREE
// FILE: test.kt
enum class MyEnum(): <!CLASS_IN_SUPERTYPE_FOR_ENUM!>MyClass<!>() {}
enum class MyEnum2(): MyTrait {}
enum class MyEnum3(): <!CLASS_IN_SUPERTYPE_FOR_ENUM, FINAL_SUPERTYPE!>MyEnumBase<!>() {}
enum class MyEnum3(): <!UPPER_BOUND_VIOLATED{LT}!><!CLASS_IN_SUPERTYPE_FOR_ENUM, FINAL_SUPERTYPE, UPPER_BOUND_VIOLATED{PSI}!>MyEnumBase<!>()<!> {}
open class MyClass() {}
@@ -1,3 +1,4 @@
// COMPARE_WITH_LIGHT_TREE
// FILE: test.kt
enum class MyEnum(): <!CLASS_IN_SUPERTYPE_FOR_ENUM!>MyClass<!>() {}
enum class MyEnum2(): MyTrait {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FIR_IDE_IGNORE
enum class<!SYNTAX!><!> {
}
}
@@ -1,8 +0,0 @@
// WITH_RUNTIME
// !DIAGNOSTICS: -UNUSED_VARIABLE
class Foo<T : Enum<T>>(val values: Array<T>)
fun foo(x: Array<out Enum<*>>) {
val y = <!NEW_INFERENCE_ERROR!>Foo(x)<!>
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// WITH_RUNTIME
// !DIAGNOSTICS: -UNUSED_VARIABLE
@@ -1,4 +1,5 @@
// FIR_IDENTICAL
// FIR_IDE_IGNORE
// !DIAGNOSTICS: -REDECLARATION -DUPLICATE_CLASS_NAMES
class C {
@@ -15,4 +16,4 @@ class C {
class C1<<!SYNTAX!>in<!>> {}
class C2(val<!SYNTAX!><!>) {}
class C2(val<!SYNTAX!><!>) {}
@@ -21,6 +21,6 @@ object<!SYNTAX!><!> {
}
enum class<!SYNTAX!><!> {}
<!UPPER_BOUND_VIOLATED!>enum class<!SYNTAX!><!> {}<!>
annotation class<!SYNTAX!><!> {}
+1 -1
View File
@@ -7,7 +7,7 @@ class C {
class<error descr="Name expected"> </error>{}
enum class<error descr="Name expected"> </error>{}
<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'kotlin/Enum<C.<no name provided>>'">enum class<error descr="Name expected"> </error>{}</error>
}
class C1<<error descr="Type parameter name expected">in</error>> {}
@@ -19,6 +19,6 @@ object<error descr="Name expected"> </error>{
}
enum class<error descr="Name expected"> </error>{}
<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'kotlin/Enum<<no name provided>>'">enum class<error descr="Name expected"> </error>{}</error>
annotation class<error descr="Name expected"> </error>{}