Add new diagnostic tests to check new rules for const modifier
This commit is contained in:
+24
@@ -20057,6 +20057,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/constInteraction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumConstName.kt")
|
||||
public void testEnumConstName() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fromJava.kt")
|
||||
public void testFromJava() throws Exception {
|
||||
@@ -20069,6 +20075,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/fromJavaSubclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallable.kt")
|
||||
public void testKCallable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt12248.kt")
|
||||
public void testKt12248() throws Exception {
|
||||
@@ -20081,6 +20099,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kt15913.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stdlibConstFun.kt")
|
||||
public void testStdlibConstFun() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/stdlibConstFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("types.kt")
|
||||
public void testTypes() throws Exception {
|
||||
|
||||
+24
@@ -20057,6 +20057,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/constInteraction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumConstName.kt")
|
||||
public void testEnumConstName() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fromJava.kt")
|
||||
public void testFromJava() throws Exception {
|
||||
@@ -20069,6 +20075,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/fromJavaSubclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallable.kt")
|
||||
public void testKCallable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt12248.kt")
|
||||
public void testKt12248() throws Exception {
|
||||
@@ -20081,6 +20099,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kt15913.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stdlibConstFun.kt")
|
||||
public void testStdlibConstFun() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/stdlibConstFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("types.kt")
|
||||
public void testTypes() throws Exception {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
enum class EnumClass {
|
||||
OK, VALUE, anotherValue, WITH_UNDERSCORE
|
||||
}
|
||||
|
||||
const val name1 = EnumClass.OK.name
|
||||
const val name2 = EnumClass.VALUE.name
|
||||
const val name3 = EnumClass.anotherValue.name
|
||||
const val name4 = EnumClass.WITH_UNDERSCORE.name
|
||||
@@ -0,0 +1,8 @@
|
||||
enum class EnumClass {
|
||||
OK, VALUE, anotherValue, WITH_UNDERSCORE
|
||||
}
|
||||
|
||||
const val name1 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>EnumClass.OK.name<!>
|
||||
const val name2 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>EnumClass.VALUE.name<!>
|
||||
const val name3 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>EnumClass.anotherValue.name<!>
|
||||
const val name4 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>EnumClass.WITH_UNDERSCORE.name<!>
|
||||
@@ -0,0 +1,31 @@
|
||||
package
|
||||
|
||||
public const val name1: kotlin.String
|
||||
public const val name2: kotlin.String
|
||||
public const val name3: kotlin.String
|
||||
public const val name4: kotlin.String
|
||||
|
||||
public final enum class EnumClass : kotlin.Enum<EnumClass> {
|
||||
enum entry OK
|
||||
|
||||
enum entry VALUE
|
||||
|
||||
enum entry anotherValue
|
||||
|
||||
enum entry WITH_UNDERSCORE
|
||||
|
||||
private constructor EnumClass()
|
||||
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: EnumClass): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<EnumClass!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): EnumClass
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<EnumClass>
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
const val flag = true
|
||||
const val value = 10
|
||||
|
||||
const val condition = if (flag) "True" else "Error"
|
||||
const val withWhen = when (flag) {
|
||||
true -> "True"
|
||||
else -> "Error"
|
||||
}
|
||||
const val withWhen2 = when {
|
||||
flag == true -> "True"
|
||||
else -> "Error"
|
||||
}
|
||||
const val withWhen3 = when(value) {
|
||||
10 -> "1"
|
||||
100 -> "2"
|
||||
else -> "3"
|
||||
}
|
||||
const val multibranchIf = if (value == 100) 1 else if (value == 1000) 2 else 3
|
||||
|
||||
val nonConstFlag = true
|
||||
const val errorConstIf = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>if (nonConstFlag) 1 else 2<!>
|
||||
const val errorBranch = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>if (flag) nonConstFlag else false<!>
|
||||
@@ -0,0 +1,22 @@
|
||||
const val flag = true
|
||||
const val value = 10
|
||||
|
||||
const val condition = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>if (flag) "True" else "Error"<!>
|
||||
const val withWhen = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>when (flag) {
|
||||
true -> "True"
|
||||
else -> "Error"
|
||||
}<!>
|
||||
const val withWhen2 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>when {
|
||||
flag == true -> "True"
|
||||
else -> "Error"
|
||||
}<!>
|
||||
const val withWhen3 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>when(value) {
|
||||
10 -> "1"
|
||||
100 -> "2"
|
||||
else -> "3"
|
||||
}<!>
|
||||
const val multibranchIf = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>if (value == 100) 1 else if (value == 1000) 2 else 3<!>
|
||||
|
||||
val nonConstFlag = true
|
||||
const val errorConstIf = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>if (nonConstFlag) 1 else 2<!>
|
||||
const val errorBranch = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>if (flag) nonConstFlag else false<!>
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public const val condition: kotlin.String
|
||||
public const val errorBranch: kotlin.Boolean
|
||||
public const val errorConstIf: kotlin.Int
|
||||
public const val flag: kotlin.Boolean = true
|
||||
public const val multibranchIf: kotlin.Int
|
||||
public val nonConstFlag: kotlin.Boolean = true
|
||||
public const val value: kotlin.Int = 10
|
||||
public const val withWhen: kotlin.String
|
||||
public const val withWhen2: kotlin.String
|
||||
public const val withWhen3: kotlin.String
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
class SomeClassWithName(val property: Int) {
|
||||
val anotherProperty: String = ""
|
||||
|
||||
fun foo() {}
|
||||
fun bar(a: Int, b: Double): String = ""
|
||||
}
|
||||
|
||||
const val className = ::SomeClassWithName.name
|
||||
const val propName = SomeClassWithName::property.name
|
||||
const val anotherPropName = SomeClassWithName::anotherProperty.name
|
||||
const val fooName = SomeClassWithName::foo.name
|
||||
const val barName = SomeClassWithName::bar.name
|
||||
|
||||
const val stringClassName = ::String.name
|
||||
const val lengthPropName = String::length.name
|
||||
|
||||
const val errorAccess = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>SomeClassWithName(1)::property.name<!>
|
||||
const val errorPlus = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>"" + ::SomeClassWithName.<!UNRESOLVED_REFERENCE!>property<!><!>
|
||||
@@ -0,0 +1,18 @@
|
||||
class SomeClassWithName(val property: Int) {
|
||||
val anotherProperty: String = ""
|
||||
|
||||
fun foo() {}
|
||||
fun bar(a: Int, b: Double): String = ""
|
||||
}
|
||||
|
||||
const val className = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>::SomeClassWithName.name<!>
|
||||
const val propName = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>SomeClassWithName::property.name<!>
|
||||
const val anotherPropName = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>SomeClassWithName::anotherProperty.name<!>
|
||||
const val fooName = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>SomeClassWithName::foo.name<!>
|
||||
const val barName = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>SomeClassWithName::bar.name<!>
|
||||
|
||||
const val stringClassName = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>::String.name<!>
|
||||
const val lengthPropName = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>String::length.name<!>
|
||||
|
||||
const val errorAccess = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>SomeClassWithName(1)::property.name<!>
|
||||
const val errorPlus = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>"" + ::SomeClassWithName.property<!>
|
||||
@@ -0,0 +1,21 @@
|
||||
package
|
||||
|
||||
public const val anotherPropName: kotlin.String
|
||||
public const val barName: kotlin.String
|
||||
public const val className: kotlin.String
|
||||
public const val errorAccess: kotlin.String
|
||||
public const val fooName: kotlin.String
|
||||
public const val lengthPropName: kotlin.String
|
||||
public const val propName: kotlin.String
|
||||
public const val stringClassName: kotlin.String
|
||||
|
||||
public final class SomeClassWithName {
|
||||
public constructor SomeClassWithName(/*0*/ property: kotlin.Int)
|
||||
public final val anotherProperty: kotlin.String = ""
|
||||
public final val property: kotlin.Int
|
||||
public final fun bar(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
|
||||
const val byte: Byte = 1
|
||||
const val short: Short = 2
|
||||
const val int: Int = 3
|
||||
const val long: Long = 4L
|
||||
const val float: Float = 5f
|
||||
const val double: Double = 6.0
|
||||
|
||||
val byteFloorByte = byte.floorDiv(byte)
|
||||
val byteFloorShort = byte.floorDiv(short)
|
||||
val byteFloorInt = byte.floorDiv(int)
|
||||
val byteFloorLong = byte.floorDiv(long)
|
||||
|
||||
val shortFloorByte = byte.floorDiv(byte)
|
||||
val shortFloorShort = byte.floorDiv(short)
|
||||
val shortFloorInt = byte.floorDiv(int)
|
||||
val shortFloorLong = byte.floorDiv(long)
|
||||
|
||||
val intFloorByte = byte.floorDiv(byte)
|
||||
val intFloorShort = byte.floorDiv(short)
|
||||
val intFloorInt = byte.floorDiv(int)
|
||||
val intFloorLong = byte.floorDiv(long)
|
||||
|
||||
val longFloorByte = byte.floorDiv(byte)
|
||||
val longFloorShort = byte.floorDiv(short)
|
||||
val longFloorInt = byte.floorDiv(int)
|
||||
val longFloorLong = byte.floorDiv(long)
|
||||
|
||||
val byteModByte = byte.mod(byte)
|
||||
val byteModShort = byte.mod(short)
|
||||
val byteModInt = byte.mod(int)
|
||||
val byteModLong = byte.mod(long)
|
||||
|
||||
val shortModByte = byte.mod(byte)
|
||||
val shortModShort = byte.mod(short)
|
||||
val shortModInt = byte.mod(int)
|
||||
val shortModLong = byte.mod(long)
|
||||
|
||||
val intModByte = byte.mod(byte)
|
||||
val intModShort = byte.mod(short)
|
||||
val intModInt = byte.mod(int)
|
||||
val intModLong = byte.mod(long)
|
||||
|
||||
val longModByte = byte.mod(byte)
|
||||
val longModShort = byte.mod(short)
|
||||
val longModInt = byte.mod(int)
|
||||
val longModLong = byte.mod(long)
|
||||
|
||||
val floatModFloat = float.mod(float)
|
||||
val floatModDouble = float.mod(double)
|
||||
val doubleModFloat = double.mod(float)
|
||||
val doubleModDouble = double.mod(double)
|
||||
@@ -0,0 +1,44 @@
|
||||
package
|
||||
|
||||
public const val byte: kotlin.Byte = 1.toByte()
|
||||
public val byteFloorByte: kotlin.Int = 1
|
||||
public val byteFloorInt: kotlin.Int = 0
|
||||
public val byteFloorLong: kotlin.Long = 0.toLong()
|
||||
public val byteFloorShort: kotlin.Int = 0
|
||||
public val byteModByte: kotlin.Byte = 0.toByte()
|
||||
public val byteModInt: kotlin.Int = 1
|
||||
public val byteModLong: kotlin.Long = 1.toLong()
|
||||
public val byteModShort: kotlin.Short = 1.toShort()
|
||||
public const val double: kotlin.Double = 6.0.toDouble()
|
||||
public val doubleModDouble: kotlin.Double = 0.0.toDouble()
|
||||
public val doubleModFloat: kotlin.Double = 1.0.toDouble()
|
||||
public const val float: kotlin.Float = 5.0.toFloat()
|
||||
public val floatModDouble: kotlin.Double = 5.0.toDouble()
|
||||
public val floatModFloat: kotlin.Float = 0.0.toFloat()
|
||||
public const val int: kotlin.Int = 3
|
||||
public val intFloorByte: kotlin.Int = 1
|
||||
public val intFloorInt: kotlin.Int = 0
|
||||
public val intFloorLong: kotlin.Long = 0.toLong()
|
||||
public val intFloorShort: kotlin.Int = 0
|
||||
public val intModByte: kotlin.Byte = 0.toByte()
|
||||
public val intModInt: kotlin.Int = 1
|
||||
public val intModLong: kotlin.Long = 1.toLong()
|
||||
public val intModShort: kotlin.Short = 1.toShort()
|
||||
public const val long: kotlin.Long = 4.toLong()
|
||||
public val longFloorByte: kotlin.Int = 1
|
||||
public val longFloorInt: kotlin.Int = 0
|
||||
public val longFloorLong: kotlin.Long = 0.toLong()
|
||||
public val longFloorShort: kotlin.Int = 0
|
||||
public val longModByte: kotlin.Byte = 0.toByte()
|
||||
public val longModInt: kotlin.Int = 1
|
||||
public val longModLong: kotlin.Long = 1.toLong()
|
||||
public val longModShort: kotlin.Short = 1.toShort()
|
||||
public const val short: kotlin.Short = 2.toShort()
|
||||
public val shortFloorByte: kotlin.Int = 1
|
||||
public val shortFloorInt: kotlin.Int = 0
|
||||
public val shortFloorLong: kotlin.Long = 0.toLong()
|
||||
public val shortFloorShort: kotlin.Int = 0
|
||||
public val shortModByte: kotlin.Byte = 0.toByte()
|
||||
public val shortModInt: kotlin.Int = 1
|
||||
public val shortModLong: kotlin.Long = 1.toLong()
|
||||
public val shortModShort: kotlin.Short = 1.toShort()
|
||||
Generated
+24
@@ -20063,6 +20063,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/constInteraction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumConstName.kt")
|
||||
public void testEnumConstName() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fromJava.kt")
|
||||
public void testFromJava() throws Exception {
|
||||
@@ -20075,6 +20081,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/fromJavaSubclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallable.kt")
|
||||
public void testKCallable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt12248.kt")
|
||||
public void testKt12248() throws Exception {
|
||||
@@ -20087,6 +20105,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kt15913.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stdlibConstFun.kt")
|
||||
public void testStdlibConstFun() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/stdlibConstFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("types.kt")
|
||||
public void testTypes() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user