Value classes: treat @JvmInline value classes as inline classes

Report error on value classes without @JvmInline annotation.
Do not check for @JvmInline annotation in value classes since
it breaks reflection.
This commit is contained in:
Ilmir Usmanov
2020-11-19 02:20:37 +01:00
parent 6c68660ffd
commit 92f1681de0
100 changed files with 2668 additions and 53 deletions
@@ -0,0 +1,46 @@
// !LANGUAGE: +InlineClasses
// !DIAGNOSTICS: -UNUSED_PARAMETER
package kotlin
annotation class JvmInline
@JvmInline
value class X(val x: Int)
@JvmInline
value class Z(val x: Int)
@JvmInline
value class Str(val str: String)
@JvmInline
value class Name(val name: String)
@JvmInline
value class NStr(val str: String?)
fun testSimple(x: X) {}
fun testSimple(z: Z) {}
fun testMixed(x: Int, y: Int) {}
fun testMixed(x: X, y: Int) {}
fun testMixed(x: Int, y: X) {}
fun testMixed(x: X, y: X) {}
fun testNewType(s: Str) {}
fun testNewType(name: Name) {}
fun testNullableVsNonNull1(s: Str) {}
fun testNullableVsNonNull1(s: Str?) {}
fun testNullableVsNonNull2(ns: NStr) {}
fun testNullableVsNonNull2(ns: NStr?) {}
fun testFunVsExt(x: X) {}
fun X.testFunVsExt() {}
fun testNonGenericVsGeneric(x: X, y: Number) {}
fun <T : Number> testNonGenericVsGeneric(x: X, y: T) {}
class C<TC : Number> {
fun testNonGenericVsGeneric(x: X, y: Number) {}
fun <T : Number> testNonGenericVsGeneric(x: X, y: T) {}
fun testNonGenericVsGeneric(x: X, y: TC) {}
}