Files
kotlin-fork/compiler/testData/diagnostics/tests/declarationChecks/kClassInSignature.fir.kt
T
Jinseong Jeon bc2228d434 FIR checker: don't report errors on type parameter as LHS of class literals
If a type paramter is not reified or nullable, different errors will
be reported by FirGetClassCallChecker.

When determining whether type parameter wrapped in qualified access is a
standalone expression or not, we examine whether the checker context has
other qualified accesses in stack. Class literals (::class) is desugared
to FirGetClassCall, and thus not stacked as qualified access. Since
class literals are a special type of callable reference (a subtype of
qualified access), we should keep track of FirGetClassCall in a similar
way.
2021-03-16 21:56:09 +03:00

24 lines
642 B
Kotlin
Vendored

// !DIAGNOSTICS: -TYPE_PARAMETER_AS_REIFIED -TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER -UNUSED_VARIABLE -UNUSED_PARAMETER
fun <T> test1() = T::class
fun <T : Any> test2() = T::class
val <T> test3 = T::class
val <T> test4 get() = T::class
fun <T> test5() = listOf(T::class)
fun <T> test6(): kotlin.reflect.KClass<T> = T::class
fun <T> test7(): kotlin.reflect.KClass<*> = T::class
fun test8() = <!NULLABLE_TYPE_IN_CLASS_LITERAL_LHS!>String?::class<!>
fun <T> listOf(e: T): List<T> = null!!
fun <L> locals() {
fun <T> test1() = T::class
fun <T : Any> test2() = T::class
val test3 = L::class
fun test4() = L::class
}