Split CompileTimeConstant into two entities

1. ConstantValue
	* just holds some value and its type
	* implementations for concrete constants
2. CompileTimeConstant
	* is only produced by ConstantExpressionEvaluator
	* has additional flags (canBeUsedInAnnotation etc)
	* has two implementations TypedCompileTimeConstant containing a constant value
		and IntegerValueConstant which does not have exact type
	* can be converted to ConstantValue

Adjustt usages to use ConstantValue if flags are not needed
Add tests for some uncovered cases
This commit is contained in:
Pavel V. Talanov
2015-07-07 14:56:19 +03:00
parent 155f00578d
commit c313887641
134 changed files with 791 additions and 907 deletions
@@ -1,6 +1,6 @@
package
internal fun foo(): @[My(x = IntegerValueType(42))] kotlin.Int
internal fun foo(): @[My(x = 42)] kotlin.Int
kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class My : kotlin.Annotation {
public constructor My(/*0*/ x: kotlin.Int)
@@ -12,7 +12,7 @@ package test {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
test.A(a = IntegerValueType(12), c = "Hello") internal object SomeObject {
test.A(a = 12, c = "Hello") internal object SomeObject {
private constructor SomeObject()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -2,10 +2,10 @@ package
my() internal fun foo(): kotlin.Unit
my1() internal fun foo2(): kotlin.Unit
my1(i = IntegerValueType(2)) internal fun foo3(): kotlin.Unit
my1(i = 2) internal fun foo3(): kotlin.Unit
my2() internal fun foo4(): kotlin.Unit
my2() internal fun foo41(): kotlin.Unit
my2(i = IntegerValueType(2)) internal fun foo42(): kotlin.Unit
my2(i = 2) internal fun foo42(): kotlin.Unit
kotlin.annotation.annotation() internal final class my : kotlin.Annotation {
public constructor my()
@@ -1,7 +1,7 @@
package
Ann2(a = Ann1(a = IntegerValueType(1))) internal val a: kotlin.Int = 1
Ann2(a = Ann1(a = IntegerValueType(1))) internal val c: kotlin.Int = 2
Ann2(a = Ann1(a = 1)) internal val a: kotlin.Int = 1
Ann2(a = Ann1(a = 1)) internal val c: kotlin.Int = 2
internal fun bar(/*0*/ a: Ann = ...): kotlin.Unit
internal fun foo(): kotlin.Unit
internal fun </*0*/ T> javaClass(): java.lang.Class<T>
@@ -1,6 +1,6 @@
package
RecursivelyAnnotated(x = IntegerValueType(1)) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation {
RecursivelyAnnotated(x = 1) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation {
public constructor RecursivelyAnnotated(/*0*/ x: kotlin.Int)
internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@@ -1,8 +1,8 @@
package
kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation {
public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int)
RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int
public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = 1) x: kotlin.Int)
RecursivelyAnnotated(x = 1) internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -1,8 +1,8 @@
package
kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation {
public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int)
internal final val x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int
public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = 1)] kotlin.Int)
internal final val x: @[RecursivelyAnnotated(x = 1)] kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -1,8 +1,8 @@
package
kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation {
public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int)
RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int
public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = 1) x: kotlin.Int)
RecursivelyAnnotated(x = 1) internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -1,8 +1,8 @@
package
internal final class RecursivelyAnnotated {
public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int)
RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int
public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = 1) x: kotlin.Int)
RecursivelyAnnotated(x = 1) internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -11,7 +11,7 @@ package test {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
test.BadAnnotation(s = IntegerValueType(1)) internal object SomeObject {
test.BadAnnotation(s = 1) internal object SomeObject {
private constructor SomeObject()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -1,11 +1,11 @@
package
Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueType(3)) private final class A {
Ann(x = 1) Ann(x = 2) Ann(x = 3) private final class A {
Ann() public constructor A()
Ann() internal final val x: kotlin.Int = 1
internal final fun bar(/*0*/ x: @[Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueType(3))] kotlin.Int): kotlin.Unit
internal final fun bar(/*0*/ x: @[Ann(x = 1) Ann(x = 2) Ann(x = 3)] kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
Ann(x = IntegerValueType(5)) internal final fun foo(): kotlin.Unit
Ann(x = 5) internal 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
}
@@ -9,7 +9,7 @@ internal final class A {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal final inner class B {
Ann(x = IntegerValueType(2)) public constructor B(/*0*/ y: kotlin.Int)
Ann(x = 2) public constructor B(/*0*/ y: kotlin.Int)
internal final val y: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -1,6 +1,6 @@
package
A(x = IntegerValueType(1), y = "2") internal fun test(): kotlin.Unit
A(x = 1, y = "2") internal fun test(): kotlin.Unit
public final class A : kotlin.Annotation {
public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
@@ -3,7 +3,7 @@ package
internal final class A {
Ann1() public constructor A()
Ann2() public constructor A(/*0*/ x1: kotlin.Int)
Ann2(x = IntegerValueType(2)) public constructor A(/*0*/ x1: kotlin.Int, /*1*/ x2: kotlin.Int)
Ann2(x = 2) public constructor A(/*0*/ x1: kotlin.Int, /*1*/ x2: kotlin.Int)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -14,7 +14,7 @@ public final class A : kotlin.Annotation {
public abstract fun value(): kotlin.String
}
A(arg = IntegerValueType(1), value = "a") internal final class MyClass {
A(arg = 1, value = "a") internal final class MyClass {
public constructor MyClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -29,7 +29,7 @@ Ann(i = {}) Ann(i = {1}) Ann(i = {}) Ann(i = {1}) Ann(i = {{1}}) internal final
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
AnnAnn(i = {Ann(i = {IntegerValueType(1)})}) AnnAnn(i = {}) internal final class TestAnn {
AnnAnn(i = {Ann(i = {1})}) AnnAnn(i = {}) internal final class TestAnn {
public constructor TestAnn()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -29,7 +29,7 @@ Ann(i = {}) Ann(i = {1}) Ann(i = {}) Ann(i = {1}) Ann(i = {}) Ann(i = {1}) Ann(i
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
AnnAnn(i = {Ann(i = {IntegerValueType(1)})}) AnnAnn(i = {}) internal final class TestAnn {
AnnAnn(i = {Ann(i = {1})}) AnnAnn(i = {}) internal final class TestAnn {
public constructor TestAnn()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -1,12 +1,12 @@
package
A(value = {"1", "2", "3"}, y = IntegerValueType(1)) internal fun test1(): kotlin.Unit
A(value = {"4"}, y = IntegerValueType(2)) internal fun test2(): kotlin.Unit
A(value = {{"5", "6"}, "7"}, y = IntegerValueType(3)) internal fun test3(): kotlin.Unit
A(value = {"1", "2", "3"}, x = kotlin.String::class, y = IntegerValueType(4)) internal fun test4(): kotlin.Unit
A(value = {"4"}, y = IntegerValueType(5)) internal fun test5(): kotlin.Unit
A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = IntegerValueType(6)) internal fun test6(): kotlin.Unit
A(value = {}, y = IntegerValueType(7)) internal fun test7(): kotlin.Unit
A(value = {"1", "2", "3"}, y = 1) internal fun test1(): kotlin.Unit
A(value = {"4"}, y = 2) internal fun test2(): kotlin.Unit
A(value = {{"5", "6"}, "7"}, y = 3) internal fun test3(): kotlin.Unit
A(value = {"1", "2", "3"}, x = kotlin.String::class, y = 4) internal fun test4(): kotlin.Unit
A(value = {"4"}, y = 5) internal fun test5(): kotlin.Unit
A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = 6) internal fun test6(): kotlin.Unit
A(value = {}, y = 7) internal fun test7(): kotlin.Unit
A(value = {"8", "9", "10"}) internal fun test8(): kotlin.Unit
public final class A : kotlin.Annotation {
@@ -1,16 +1,16 @@
package
A(value = {"1", "2", "3"}) internal fun test1(): kotlin.Unit
A(value = {"5", "6"}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test10(): kotlin.Unit
A(value = {"5", "6", "7"}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test11(): kotlin.Unit
A(value = {"5", "6"}, x = kotlin.Any::class, y = 3) internal fun test10(): kotlin.Unit
A(value = {"5", "6", "7"}, x = kotlin.Any::class, y = 3) internal fun test11(): kotlin.Unit
A(value = {"4"}) internal fun test2(): kotlin.Unit
A(value = {{"5", "6"}, "7"}) internal fun test3(): kotlin.Unit
A(value = {"1", "2", "3"}, x = kotlin.String::class) internal fun test4(): kotlin.Unit
A(value = {"4"}, y = IntegerValueType(2)) internal fun test5(): kotlin.Unit
A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test6(): kotlin.Unit
A(value = {"4"}, y = 2) internal fun test5(): kotlin.Unit
A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = 3) internal fun test6(): kotlin.Unit
A(value = {}) internal fun test7(): kotlin.Unit
A(value = {}) internal fun test8(): kotlin.Unit
A(value = {}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test9(): kotlin.Unit
A(value = {}, x = kotlin.Any::class, y = 3) internal fun test9(): kotlin.Unit
public final class A : kotlin.Annotation {
public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array<out kotlin.String>*/, /*1*/ x: kotlin.reflect.KClass<*> = ..., /*2*/ y: kotlin.Int = ...)
@@ -1,6 +1,6 @@
package
A(value = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit
A(value = {1, "b"}) internal fun test(): kotlin.Unit
public final class A : kotlin.Annotation {
public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array<out kotlin.String>*/)
@@ -1,6 +1,6 @@
package
B(args = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit
B(args = {1, "b"}) internal fun test(): kotlin.Unit
kotlin.annotation.annotation() internal final class B : kotlin.Annotation {
public constructor B(/*0*/ vararg args: kotlin.String /*kotlin.Array<out kotlin.String>*/)
@@ -24,14 +24,14 @@ public final class B : kotlin.Annotation {
public abstract fun y(): kotlin.Int
}
A(arg = kotlin.String::class, b = B(y = IntegerValueType(1))) internal final class MyClass1 {
A(arg = kotlin.String::class, b = B(y = 1)) internal final class MyClass1 {
public constructor MyClass1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(b = B(y = IntegerValueType(3))) internal final class MyClass2 {
A(b = B(y = 3)) internal final class MyClass2 {
public constructor MyClass2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -18,7 +18,7 @@ A(arg = kotlin.String::class) internal final class MyClass1 {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(arg = kotlin.String::class, x = IntegerValueType(2)) internal final class MyClass2 {
A(arg = kotlin.String::class, x = 2) internal final class MyClass2 {
public constructor MyClass2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -11,14 +11,14 @@ public final class A : kotlin.Annotation {
public abstract fun x(): kotlin.Int
}
A(arg = kotlin.String::class, x = IntegerValueType(4)) internal final class MyClass2 {
A(arg = kotlin.String::class, x = 4) internal final class MyClass2 {
public constructor MyClass2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(x = IntegerValueType(5)) internal final class MyClass3 {
A(x = 5) internal final class MyClass3 {
public constructor MyClass3()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -25,14 +25,14 @@ A(value = kotlin.String::class) internal final class MyClass2 {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(value = kotlin.String::class, x = IntegerValueType(2)) internal final class MyClass3 {
A(value = kotlin.String::class, x = 2) internal final class MyClass3 {
public constructor MyClass3()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(value = kotlin.String::class, x = IntegerValueType(4)) internal final class MyClass4 {
A(value = kotlin.String::class, x = 4) internal final class MyClass4 {
public constructor MyClass4()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -11,21 +11,21 @@ public final class A : kotlin.Annotation {
public abstract fun x(): kotlin.Int
}
A(value = kotlin.String::class, x = IntegerValueType(2)) internal final class MyClass1 {
A(value = kotlin.String::class, x = 2) internal final class MyClass1 {
public constructor MyClass1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(value = kotlin.String::class, x = IntegerValueType(4)) internal final class MyClass2 {
A(value = kotlin.String::class, x = 4) internal final class MyClass2 {
public constructor MyClass2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
A(x = IntegerValueType(5)) internal final class MyClass3 {
A(x = 5) internal final class MyClass3 {
public constructor MyClass3()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -1,8 +1,8 @@
package
Ann(value = "a", x = IntegerValueType(1), y = 1.0.toDouble()) internal fun foo1(): kotlin.Unit
Ann(value = "b", x = IntegerValueType(2), y = 2.0.toDouble()) internal fun foo2(): kotlin.Unit
Ann(value = "c", x = IntegerValueType(3), y = 2.0.toDouble()) internal fun foo3(): kotlin.Unit
Ann(value = "a", x = 1, y = 1.0.toDouble()) internal fun foo1(): kotlin.Unit
Ann(value = "b", x = 2, y = 2.0.toDouble()) internal fun foo2(): kotlin.Unit
Ann(value = "c", x = 3, y = 2.0.toDouble()) internal fun foo3(): kotlin.Unit
kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation {
public constructor Ann(/*0*/ x: kotlin.Int, /*1*/ value: kotlin.String, /*2*/ y: kotlin.Double)
@@ -1,9 +1,9 @@
package
A(a = IntegerValueType(1), b = 1.0.toDouble(), value = "v1", x = false) internal fun foo1(): kotlin.Unit
A(a = IntegerValueType(2), b = 2.0.toDouble(), value = "v2", x = true) internal fun foo2(): kotlin.Unit
A(a = IntegerValueType(4), b = 3.0.toDouble(), value = "v2", x = true) internal fun foo3(): kotlin.Unit
A(a = IntegerValueType(4), b = 3.0.toDouble(), value = "v2", x = true) internal fun foo4(): kotlin.Unit
A(a = 1, b = 1.0.toDouble(), value = "v1", x = false) internal fun foo1(): kotlin.Unit
A(a = 2, b = 2.0.toDouble(), value = "v2", x = true) internal fun foo2(): kotlin.Unit
A(a = 4, b = 3.0.toDouble(), value = "v2", x = true) internal fun foo3(): kotlin.Unit
A(a = 4, b = 3.0.toDouble(), value = "v2", x = true) internal fun foo4(): kotlin.Unit
public final class A : kotlin.Annotation {
public constructor A(/*0*/ value: kotlin.String, /*1*/ a: kotlin.Int, /*2*/ b: kotlin.Double, /*3*/ x: kotlin.Boolean)
@@ -1,8 +1,8 @@
package
A(a = IntegerValueType(1), b = 1.0.toDouble(), x = false) internal fun foo1(): kotlin.Unit
A(a = IntegerValueType(2), b = 2.0.toDouble(), x = true) internal fun foo2(): kotlin.Unit
A(a = IntegerValueType(4), b = 3.0.toDouble(), x = true) internal fun foo3(): kotlin.Unit
A(a = 1, b = 1.0.toDouble(), x = false) internal fun foo1(): kotlin.Unit
A(a = 2, b = 2.0.toDouble(), x = true) internal fun foo2(): kotlin.Unit
A(a = 4, b = 3.0.toDouble(), x = true) internal fun foo3(): kotlin.Unit
public final class A : kotlin.Annotation {
public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double, /*2*/ x: kotlin.Boolean)