Add regression tests
KT-32358
This commit is contained in:
Generated
+15
@@ -20445,6 +20445,21 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_1.kt")
|
||||||
|
public void testKt32358_1() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_2.kt")
|
||||||
|
public void testKt32358_2() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_3.kt")
|
||||||
|
public void testKt32358_3() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3244.kt")
|
@TestMetadata("kt3244.kt")
|
||||||
public void testKt3244() throws Exception {
|
public void testKt3244() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3244.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3244.kt");
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
|
||||||
|
class MyChild {
|
||||||
|
val nullableString: String? = null
|
||||||
|
val notNull = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyParent {
|
||||||
|
val child: MyChild? = MyChild()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun myFun() {
|
||||||
|
val myParent = MyParent()
|
||||||
|
myParent.child?.nullableString ?: run { return }
|
||||||
|
|
||||||
|
myParent.child.notNull // <- No smart cast in plugin
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
|
||||||
|
class MyChild {
|
||||||
|
val nullableString: String? = null
|
||||||
|
val notNull = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyParent {
|
||||||
|
val child: MyChild? = MyChild()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun myFun() {
|
||||||
|
val myParent = MyParent()
|
||||||
|
myParent.child?.nullableString ?: run { return }
|
||||||
|
|
||||||
|
<!DEBUG_INFO_SMARTCAST!>myParent.child<!>.notNull // <- No smart cast in plugin
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun myFun(): kotlin.Unit
|
||||||
|
|
||||||
|
public final class MyChild {
|
||||||
|
public constructor MyChild()
|
||||||
|
public final val notNull: kotlin.String = ""
|
||||||
|
public final val nullableString: kotlin.String? = null
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class MyParent {
|
||||||
|
public constructor MyParent()
|
||||||
|
public final val child: MyChild?
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
import kotlin.contracts.*
|
||||||
|
|
||||||
|
inline fun <R> callIt(fn: () -> R): R = TODO()
|
||||||
|
|
||||||
|
inline fun <R> callItContracted(fn: () -> R): R {
|
||||||
|
contract {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>callsInPlace<!>(fn, InvocationKind.EXACTLY_ONCE)
|
||||||
|
}
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun smartIt(p1: String?, p2: String?) {
|
||||||
|
p1 ?: callIt { return }
|
||||||
|
p1.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||||
|
|
||||||
|
p2 ?: callItContracted { return }
|
||||||
|
p2.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
import kotlin.contracts.*
|
||||||
|
|
||||||
|
inline fun <R> callIt(fn: () -> R): R = TODO()
|
||||||
|
|
||||||
|
inline fun <R> callItContracted(fn: () -> R): R {
|
||||||
|
contract {
|
||||||
|
callsInPlace(fn, InvocationKind.EXACTLY_ONCE)
|
||||||
|
}
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun smartIt(p1: String?, p2: String?) {
|
||||||
|
p1 ?: callIt { return }
|
||||||
|
<!DEBUG_INFO_SMARTCAST!>p1<!>.length
|
||||||
|
|
||||||
|
p2 ?: callItContracted { return }
|
||||||
|
<!DEBUG_INFO_SMARTCAST!>p2<!>.length
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public inline fun </*0*/ R> callIt(/*0*/ fn: () -> R): R
|
||||||
|
public inline fun </*0*/ R> callItContracted(/*0*/ fn: () -> R): R
|
||||||
|
CallsInPlace(fn, EXACTLY_ONCE)
|
||||||
|
|
||||||
|
public fun smartIt(/*0*/ p1: kotlin.String?, /*1*/ p2: kotlin.String?): kotlin.Unit
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
// no inline modifier
|
||||||
|
fun <R> callIt(fn: () -> R): R = TODO()
|
||||||
|
|
||||||
|
fun smartIt(p1: String?, p2: String?) {
|
||||||
|
p1 ?: callIt { TODO() }
|
||||||
|
p1.<!INAPPLICABLE_CANDIDATE!>length<!> // smartcast
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
// no inline modifier
|
||||||
|
fun <R> callIt(fn: () -> R): R = TODO()
|
||||||
|
|
||||||
|
fun smartIt(p1: String?, p2: String?) {
|
||||||
|
p1 ?: callIt { TODO() }
|
||||||
|
<!DEBUG_INFO_SMARTCAST!>p1<!>.length // smartcast
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ R> callIt(/*0*/ fn: () -> R): R
|
||||||
|
public fun smartIt(/*0*/ p1: kotlin.String?, /*1*/ p2: kotlin.String?): kotlin.Unit
|
||||||
@@ -20522,6 +20522,21 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_1.kt")
|
||||||
|
public void testKt32358_1() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_2.kt")
|
||||||
|
public void testKt32358_2() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_3.kt")
|
||||||
|
public void testKt32358_3() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3244.kt")
|
@TestMetadata("kt3244.kt")
|
||||||
public void testKt3244() throws Exception {
|
public void testKt3244() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3244.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3244.kt");
|
||||||
|
|||||||
Generated
+15
@@ -20447,6 +20447,21 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_1.kt")
|
||||||
|
public void testKt32358_1() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_2.kt")
|
||||||
|
public void testKt32358_2() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt32358_3.kt")
|
||||||
|
public void testKt32358_3() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt32358_3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3244.kt")
|
@TestMetadata("kt3244.kt")
|
||||||
public void testKt3244() throws Exception {
|
public void testKt3244() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3244.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3244.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user