Report warning on usages of non-const vals in places where constants expected

This commit is contained in:
Denis Zharkov
2015-09-21 18:14:35 +03:00
parent 8d13f08271
commit afd4e644a3
21 changed files with 105 additions and 29 deletions
@@ -1,3 +1,3 @@
// Properties can be recursively annotated
annotation class ann(val x: Int)
@ann(x) val x: Int = 1
@ann(x) const val x: Int = 1
@@ -1,6 +1,6 @@
package
@ann(x = 1) public val x: kotlin.Int = 1
@ann(x = 1) public const val x: kotlin.Int = 1
@kotlin.annotation.annotation() public final class ann : kotlin.Annotation {
public constructor ann(/*0*/ x: kotlin.Int)
@@ -11,8 +11,8 @@ annotation class Ann(vararg val i: Int)
class Test
var i1 = 1 // var
val i2 = 1 // val
const val i2 = 1 // val
val i3 = i1 // val with var in initializer
val i4 = i2 // val with val in initializer
const val i4 = i2 // val with val in initializer
var i5 = i1 // var with var in initializer
var i6 = i2 // var with val in initializer
@@ -1,9 +1,9 @@
package
public var i1: kotlin.Int
public val i2: kotlin.Int = 1
public const val i2: kotlin.Int = 1
public val i3: kotlin.Int
public val i4: kotlin.Int = 1
public const val i4: kotlin.Int = 1
public var i5: kotlin.Int
public var i6: kotlin.Int
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
annotation class Ann(vararg val i: String)
val topLevel = "topLevel"
const val topLevel = "topLevel"
fun foo() {
val a1 = "a"
@@ -1,6 +1,6 @@
package
public val topLevel: kotlin.String = "topLevel"
public const val topLevel: kotlin.String = "topLevel"
public fun foo(): kotlin.Unit
@kotlin.annotation.annotation() public final class Ann : kotlin.Annotation {