Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed
This commit is contained in:
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
package test
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class AnnClass(val a: KClass<*>)
|
||||
|
||||
class MyClass {
|
||||
|
||||
@AnnClass(MyClass::class)
|
||||
companion object {
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
package test
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class C {
|
||||
val plainField: Int = 1
|
||||
@delegate:Transient
|
||||
val lazy by lazy { 1 }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class C {
|
||||
val plainField: Int = 1
|
||||
@delegate:Transient
|
||||
|
||||
compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.fir.kt
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
double b();
|
||||
Class<?> x1();
|
||||
int a();
|
||||
String value();
|
||||
Class<?> x();
|
||||
Class<?> x2();
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
double b();
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
double b();
|
||||
Class<?> x1();
|
||||
int a();
|
||||
Class<?> x();
|
||||
Class<?> x2();
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
double b();
|
||||
|
||||
compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.fir.kt
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
String[] value();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A("1", "2", "3") fun test1() {}
|
||||
|
||||
@A("4") fun test2() {}
|
||||
|
||||
@A(*arrayOf("5", "6"), "7") fun test3() {}
|
||||
|
||||
@A() fun test4() {}
|
||||
|
||||
@A fun test5() {}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
String[] value();
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
String[] value() default {"abc", "cde"};
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A("1", "2", "3") fun test1() {}
|
||||
|
||||
@A("4") fun test2() {}
|
||||
|
||||
@A(*arrayOf("5", "6"), "7") fun test3() {}
|
||||
|
||||
@A() fun test4() {}
|
||||
|
||||
@A fun test5() {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
String[] value() default {"abc", "cde"};
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(arg = String::class) class MyClass3
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg();
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg();
|
||||
int x() default 1;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(arg = String::class) class MyClass1
|
||||
@A(arg = String::class, x = 2) class MyClass2
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg();
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?>[] arg();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(arg = arrayOf(String::class, Int::class)) class MyClass
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?>[] arg();
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(arg = String::class) class MyClass1
|
||||
@A class MyClass2
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
int x();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(arg = String::class, x = 4) class MyClass2
|
||||
@A(x = 5) class MyClass3
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg1();
|
||||
Class<?> arg2();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(arg1 = String::class, arg2 = Int::class) class MyClass
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg1();
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(String::class) class MyClass1
|
||||
@A(value = String::class) class MyClass2
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value();
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value();
|
||||
int x() default 1;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(String::class) class MyClass1
|
||||
@A(value = String::class) class MyClass2
|
||||
|
||||
@A(String::class, x = 2) class MyClass3
|
||||
@A(value = String::class, x = 4) class MyClass4
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value();
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(String::class, Int::class) class MyClass1
|
||||
@A(*arrayOf(String::class, Int::class)) class MyClass2
|
||||
@A(value = [String::class, Int::class]) class MyClass3
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?>[] value();
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value() default Integer.class;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(String::class) class MyClass1
|
||||
@A(value = String::class) class MyClass2
|
||||
@A class MyClass3
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value() default Integer.class;
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value() default Integer.class;
|
||||
int x();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
@A(String::class, x = 2) class MyClass1
|
||||
@A(value = String::class, x = 4) class MyClass2
|
||||
@A(x = 5) class MyClass3
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value() default Integer.class;
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
@file:JvmName("SomeName")
|
||||
|
||||
@JvmField
|
||||
val c = 4
|
||||
|
||||
@JvmField
|
||||
var g = 5
|
||||
|
||||
class C {
|
||||
@JvmField
|
||||
var g = 5
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
@file:JvmName("SomeName")
|
||||
|
||||
@JvmField
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
open class A
|
||||
class B1 : A()
|
||||
class B2 : A()
|
||||
|
||||
annotation class Ann1(val arg: Array<out KClass<out A>>)
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
open class A
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
annotation class Ann(val x: Int, val value: String, val y: Double)
|
||||
|
||||
@Ann(value = "a", x = 1, y = 1.0) fun foo1() {}
|
||||
@Ann(2, "b", 2.0) fun foo2() {}
|
||||
@Ann(3, "c", y = 2.0) fun foo3() {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
annotation class Ann(val x: Int, val value: String, val y: Double)
|
||||
|
||||
@Ann(value = "a", x = 1, y = 1.0) fun foo1() {}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// FILE: TargetUse.java
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
public class TargetUse {
|
||||
public static String foo(kotlin.annotation.Target aTarget) {
|
||||
return aTarget.toString();
|
||||
}
|
||||
|
||||
public static String bar(Target aTarget) {
|
||||
return aTarget.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: TargetUse.kt
|
||||
|
||||
import java.lang.annotation.Target as JTarget
|
||||
|
||||
fun fooUse(aTarget: Target): String = TargetUse.foo(aTarget)
|
||||
|
||||
fun barUse(aTarget: JTarget): String = TargetUse.bar(aTarget)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: TargetUse.java
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
inline fun <T> myRun(block: () -> T): T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return block()
|
||||
}
|
||||
|
||||
fun functionWithExpressionBody(x: Int): Boolean = myRun {
|
||||
if (x == 0) return true
|
||||
if (x == 1) return false
|
||||
return functionWithExpressionBody(x - 2)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
inline fun myRun(block: () -> Unit): Unit {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return block()
|
||||
}
|
||||
|
||||
inline fun unknownRun(block: () -> Unit) { block() }
|
||||
|
||||
fun foo() {
|
||||
val x: Int
|
||||
myRun {
|
||||
unknownRun { println("shouldn't change anything") }
|
||||
x = 42
|
||||
}
|
||||
println(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
inline fun <T, R> T.myLet(block: (T) -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return block(this)
|
||||
}
|
||||
|
||||
|
||||
fun nonLocalReturnWithElvis(x: Int?): Int? {
|
||||
x?.myLet { return 42 }
|
||||
return x?.inc()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
fun <T> myRun(block: () -> T): T {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return block()
|
||||
}
|
||||
|
||||
fun definiteVarInitialization() {
|
||||
var x: Int
|
||||
myRun { x = 42 }
|
||||
x.inc()
|
||||
}
|
||||
|
||||
fun definiteVarReassignment() {
|
||||
var x: Int
|
||||
myRun { x = 42 }
|
||||
x.inc()
|
||||
myRun { x = 43 }
|
||||
x.inc()
|
||||
x = 44
|
||||
x.inc()
|
||||
}
|
||||
|
||||
fun nestedVarInitialization() {
|
||||
var x: Int
|
||||
myRun { myRun { myRun { x = 42 } } }
|
||||
x.inc()
|
||||
myRun { myRun { myRun { x = 42 } } }
|
||||
}
|
||||
|
||||
|
||||
fun notAnExpression() {
|
||||
var x: Int = 0
|
||||
myRun { if (true) x = 42 }
|
||||
x.inc()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
Vendored
-42
@@ -1,42 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
package my
|
||||
|
||||
// Accepts block, can't be distinguished from kotlin.contract without resolve
|
||||
fun contract(block: () -> Unit) {}
|
||||
|
||||
// Accepts int, potentially can be distinguished from kotlin.contract by PSI,
|
||||
// but as of Kotlin 1.3.0, we don't do that
|
||||
fun contract(i: Int) {}
|
||||
|
||||
fun doStuff() {}
|
||||
|
||||
class SomeClass {
|
||||
|
||||
fun contract() {}
|
||||
|
||||
fun callMemberContractWithThis() {
|
||||
this.contract()
|
||||
}
|
||||
|
||||
fun callMemberContractWithoutThis() {
|
||||
contract()
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsiInMember() {
|
||||
contract { }
|
||||
}
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsi() {
|
||||
contract { }
|
||||
}
|
||||
|
||||
fun callTopLevelDifferentPsi() {
|
||||
contract(42)
|
||||
}
|
||||
|
||||
fun callTopLevelSamePsiNotFirstStatement() {
|
||||
doStuff()
|
||||
contract { }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
package my
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !LANGUAGE: +UseReturnsEffect
|
||||
// Issue: KT-26386
|
||||
|
||||
fun myRun(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
fun contract(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
fun case_1(): Boolean? {
|
||||
contract { case_1() }
|
||||
return null
|
||||
}
|
||||
|
||||
fun case_2(): Boolean? {
|
||||
contract { case_3() }
|
||||
return null
|
||||
}
|
||||
|
||||
fun case_3(): Boolean? {
|
||||
contract { case_2() }
|
||||
return null
|
||||
}
|
||||
|
||||
fun case4() {
|
||||
contract {
|
||||
myRun {
|
||||
val s: String
|
||||
run {
|
||||
s = "hello"
|
||||
}
|
||||
s.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !LANGUAGE: +UseReturnsEffect
|
||||
// Issue: KT-26386
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
import kotlin.contracts.InvocationKind
|
||||
|
||||
inline fun foo(block: () -> Unit) {
|
||||
kotlin.contracts.contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x: Int
|
||||
foo {
|
||||
x = 42
|
||||
}
|
||||
println(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// See KT-28847
|
||||
|
||||
class Foo(val str: String?) {
|
||||
val first = run {
|
||||
str.isNullOrEmpty()
|
||||
second
|
||||
}
|
||||
|
||||
val second = str.isNullOrEmpty()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// See KT-28847
|
||||
|
||||
class Foo(val str: String?) {
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect
|
||||
|
||||
fun test(lock: Any) {
|
||||
val x: Int
|
||||
|
||||
synchronized(lock) {
|
||||
x = 42
|
||||
}
|
||||
|
||||
x.inc()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect
|
||||
|
||||
fun test(lock: Any) {
|
||||
|
||||
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
fun Any.nullWhenString(): Any? {
|
||||
contract {
|
||||
returns(null) implies (this@nullWhenString is String)
|
||||
}
|
||||
return if (this is String) null else this
|
||||
}
|
||||
|
||||
fun test(x: Int?) {
|
||||
if (x?.nullWhenString() == null) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// !API_VERSION: 1.2
|
||||
|
||||
import java.io.InputStream
|
||||
|
||||
fun InputStream.test() {
|
||||
readBytes()
|
||||
|
||||
readBytes(1)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !API_VERSION: 1.2
|
||||
|
||||
import java.io.InputStream
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class C {
|
||||
val `x$delegate`: ReadWriteProperty<Any, Any>? = null
|
||||
val x: String? by Delegates.notNull()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@JvmName("bar")
|
||||
fun foo(a: Any) {}
|
||||
|
||||
fun Any.foo() {}
|
||||
|
||||
@JvmName("barInt")
|
||||
fun bar(x: List<Int>) {}
|
||||
|
||||
@JvmName("barStr")
|
||||
fun bar(x: List<String>) {}
|
||||
|
||||
class C {
|
||||
var rwProp: Int
|
||||
@JvmName("get_rwProp")
|
||||
get() = 0
|
||||
@JvmName("set_rwProp")
|
||||
set(v) {}
|
||||
|
||||
fun getRwProp(): Int = 123
|
||||
fun setRwProp(v: Int) {}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@JvmName("bar")
|
||||
fun foo(a: Any) {}
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: foo/A.java
|
||||
|
||||
package foo;
|
||||
|
||||
public class A {
|
||||
private static void foo(int s) {}
|
||||
static void bar(double s) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
import foo.A
|
||||
|
||||
open class K : A() {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun foo(i: Int) {}
|
||||
@JvmStatic
|
||||
fun bar(d: Double) {}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: foo/A.java
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
fun foo(x: Int?) {
|
||||
// Both parts of the Elvis should be alive, see KT-7936
|
||||
x?.let {
|
||||
smth()
|
||||
}?: orElse()
|
||||
}
|
||||
|
||||
fun smth() {}
|
||||
fun orElse() {}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun foo(x: Int?) {
|
||||
// Both parts of the Elvis should be alive, see KT-7936
|
||||
x?.let {
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
interface I
|
||||
|
||||
@ExperimentalAPI
|
||||
class Impl : I
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
open class Base(val i: I)
|
||||
|
||||
@OptIn(ExperimentalAPI::class)
|
||||
class Derived : Base(Impl())
|
||||
|
||||
@OptIn(ExperimentalAPI::class)
|
||||
class Delegated : I by Impl()
|
||||
|
||||
@OptIn(ExperimentalAPI::class)
|
||||
val delegatedProperty by Impl()
|
||||
operator fun I.getValue(x: Any?, y: Any?) = null
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// FILE: api.kt
|
||||
|
||||
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// !EXPERIMENTAL: api.ExperimentalAPI
|
||||
// MODULE: api
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@RequiresOptIn
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
fun function(): String = ""
|
||||
|
||||
// MODULE: usage(api)
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
function()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// !EXPERIMENTAL: api.ExperimentalAPI
|
||||
// MODULE: api
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
|
||||
package test.abc
|
||||
|
||||
@RequiresOptIn
|
||||
annotation class E
|
||||
|
||||
@OptIn(test.abc.E::class)
|
||||
fun f() {}
|
||||
|
||||
@test.abc.E
|
||||
fun g() {}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
|
||||
package test.abc
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// FILE: api.kt
|
||||
|
||||
package feature.experimental.self
|
||||
|
||||
@RequiresOptIn
|
||||
annotation class ImportedMarker
|
||||
|
||||
@ImportedMarker
|
||||
object ImportedClass {
|
||||
@ImportedMarker
|
||||
fun importedObjectMember() {}
|
||||
}
|
||||
|
||||
@ImportedMarker
|
||||
fun importedFunction() {}
|
||||
|
||||
@ImportedMarker
|
||||
val importedProperty = Unit
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
import feature.experimental.self.ImportedMarker
|
||||
import feature.experimental.self.ImportedClass
|
||||
import feature.experimental.self.importedFunction
|
||||
import feature.experimental.self.importedProperty
|
||||
import feature.experimental.self.ImportedClass.importedObjectMember
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// FILE: api.kt
|
||||
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
annotation class VeryExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
@VeryExperimentalAPI
|
||||
fun f() {}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun g() {}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
@file:OptIn(ExperimentalAPI::class, VeryExperimentalAPI::class)
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun usage() {
|
||||
f()
|
||||
g()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// FILE: api.kt
|
||||
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn api.ExperimentalAPI
|
||||
// MODULE: api
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
fun function(): String = ""
|
||||
|
||||
// MODULE: usage(api)
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
function()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn api.ExperimentalAPI
|
||||
// MODULE: api
|
||||
// FILE: api.kt
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class E
|
||||
|
||||
@E
|
||||
open class Foo(val s: String = "")
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
import api.*
|
||||
|
||||
@OptIn(E::class)
|
||||
class Klass {
|
||||
init {
|
||||
Foo()
|
||||
}
|
||||
}
|
||||
|
||||
class Constructor {
|
||||
@OptIn(E::class) constructor() {
|
||||
Foo()
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(E::class)
|
||||
val property = Foo().s
|
||||
|
||||
@OptIn(E::class)
|
||||
fun function() {
|
||||
Foo()
|
||||
}
|
||||
|
||||
fun valueParameter(@OptIn(E::class) p: String = Foo().s): String {
|
||||
@OptIn(E::class)
|
||||
val localVariable: String = Foo().s
|
||||
return localVariable
|
||||
}
|
||||
|
||||
var propertyAccessors: String
|
||||
@OptIn(E::class)
|
||||
get() = Foo().s
|
||||
@OptIn(E::class)
|
||||
set(value) { Foo() }
|
||||
|
||||
fun expression(): String {
|
||||
val s = @OptIn(E::class) Foo().s
|
||||
return s
|
||||
}
|
||||
|
||||
@OptIn(E::class)
|
||||
typealias TypeAlias = Foo
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: api.kt
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
// SKIP_TXT
|
||||
|
||||
var xs: IntArray = intArrayOf(1, 2, 3)
|
||||
get() = field
|
||||
set(ys) {
|
||||
var sum = 0
|
||||
for (x in field) {
|
||||
sum = sum * 10 + x
|
||||
field = intArrayOf(4, 5, 6)
|
||||
}
|
||||
if (sum != 123) throw AssertionError("sum=$sum")
|
||||
field = ys
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
// SKIP_TXT
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
// SKIP_TXT
|
||||
|
||||
class Delegate<T>(var v: T) {
|
||||
operator fun getValue(thisRef: Any?, kProp: Any?) = v
|
||||
operator fun setValue(thisRef: Any?, kProp: Any?, value: T) { v = value }
|
||||
}
|
||||
|
||||
fun testLocalDelegatedProperty() {
|
||||
var xs by Delegate(arrayOf("a", "b", "c"))
|
||||
for (x in xs) {
|
||||
println(x)
|
||||
xs = arrayOf("d", "e", "f")
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
// SKIP_TXT
|
||||
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
// !LANGUAGE: +ProperForInArrayLoopRangeVariableAssignmentSemantic
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
// SKIP_TXT
|
||||
|
||||
fun testObjectArray() {
|
||||
var xs = arrayOf("a", "b", "c")
|
||||
for (x in xs) {
|
||||
println(x)
|
||||
xs = arrayOf("d", "e", "f")
|
||||
}
|
||||
}
|
||||
|
||||
fun testPrimitiveArray() {
|
||||
var xs = intArrayOf(1, 2, 3)
|
||||
for (x in xs) {
|
||||
println(x)
|
||||
xs = intArrayOf(4, 5, 6)
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +ProperForInArrayLoopRangeVariableAssignmentSemantic
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
// SKIP_TXT
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// FILE: Java.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class Java {
|
||||
public static List<Integer> get(List<Integer> o) { return o; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun call(): List<Int> {
|
||||
// No errors should be here
|
||||
return Java.get(if (true) ArrayList<Int>() else listOf(0))
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: Java.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
//!DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <R> Iterable<*>.filterIsInstance1(): List<@kotlin.internal.NoInfer R> = throw Exception()
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <R> List<*>.filterIsInstance2(): @kotlin.internal.NoInfer List<R> = throw Exception()
|
||||
|
||||
fun test(list: List<Int>) {
|
||||
list.filterIsInstance1<Int>().map { it * 2 }
|
||||
list.filterIsInstance2<Int>().filter { it > 10 }
|
||||
}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <R> foo(t: R): List<@kotlin.internal.NoInfer R> = throw Exception("$t")
|
||||
|
||||
fun test() {
|
||||
foo(1).map { it * 2 }
|
||||
}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <R> List<R>.foo(): @kotlin.internal.NoInfer R = throw Exception()
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <R> bar(r: R, f: Function1<@kotlin.internal.NoInfer R, Unit>): Nothing = throw Exception()
|
||||
|
||||
fun test1() {
|
||||
listOf("").foo().length
|
||||
bar(1) { x -> x + 1 }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//!DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
annotation class Anno
|
||||
|
||||
fun test(a: List<Class<Anno>>) {
|
||||
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
|
||||
}
|
||||
|
||||
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: TestBase.java
|
||||
|
||||
public class TestBase<T> { }
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test<K> extends TestBase<K> { }
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes K> TestBase<out K>.foo(key: K) = null
|
||||
fun foo(result: Test<*>) {
|
||||
result.foo("sd") // Type inference failed (NI), OK in OI
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user