[FIR] Implement Native test infrastructure, add FirNativeSessionFactory
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -MISSING_DEPENDENCY_SUPERCLASS
|
||||
|
||||
// FIXME: rename identifiers.kt
|
||||
|
||||
// FILE: 1.kt
|
||||
package `check.pkg`
|
||||
|
||||
// FILE: 2.kt
|
||||
package totally.normal.pkg
|
||||
|
||||
class `Check.Class`
|
||||
class NormalClass {
|
||||
fun `check$member`() {}
|
||||
}
|
||||
|
||||
object `Check;Object`
|
||||
object NormalObject
|
||||
|
||||
data class Pair(val first: Int, val `next,one`: Int)
|
||||
|
||||
object Delegate {
|
||||
operator fun getValue(thisRef: Any?, property: kotlin.reflect.KProperty<*>): Any? = null
|
||||
}
|
||||
|
||||
fun `check(function`() {
|
||||
val `check)variable` = 1
|
||||
val `check[delegated[variable` by Delegate
|
||||
|
||||
val normalVariable = 2
|
||||
val normalDelegatedVariable by Delegate
|
||||
|
||||
val (check, `destructuring]declaration`) = Pair(1, 2)
|
||||
}
|
||||
|
||||
fun normalFunction() {}
|
||||
|
||||
val `check{property` = 1
|
||||
val `check}delegated}property` by Delegate
|
||||
val normalProperty = 2
|
||||
val normalDelegatedProperty by Delegate
|
||||
|
||||
fun checkValueParameter(`check/parameter`: Int) {}
|
||||
|
||||
fun <`check<type<parameter`, normalTypeParameter> checkTypeParameter() {}
|
||||
|
||||
enum class `Check>Enum>Entry` {
|
||||
`CHECK:ENUM:ENTRY`;
|
||||
}
|
||||
|
||||
typealias `check\typealias` = Any
|
||||
|
||||
fun `check&`() {}
|
||||
|
||||
fun `check~`() {}
|
||||
|
||||
fun `check*`() {}
|
||||
|
||||
fun `check?`() {}
|
||||
|
||||
fun `check#`() {}
|
||||
|
||||
fun `check|`() {}
|
||||
|
||||
fun `check§`() {}
|
||||
|
||||
fun `check%`() {}
|
||||
|
||||
fun `check@`() {}
|
||||
@@ -0,0 +1,179 @@
|
||||
// FILE: kotlin.kt
|
||||
package kotlin.native
|
||||
|
||||
@Target(
|
||||
AnnotationTarget.CLASS,
|
||||
AnnotationTarget.PROPERTY,
|
||||
AnnotationTarget.VALUE_PARAMETER,
|
||||
AnnotationTarget.FUNCTION
|
||||
)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@MustBeDocumented
|
||||
public annotation class ObjCName(val name: String = "", val swiftName: String = "", val exact: Boolean = false)
|
||||
|
||||
// FILE: test.kt
|
||||
@ObjCName("ObjCClass", "SwiftClass")
|
||||
open class KotlinClass {
|
||||
@ObjCName("objCProperty")
|
||||
open var kotlinProperty: Int = 0
|
||||
@ObjCName(swiftName = "swiftFunction")
|
||||
open fun @receiver:ObjCName("objCReceiver") Int.kotlinFunction(
|
||||
@ObjCName("objCParam") kotlinParam: Int
|
||||
): Int = this + kotlinParam
|
||||
}
|
||||
|
||||
@ObjCName("ObjCSubClass", "SwiftSubClass")
|
||||
class KotlinSubClass: KotlinClass() {
|
||||
@ObjCName("objCProperty")
|
||||
override var kotlinProperty: Int = 1
|
||||
@ObjCName(swiftName = "swiftFunction")
|
||||
override fun @receiver:ObjCName("objCReceiver") Int.kotlinFunction(
|
||||
@ObjCName("objCParam") kotlinParam: Int
|
||||
): Int = this + kotlinParam * 2
|
||||
}
|
||||
|
||||
@ObjCName()
|
||||
val invalidObjCName: Int = 0
|
||||
|
||||
@ObjCName("validName", "invalid.name")
|
||||
val invalidCharactersObjCNameA: Int = 0
|
||||
|
||||
@ObjCName("invalid.name", "validName")
|
||||
val invalidCharactersObjCNameB: Int = 0
|
||||
|
||||
@ObjCName("validName1", "1validName")
|
||||
val invalidFirstCharacterObjCNameA: Int = 0
|
||||
|
||||
@ObjCName("1validName", "validName1")
|
||||
val invalidFirstCharacterObjCNameB: Int = 0
|
||||
|
||||
@ObjCName(swiftName = "SwiftMissingExactName", exact = true)
|
||||
class MissingExactName
|
||||
|
||||
interface KotlinInterfaceA {
|
||||
@ObjCName("objCPropertyA", "swiftPropertyA")
|
||||
var kotlinPropertyA: Int
|
||||
@ObjCName("objCPropertyB", "swiftPropertyB")
|
||||
var kotlinPropertyB: Int
|
||||
@ObjCName("objCPropertyB")
|
||||
var kotlinPropertyC: Int
|
||||
@ObjCName(swiftName ="swiftPropertyB")
|
||||
var kotlinPropertyD: Int
|
||||
var kotlinPropertyE: Int
|
||||
var kotlinPropertyF: Int
|
||||
|
||||
@ObjCName("objCFunctionA", "swiftFunctionA")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionA(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionB", "swiftFunctionB")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionB(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionC", "swiftFunctionC")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionC(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionD", "swiftFunctionD")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionD(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionE", "swiftFunctionE")
|
||||
fun Int.kotlinFunctionE(@ObjCName("objCParam", "swiftParam") kotlinParam: Int): Int
|
||||
}
|
||||
|
||||
interface KotlinInterfaceB {
|
||||
@ObjCName("objCPropertyA", "swiftPropertyA")
|
||||
var kotlinPropertyA: Int
|
||||
@ObjCName("objCPropertyBB", "swiftPropertyB")
|
||||
var kotlinPropertyB: Int
|
||||
@ObjCName(swiftName ="swiftPropertyC")
|
||||
var kotlinPropertyC: Int
|
||||
@ObjCName("objCPropertyD")
|
||||
var kotlinPropertyD: Int
|
||||
@ObjCName("objCPropertyE")
|
||||
var kotlinPropertyE: Int
|
||||
var kotlinPropertyF: Int
|
||||
|
||||
@ObjCName("objCFunctionA", "swiftFunctionA")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionA(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionBB", "swiftFunctionB")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionB(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionC", "swiftFunctionC")
|
||||
fun @receiver:ObjCName("objCReceiverC", "swiftReceiver") Int.kotlinFunctionC(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
@ObjCName("objCFunctionD", "swiftFunctionD")
|
||||
fun @receiver:ObjCName("objCReceiver", "swiftReceiver") Int.kotlinFunctionD(
|
||||
@ObjCName("objCParamD", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
fun @receiver:ObjCName("objCFunctionE", "swiftFunctionE") Int.kotlinFunctionE(
|
||||
@ObjCName("objCParam", "swiftParam") kotlinParam: Int
|
||||
): Int
|
||||
}
|
||||
|
||||
class KotlinOverrideClass: KotlinInterfaceA, KotlinInterfaceB {
|
||||
override var kotlinPropertyA: Int = 0
|
||||
override var kotlinPropertyB: Int = 0
|
||||
override var kotlinPropertyC: Int = 0
|
||||
override var kotlinPropertyD: Int = 0
|
||||
override var kotlinPropertyE: Int = 0
|
||||
override var kotlinPropertyF: Int = 0
|
||||
|
||||
override fun Int.kotlinFunctionA(kotlinParam: Int): Int = this + kotlinParam
|
||||
override fun Int.kotlinFunctionB(kotlinParam: Int): Int = this + kotlinParam
|
||||
override fun Int.kotlinFunctionC(kotlinParam: Int): Int = this + kotlinParam
|
||||
override fun Int.kotlinFunctionD(kotlinParam: Int): Int = this + kotlinParam
|
||||
override fun Int.kotlinFunctionE(kotlinParam: Int): Int = this + kotlinParam
|
||||
}
|
||||
|
||||
@ObjCName("ObjCExactChecks", exact = true)
|
||||
class ExactChecks {
|
||||
@ObjCName("objCProperty", exact = true)
|
||||
var property: Int = 0
|
||||
@ObjCName("objCFunction", exact = true)
|
||||
fun @receiver:ObjCName("objCReceiver", exact = true) Int.function(
|
||||
@ObjCName("objCParam", exact = true) param: Int
|
||||
): Int = this * param
|
||||
}
|
||||
|
||||
@ObjCName("ObjCEnumExactChecks", exact = true)
|
||||
enum class EnumExactChecks {
|
||||
@ObjCName("objCEntryOne", exact = true)
|
||||
ENTRY_ONE,
|
||||
@ObjCName("objCEntryTwo")
|
||||
ENTRY_TWO
|
||||
}
|
||||
|
||||
open class Base {
|
||||
@ObjCName("foo1")
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
interface I {
|
||||
@ObjCName("foo2")
|
||||
fun foo()
|
||||
}
|
||||
|
||||
open class Derived : Base(), I
|
||||
|
||||
open class Derived2 : Derived() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
private const val exact = false
|
||||
private const val objcName = "nonLiteralArgsObjC"
|
||||
|
||||
@ObjCName(
|
||||
objcName,
|
||||
"nonLiteralArgs" + "Swift",
|
||||
exact
|
||||
)
|
||||
val nonLiteralArgs: Int = 0
|
||||
|
||||
@ObjCName("invalidArgsObjC", <!ARGUMENT_TYPE_MISMATCH!>false<!>, <!ARGUMENT_TYPE_MISMATCH!>"not a boolean"<!>)
|
||||
val invalidArgs: Int = 0
|
||||
@@ -0,0 +1,145 @@
|
||||
// FILE: annotation.kt
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class SharedImmutable
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class ThreadLocal
|
||||
|
||||
// FILE: test.kt
|
||||
import kotlin.native.concurrent.SharedImmutable
|
||||
import kotlin.native.concurrent.ThreadLocal
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
fun println(value: Int) {}
|
||||
fun println(value: String) {}
|
||||
fun println(value: Point) {}
|
||||
|
||||
data class Point(val x: Double, val y: Double)
|
||||
@SharedImmutable
|
||||
val point1 = Point(1.0, 1.0)
|
||||
|
||||
@SharedImmutable
|
||||
var point2 = Point(2.0, 2.0)
|
||||
|
||||
class Date(@SharedImmutable val month: Int, @SharedImmutable var day:Int)
|
||||
class Person(val name: String) {
|
||||
@SharedImmutable
|
||||
var surname: String? = null
|
||||
}
|
||||
|
||||
class Figure {
|
||||
@SharedImmutable
|
||||
val cornerPoint: Point
|
||||
get() = point1
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
var age = 20
|
||||
get() {
|
||||
println("Age is: $field")
|
||||
return field
|
||||
}
|
||||
set(value) {
|
||||
println(value)
|
||||
}
|
||||
|
||||
var globalAge = 30
|
||||
@SharedImmutable
|
||||
var age1 = 20
|
||||
get() {
|
||||
println("Age is: $field")
|
||||
return field
|
||||
}
|
||||
set(value) {
|
||||
globalAge = value
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
val age2 = 20
|
||||
get() {
|
||||
println("Age is: $field")
|
||||
return field
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
var point3: Point
|
||||
get() = point2
|
||||
set(value) {
|
||||
point2 = value
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
var point4: Point
|
||||
get() = point2
|
||||
set(value) {
|
||||
println(value)
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
var point0 = Point(2.0, 2.0)
|
||||
|
||||
@SharedImmutable
|
||||
var point5: Point
|
||||
get() = point0
|
||||
set(value) {
|
||||
point0 = value
|
||||
}
|
||||
|
||||
|
||||
class Delegate {
|
||||
var value = 20
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Int {
|
||||
println("Get")
|
||||
return value
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {
|
||||
println("Set")
|
||||
}
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
var property: Int by Delegate()
|
||||
|
||||
class Delegate1 {
|
||||
var value = 20
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Int {
|
||||
return value
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {
|
||||
this.value = value
|
||||
}
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
var property1: Int by Delegate1()
|
||||
|
||||
var globalValue: Int = 20
|
||||
|
||||
class Delegate2 {
|
||||
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Int {
|
||||
return globalValue
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {
|
||||
println(value)
|
||||
}
|
||||
}
|
||||
|
||||
@SharedImmutable
|
||||
var property2: Int by Delegate2()
|
||||
|
||||
@SharedImmutable
|
||||
val someValue: Int
|
||||
get() = 20
|
||||
|
||||
@SharedImmutable
|
||||
val someValueWithDelegate by Delegate()
|
||||
@@ -0,0 +1,71 @@
|
||||
// FILE: annotation.kt
|
||||
package kotlin.native.concurrent
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class ThreadLocal
|
||||
|
||||
// FILE: test.kt
|
||||
import kotlin.native.concurrent.ThreadLocal
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
data class Point(val x: Double, val y: Double)
|
||||
|
||||
class Person(val name: String) {
|
||||
@ThreadLocal
|
||||
var surname: String? = null
|
||||
}
|
||||
|
||||
abstract class Information {
|
||||
abstract var field: String
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
class Person1(val name: String) {
|
||||
var surname: String? = null
|
||||
@ThreadLocal
|
||||
val extraInfo: Information = object : Information() {
|
||||
override var field: String = "extra info"
|
||||
}
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
val extraInfo: Information = object : Information() {
|
||||
override var field: String = "extra info"
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
val point1 = Point(1.0, 1.0)
|
||||
|
||||
@ThreadLocal
|
||||
val cornerPoint: Point
|
||||
get() = point1
|
||||
|
||||
@ThreadLocal
|
||||
val person = Person1("aaaaa")
|
||||
|
||||
class Delegate {
|
||||
val value: Int = 10
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Int {
|
||||
return value
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
var field1: Int by Delegate()
|
||||
|
||||
@ThreadLocal
|
||||
object WithDelegate {
|
||||
var field1: Int by Delegate()
|
||||
}
|
||||
|
||||
class Bar {
|
||||
@ThreadLocal
|
||||
object SomeObject {
|
||||
var field1: Int = 10
|
||||
var field2: String? = null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
// FILE: kotlin.kt
|
||||
package kotlin
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Throws(vararg val exceptionClasses: KClass<out Throwable>)
|
||||
|
||||
public open class Exception : Throwable()
|
||||
|
||||
public open class RuntimeException : Exception()
|
||||
|
||||
public open class IllegalStateException : RuntimeException()
|
||||
|
||||
// FILE: native.kt
|
||||
package kotlin.native
|
||||
|
||||
@Deprecated("")
|
||||
public typealias Throws = kotlin.Throws
|
||||
|
||||
// FILE: CancellationException.kt
|
||||
package kotlin.coroutines.cancellation
|
||||
|
||||
public open class CancellationException() : IllegalStateException()
|
||||
|
||||
// FILE: test.kt
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
|
||||
class Exception1 : Throwable()
|
||||
class Exception2 : Throwable()
|
||||
class Exception3 : Throwable()
|
||||
|
||||
@Throws
|
||||
fun foo() {}
|
||||
|
||||
@Throws()
|
||||
fun throwsEmptyParens() {}
|
||||
|
||||
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
||||
fun throwsUnresolved() {}
|
||||
|
||||
@Throws(exceptionClasses = <!ANNOTATION_ARGUMENT_MUST_BE_CONST, ARGUMENT_TYPE_MISMATCH, ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR!><!UNRESOLVED_REFERENCE!>UnresolvedException<!>::class<!>)
|
||||
fun throwsNamedUnresolved() {}
|
||||
|
||||
@Throws(exceptionClasses = [])
|
||||
fun throwsNamedEmptyLiteral() {}
|
||||
|
||||
@Throws(exceptionClasses = arrayOf())
|
||||
fun throwsNamedEmptyArrayOf() {}
|
||||
|
||||
@Throws(*[])
|
||||
fun throwsSpreadEmptyLiteral() {}
|
||||
|
||||
@Throws(*arrayOf())
|
||||
fun throwsSpreadEmptyArrayOf() {}
|
||||
|
||||
@Throws(exceptionClasses = <!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>[<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>]<!>)
|
||||
fun throwsNamedLiteralWithUnresolved() {}
|
||||
|
||||
@Throws(exceptionClasses = <!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>)<!>)
|
||||
fun throwsNamedArrayOfUnresolved() {}
|
||||
|
||||
@Throws(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>[<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>]<!>)
|
||||
fun throwsSpreadLiteralWithUnresolved() {}
|
||||
|
||||
@Throws(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>)<!>)
|
||||
fun throwsSpreadArrayOfUnresolved() {}
|
||||
|
||||
typealias UEAlias = <!UNRESOLVED_REFERENCE!>UE<!>
|
||||
|
||||
@Throws(UEAlias::class)
|
||||
fun throwsTypealiasToUnresolved() {}
|
||||
|
||||
interface Base0 {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class ThrowsOnOverride : Base0 {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
interface Base1 {
|
||||
@Throws(Exception1::class) fun foo()
|
||||
}
|
||||
|
||||
class InheritsThrowsAndNoThrows : Base0, Base1 {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesThrowsAndNoThrows : Base0, Base1 {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class SameThrowsOnOverride : Base1 {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class DifferentThrowsOnOverride : Base1 {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class HasThrowsWithEmptyListOnOverride : Base1 {
|
||||
@Throws override fun foo() {}
|
||||
}
|
||||
|
||||
interface Base2 {
|
||||
@Throws(Exception2::class) fun foo()
|
||||
}
|
||||
|
||||
open class InheritsDifferentThrows1 : Base1, Base2 {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
open class OverridesDifferentThrows1_1 : Base1, Base2 {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
open class OverridesDifferentThrows1_2 : Base1, Base2 {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
open class OverridesDifferentThrows1_3 : Base1, Base2 {
|
||||
@Throws(Exception1::class, Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class InheritsDifferentThrowsThroughSameClass1 : InheritsDifferentThrows1() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesDifferentThrowsThroughSameClass1 : InheritsDifferentThrows1() {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesDifferentThrowsThroughSameClass2 : InheritsDifferentThrows1() {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
interface Base3 {
|
||||
@Throws(Exception3::class) fun foo()
|
||||
}
|
||||
|
||||
class InheritsDifferentThrows2 : InheritsDifferentThrows1(), Base3 {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesDifferentThrows2 : InheritsDifferentThrows1(), Base3 {
|
||||
@Throws(Exception3::class) override fun foo() {}
|
||||
}
|
||||
|
||||
open class OverridesDifferentThrows3 : Base1, Base2 {
|
||||
@Throws(Exception3::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class InheritsDifferentThrows3 : OverridesDifferentThrows3() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideDifferentThrows4 : OverridesDifferentThrows3() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideDifferentThrows5 : OverridesDifferentThrows3() {
|
||||
@Throws(Exception3::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideDifferentThrows6 : OverridesDifferentThrows3() {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
interface Base4 {
|
||||
@Throws(Exception1::class) fun foo()
|
||||
}
|
||||
|
||||
class InheritsSameThrows : Base1, Base4 {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesSameThrows : Base1, Base4 {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideDifferentThrows7 : Base1, Base4 {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideDifferentThrows8 : Base1, Base3 {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
interface Base5 {
|
||||
@Throws(Exception1::class, Exception2::class) fun foo()
|
||||
}
|
||||
|
||||
interface Base6 {
|
||||
@Throws(Exception2::class, Exception1::class) fun foo()
|
||||
}
|
||||
|
||||
class InheritsSameThrowsMultiple : Base5, Base6 {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesSameThrowsMultiple1 : Base5, Base6 {
|
||||
@Throws(Exception1::class, Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesSameThrowsMultiple2 : Base5, Base6 {
|
||||
@Throws(Exception2::class, Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesDifferentThrowsMultiple : Base5, Base6 {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
fun withLocalClass() {
|
||||
class LocalException : Throwable()
|
||||
|
||||
abstract class Base7 {
|
||||
@Throws(Exception1::class, LocalException::class) abstract fun foo()
|
||||
}
|
||||
|
||||
class InheritsDifferentThrowsLocal : Base1, Base7() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverridesDifferentThrowsLocal : Base1, Base7() {
|
||||
@Throws(Exception1::class, LocalException::class) override fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
interface ThrowsOnFakeOverride : Base1
|
||||
|
||||
class InheritThrowsOnFakeOverride : ThrowsOnFakeOverride {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideDifferentThrowsOnFakeOverride : ThrowsOnFakeOverride {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
interface IncompatibleThrowsOnFakeOverride : Base1, Base2
|
||||
|
||||
class OverrideIncompatibleThrowsOnFakeOverride1 : IncompatibleThrowsOnFakeOverride {
|
||||
@Throws(Exception1::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class OverrideIncompatibleThrowsOnFakeOverride2 : IncompatibleThrowsOnFakeOverride {
|
||||
@Throws(Exception2::class) override fun foo() {}
|
||||
}
|
||||
|
||||
class InheritIncompatibleThrowsOnFakeOverride : IncompatibleThrowsOnFakeOverride {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
@Throws
|
||||
suspend fun suspendThrowsNothing() {}
|
||||
|
||||
interface SuspendFun {
|
||||
suspend fun foo()
|
||||
}
|
||||
|
||||
class OverrideImplicitThrowsOnSuspendWithExplicit : SuspendFun {
|
||||
// Although `SuspendFun.foo` effectively has `@Throws(CancellationException::class)`,
|
||||
// overriding it with equal explicit `@Throws` is forbidden:
|
||||
@Throws(CancellationException::class) override suspend fun foo() {}
|
||||
}
|
||||
|
||||
interface SuspendFunThrows {
|
||||
@Throws(CancellationException::class) suspend fun foo() {}
|
||||
}
|
||||
|
||||
class InheritExplicitThrowsOnSuspend : SuspendFunThrows {
|
||||
override suspend fun foo() {}
|
||||
}
|
||||
|
||||
@Throws(Exception1::class)
|
||||
suspend fun suspendDoesNotThrowCancellationException1() {}
|
||||
|
||||
@Throws(Exception1::class, Exception2::class)
|
||||
suspend fun suspendDoesNotThrowCancellationException2() {}
|
||||
|
||||
@Throws(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>)
|
||||
suspend fun suspendThrowsUnresolved() {}
|
||||
|
||||
@Throws(exceptionClasses = <!ANNOTATION_ARGUMENT_MUST_BE_CONST, ARGUMENT_TYPE_MISMATCH, ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>)
|
||||
suspend fun suspendThrowsNamedUnresolved() {}
|
||||
|
||||
@Throws(exceptionClasses = [])
|
||||
suspend fun suspendThrowsNamedEmptyLiteral() {}
|
||||
|
||||
@Throws(exceptionClasses = arrayOf())
|
||||
suspend fun suspendThrowsNamedEmptyArrayOf() {}
|
||||
|
||||
@Throws(*[])
|
||||
suspend fun suspendThrowsSpreadEmptyLiteral() {}
|
||||
|
||||
@Throws(*arrayOf())
|
||||
suspend fun suspendThrowsSpreadEmptyArrayOf() {}
|
||||
|
||||
@Throws(exceptionClasses = <!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>[<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>]<!>)
|
||||
suspend fun suspendThrowsNamedLiteralWithUnresolved() {}
|
||||
|
||||
@Throws(exceptionClasses = <!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>)<!>)
|
||||
suspend fun suspendThrowsNamedArrayOfUnresolved() {}
|
||||
|
||||
@Throws(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>[<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>]<!>)
|
||||
suspend fun suspendThrowsSpreadLiteralWithUnresolved() {}
|
||||
|
||||
@Throws(*<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!><!UNRESOLVED_REFERENCE!>UE<!>::class<!>)<!>)
|
||||
suspend fun suspendThrowsSpreadArrayOfUnresolved() {}
|
||||
|
||||
@Throws(UEAlias::class)
|
||||
suspend fun suspendThrowsTypealiasToUnresolved() {}
|
||||
|
||||
@Throws(Exception1::class, CancellationException::class)
|
||||
suspend fun suspendThrowsCancellationException1() {}
|
||||
|
||||
@Throws(CancellationException::class, Exception1::class)
|
||||
suspend fun suspendThrowsCancellationException2() {}
|
||||
|
||||
typealias CancellationExceptionAlias = CancellationException
|
||||
|
||||
@Throws(CancellationExceptionAlias::class)
|
||||
suspend fun suspendThrowsCancellationExceptionTypealias() {}
|
||||
|
||||
@Throws(IllegalStateException::class)
|
||||
suspend fun suspendThrowsIllegalStateException1() {}
|
||||
|
||||
@Throws(Exception2::class, IllegalStateException::class)
|
||||
suspend fun suspendThrowsIllegalStateException2() {}
|
||||
|
||||
typealias IllegalStateExceptionAlias = IllegalStateException
|
||||
|
||||
@Throws(IllegalStateExceptionAlias::class)
|
||||
suspend fun suspendThrowsIllegalStateExceptionTypealias() {}
|
||||
|
||||
@Throws(RuntimeException::class)
|
||||
suspend fun suspendThrowsRuntimeException1() {}
|
||||
|
||||
@Throws(RuntimeException::class, Exception3::class)
|
||||
suspend fun suspendThrowsRuntimeException2() {}
|
||||
|
||||
typealias RuntimeExceptionAlias = RuntimeException
|
||||
|
||||
@Throws(RuntimeExceptionAlias::class)
|
||||
suspend fun suspendThrowsRuntimeExceptionTypealias() {}
|
||||
|
||||
@Throws(Exception::class)
|
||||
suspend fun suspendThrowsException1() {}
|
||||
|
||||
@Throws(Exception1::class, Exception::class)
|
||||
suspend fun suspendThrowsException2() {}
|
||||
|
||||
typealias ExceptionAlias = Exception
|
||||
|
||||
@Throws(ExceptionAlias::class)
|
||||
suspend fun suspendThrowsExceptionTypealias() {}
|
||||
|
||||
@Throws(Throwable::class)
|
||||
suspend fun suspendThrowsThrowable1() {}
|
||||
|
||||
@Throws(Throwable::class, Exception2::class)
|
||||
suspend fun suspendThrowsThrowable2() {}
|
||||
|
||||
@Throws(Throwable::class, CancellationException::class)
|
||||
suspend fun suspendThrowsThrowable3() {}
|
||||
|
||||
typealias ThrowableAlias = Throwable
|
||||
|
||||
@Throws(ThrowableAlias::class)
|
||||
suspend fun suspendThrowsThrowableTypealias() {}
|
||||
@@ -0,0 +1,179 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: throws.kt
|
||||
package kotlin
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Throws(vararg val ThrowableClasses: KClass<out Throwable>)
|
||||
|
||||
// FILE: native.kt
|
||||
package kotlin.native
|
||||
|
||||
@Deprecated("")
|
||||
public typealias Throws = kotlin.Throws
|
||||
|
||||
// FILE: main1.kt
|
||||
package abc1
|
||||
|
||||
@Throws(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: Throws) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main2.kt
|
||||
package abc2
|
||||
|
||||
import kotlin.native.Throws
|
||||
|
||||
@<!DEPRECATION!>Throws<!>(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: <!DEPRECATION!>Throws<!>) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main3.kt
|
||||
package abc3
|
||||
|
||||
import kotlin.Throws
|
||||
|
||||
@Throws(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: Throws) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main4.kt
|
||||
package abc4
|
||||
|
||||
import kotlin.<!CONFLICTING_IMPORT!>Throws<!>
|
||||
import kotlin.native.<!CONFLICTING_IMPORT!>Throws<!>
|
||||
|
||||
@<!OVERLOAD_RESOLUTION_AMBIGUITY!>Throws<!>(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: <!OVERLOAD_RESOLUTION_AMBIGUITY!>Throws<!>) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main5.kt
|
||||
package abc5
|
||||
|
||||
import kotlin.native.*
|
||||
|
||||
@<!DEPRECATION!>Throws<!>(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: <!DEPRECATION!>Throws<!>) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main6.kt
|
||||
package abc6
|
||||
|
||||
import kotlin.*
|
||||
|
||||
@Throws(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: Throws) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main7.kt
|
||||
package abc7
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.native.*
|
||||
|
||||
@<!OVERLOAD_RESOLUTION_AMBIGUITY!>Throws<!>(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: <!OVERLOAD_RESOLUTION_AMBIGUITY!>Throws<!>) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main8.kt
|
||||
package abc8
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.native.Throws
|
||||
|
||||
@<!DEPRECATION!>Throws<!>(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: <!DEPRECATION!>Throws<!>) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
|
||||
// FILE: main9.kt
|
||||
package abc9
|
||||
|
||||
import kotlin.native.*
|
||||
import kotlin.Throws
|
||||
|
||||
@Throws(Throwable::class)
|
||||
fun foo1() {}
|
||||
|
||||
@kotlin.Throws(Throwable::class)
|
||||
fun foo2() {}
|
||||
|
||||
@<!DEPRECATION!>kotlin.native.Throws<!>(Throwable::class)
|
||||
fun foo3() {}
|
||||
|
||||
fun foo5(x: Throws) {}
|
||||
fun foo6(x: kotlin.Throws) {}
|
||||
fun foo7(x: <!DEPRECATION!>kotlin.native.Throws<!>) {}
|
||||
@@ -0,0 +1,114 @@
|
||||
// FILE: annotation.kt
|
||||
package kotlin.native.concurrent
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class ThreadLocal
|
||||
|
||||
// FILE: test.kt
|
||||
import kotlin.native.concurrent.ThreadLocal
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate {
|
||||
val value: Int = 10
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Int {
|
||||
return value
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
class AtomicInt(var value: Int)
|
||||
object Foo {
|
||||
var field1: Int = 10
|
||||
val backer2 = AtomicInt(0)
|
||||
var field2: Int
|
||||
get() = backer2.value
|
||||
set(value: Int) { backer2.value = value }
|
||||
}
|
||||
|
||||
object Foo1 {
|
||||
var field1: Int = 10
|
||||
set(value: Int) { backer2.value = value }
|
||||
val backer2 = AtomicInt(0)
|
||||
}
|
||||
|
||||
object WithDelegate {
|
||||
var field1: Int by Delegate()
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
object Bar {
|
||||
var field1: Int = 10
|
||||
var field2: String? = null
|
||||
}
|
||||
|
||||
class Foo2 {
|
||||
companion object {
|
||||
var field1: Int = 10
|
||||
val backer2 = AtomicInt(0)
|
||||
var field2: Int
|
||||
get() = backer2.value
|
||||
set(value: Int) {
|
||||
backer2.value = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Bar2 {
|
||||
@ThreadLocal
|
||||
companion object {
|
||||
var field1: Int = 10
|
||||
var field2: String? = null
|
||||
}
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
enum class Color(var rgb: Int) {
|
||||
RED(0xFF0000),
|
||||
GREEN(0x00FF00),
|
||||
BLUE(0x0000FF)
|
||||
}
|
||||
|
||||
enum class Color1(var rgb: Int) {
|
||||
RED(0xFF0000),
|
||||
GREEN(0x00FF00),
|
||||
BLUE(0x0000FF);
|
||||
|
||||
init { this.rgb += 1 }
|
||||
}
|
||||
|
||||
@ThreadLocal
|
||||
var a = 3
|
||||
enum class Color2() {
|
||||
RED(),
|
||||
GREEN(),
|
||||
BLUE();
|
||||
|
||||
var rgb: Int = 2
|
||||
set(value: Int) {
|
||||
a = value
|
||||
}
|
||||
}
|
||||
|
||||
enum class Color3() {
|
||||
RED(),
|
||||
GREEN(),
|
||||
BLUE();
|
||||
|
||||
var field1: Int by Delegate()
|
||||
}
|
||||
|
||||
enum class Color4 {
|
||||
RED {
|
||||
var a = 2
|
||||
override fun foo() { a = 42 }
|
||||
},
|
||||
GREEN,
|
||||
BLUE;
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
var topLevelProperty = "Global var"
|
||||
Reference in New Issue
Block a user