Add addtional tests for builder inference

This commit is contained in:
Victor Petukhov
2021-05-11 17:17:49 +03:00
parent ecde5414dc
commit 0b37b2be6a
54 changed files with 962 additions and 173 deletions
@@ -0,0 +1,33 @@
// !LANGUAGE: +StableBuilderInference
// WITH_RUNTIME
interface A {
fun foo(): MutableList<String>
}
@ExperimentalStdlibApi
fun main() {
buildList {
add(3)
object : A {
override fun foo(): MutableList<String> = this@buildList
}
}
buildList {
add(3)
val x: String = get(0)
}
buildList {
add("3")
val x: MutableList<Int> = this@buildList
}
buildList {
val y: CharSequence = ""
add(y)
val x: MutableList<String> = this@buildList
}
buildList {
add("")
val x: StringBuilder = get(0)
}
}
@@ -0,0 +1,33 @@
// !LANGUAGE: +StableBuilderInference
// WITH_RUNTIME
interface A {
fun foo(): MutableList<String>
}
@ExperimentalStdlibApi
fun main() {
buildList {
add(<!CONSTANT_EXPECTED_TYPE_MISMATCH, CONSTANT_EXPECTED_TYPE_MISMATCH!>3<!>)
object : A {
override fun foo(): MutableList<String> = this@buildList
}
}
buildList {
add(<!CONSTANT_EXPECTED_TYPE_MISMATCH, CONSTANT_EXPECTED_TYPE_MISMATCH!>3<!>)
val x: String = get(0)
}
buildList {
add(<!TYPE_MISMATCH, TYPE_MISMATCH!>"3"<!>)
val x: MutableList<Int> = this@buildList
}
buildList {
val y: CharSequence = ""
add(<!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>y<!>)
val x: MutableList<String> = this@buildList
}
buildList {
add(<!TYPE_MISMATCH, TYPE_MISMATCH!>""<!>)
val x: StringBuilder = get(0)
}
}
@@ -0,0 +1,11 @@
package
@kotlin.ExperimentalStdlibApi public fun main(): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.collections.MutableList<kotlin.String>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,39 +1,69 @@
// !LANGUAGE: +StableBuilderInference
// WITH_RUNTIME
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -CAST_NEVER_SUCCEEDS
interface A {
fun foo(): MutableList<String>
}
fun <K> id(x: K): K = x
fun <K, V> build(@BuilderInference builderAction: MutableMap<K, V>.() -> V) {}
fun <K, V> build2(@BuilderInference builderAction: MutableMap<K, V>.() -> K) {}
fun <K, V> build3(@BuilderInference builderAction: MutableMap<K, V>.(K) -> Unit) {}
fun <K, V> build4(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<String, Int>) {}
fun <K : V, V : CharSequence> build5(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<String, V>) {}
fun <K : V, V : CharSequence> build6(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<K, String>) {}
fun <K : V, V : CharSequence> build7(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<String, V>) = null as MutableMap<String, V>
@ExperimentalStdlibApi
fun main() {
buildList {
add(3)
object : A {
override fun foo(): MutableList<String> = this@buildList
}
}
buildList {
add(3)
val x: String = get(0)
}
buildList {
add("3")
val x: MutableList<Int> = this@buildList
}
buildList {
val y: CharSequence = ""
add(y)
val x: MutableList<String> = this@buildList
}
buildList {
add("")
val x: MutableList<CharSequence> = this@buildList
}
buildList {
add("")
val x: StringBuilder = get(0)
}
buildMap {
val x: Function2<String, Char, Char?> = ::put
}
}
build {
get("")
""
}
build2 {
val x: String = this.values.first()
1
}
build2 {
take(this.values.first())
1
}
build3 { key: String ->
take(this.values.first())
}
build3 { this.foo() }
build4 { this }
build4 { this.run { this } }
build4 { run { this } }
build4 { id(run { this }) }
build5 { id(run { this }) }
build6 { id(run { this }) }
val x: MutableMap<String, CharSequence> = build7 {
id(run { this })
}
}
fun MutableMap<String, Int>.foo() {}
fun take(x: String) {}
@@ -1,9 +1,6 @@
// !LANGUAGE: +StableBuilderInference
// WITH_RUNTIME
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR
interface A {
fun foo(): MutableList<String>
}
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -CAST_NEVER_SUCCEEDS
fun <K> id(x: K): K = x
@@ -19,37 +16,14 @@ fun <K : V, V : CharSequence> build5(@BuilderInference builderAction: MutableMap
fun <K : V, V : CharSequence> build6(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<K, String>) {}
fun <K : V, V : CharSequence> build7(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<String, V>): MutableMap<String, V> {}
fun <K : V, V : CharSequence> build7(@BuilderInference builderAction: MutableMap<K, V>.() -> MutableMap<String, V>) = null as MutableMap<String, V>
@ExperimentalStdlibApi
fun main() {
buildList {
add(<!CONSTANT_EXPECTED_TYPE_MISMATCH, CONSTANT_EXPECTED_TYPE_MISMATCH!>3<!>)
object : A {
override fun foo(): MutableList<String> = this@buildList
}
}
buildList {
add(<!CONSTANT_EXPECTED_TYPE_MISMATCH, CONSTANT_EXPECTED_TYPE_MISMATCH!>3<!>)
val x: String = get(0)
}
buildList {
add(<!TYPE_MISMATCH, TYPE_MISMATCH!>"3"<!>)
val x: MutableList<Int> = this@buildList
}
buildList {
val y: CharSequence = ""
add(<!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>y<!>)
val x: MutableList<String> = this@buildList
}
buildList {
add("")
val x: MutableList<CharSequence> = this@buildList
}
buildList {
add(<!TYPE_MISMATCH, TYPE_MISMATCH!>""<!>)
val x: StringBuilder = get(0)
}
buildMap {
val x: Function2<String, Char, Char?> = ::put
}
@@ -6,14 +6,9 @@ public fun </*0*/ K, /*1*/ V> build3(/*0*/ @kotlin.BuilderInference builderActio
public fun </*0*/ K, /*1*/ V> build4(/*0*/ @kotlin.BuilderInference builderAction: kotlin.collections.MutableMap<K, V>.() -> kotlin.collections.MutableMap<kotlin.String, kotlin.Int>): kotlin.Unit
public fun </*0*/ K : V, /*1*/ V : kotlin.CharSequence> build5(/*0*/ @kotlin.BuilderInference builderAction: kotlin.collections.MutableMap<K, V>.() -> kotlin.collections.MutableMap<kotlin.String, V>): kotlin.Unit
public fun </*0*/ K : V, /*1*/ V : kotlin.CharSequence> build6(/*0*/ @kotlin.BuilderInference builderAction: kotlin.collections.MutableMap<K, V>.() -> kotlin.collections.MutableMap<K, kotlin.String>): kotlin.Unit
public fun </*0*/ K : V, /*1*/ V : kotlin.CharSequence> build7(/*0*/ @kotlin.BuilderInference builderAction: kotlin.collections.MutableMap<K, V>.() -> kotlin.collections.MutableMap<kotlin.String, V>): kotlin.collections.MutableMap<kotlin.String, V>
public fun </*0*/ K> id(/*0*/ x: K): K
@kotlin.ExperimentalStdlibApi public fun main(): kotlin.Unit
public fun take(/*0*/ x: kotlin.String): kotlin.Unit
public fun kotlin.collections.MutableMap<kotlin.String, kotlin.Int>.foo(): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.collections.MutableList<kotlin.String>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -30,7 +30,7 @@ fun foo7() = null as Foo7<Int>
interface FlowCollector<in T> {}
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit) = Flow(block)
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit): Flow<L> = Flow(block)
class Flow<out R>(private val block: suspend FlowCollector<R>.() -> Unit)
@@ -39,7 +39,7 @@ fun <R> select(vararg x: R) = x[0]
fun poll0(): Flow<String> {
return flow {
val inv = <!NEW_INFERENCE_ERROR!>select(::bar, ::foo)<!>
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -123,7 +123,7 @@ fun poll14(flag: Boolean): Flow<String> {
fun poll15(flag: Boolean): Flow<String> {
return flow {
val inv = if (flag) { ::bar5 } else { ::foo5 }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -144,7 +144,7 @@ fun poll17(flag: Boolean): Flow<String> {
fun poll2(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> ::bar else -> ::foo }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -193,7 +193,7 @@ fun poll26(flag: Boolean): Flow<String> {
fun poll3(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> ::bar false -> ::foo }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -242,7 +242,7 @@ fun poll36(flag: Boolean): Flow<String> {
fun poll4(): Flow<String> {
return flow {
val inv = try { ::bar } finally { ::foo }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -270,7 +270,7 @@ fun poll43(): Flow<String> {
fun poll44(): Flow<String> {
return flow {
val inv = try { ::bar5 } finally { ::foo5 }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -291,7 +291,7 @@ fun poll46(): Flow<String> {
fun poll5(): Flow<String> {
return flow {
val inv = try { ::bar } catch (e: Exception) { ::foo } finally { ::foo }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -319,7 +319,7 @@ fun poll53(): Flow<String> {
fun poll54(): Flow<String> {
return flow {
val inv = try { ::bar5 } catch (e: Exception) { ::foo5 } finally { ::foo5 }
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
inv()
}
}
@@ -388,49 +388,49 @@ fun poll66(): Flow<String> {
fun poll7(): Flow<String> {
return flow {
val inv = ::bar<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
val inv = ::bar!!
inv()
}
}
fun poll71(): Flow<String> {
return flow {
val inv = ::bar2<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
val inv = ::bar2!!
inv()
}
}
fun poll72(): Flow<String> {
return flow {
val inv = ::bar3<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
val inv = ::bar3!!
inv()
}
}
fun poll73(): Flow<String> {
return flow {
val inv = ::bar4<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
val inv = ::bar4!!
inv
}
}
fun poll74(): Flow<String> {
return flow {
val inv = ::bar5<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
val inv = ::bar5!!
inv
}
}
fun poll75(): Flow<String> {
return flow {
val inv = ::Foo6<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
val inv = ::Foo6!!
inv
}
}
fun poll76(): Flow<String> {
return flow {
val inv = ::Foo7<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
val inv = ::Foo7!!
inv
}
}
@@ -438,21 +438,21 @@ fun poll76(): Flow<String> {
fun poll8(): Flow<String> {
return flow {
val inv = <!NEW_INFERENCE_ERROR!>::bar in <!NEW_INFERENCE_ERROR!>setOf(::foo)<!><!>
<!UNRESOLVED_REFERENCE!>inv<!>()
inv()
}
}
fun poll81(): Flow<String> {
return flow {
val inv = ::bar2 in setOf(::foo2)
<!UNRESOLVED_REFERENCE!>inv<!>()
inv()
}
}
fun poll82(): Flow<String> {
return flow {
val inv = ::bar3 in <!NEW_INFERENCE_ERROR!>setOf(::foo3)<!>
<!UNRESOLVED_REFERENCE!>inv<!>()
inv()
}
}
@@ -30,7 +30,7 @@ fun foo7() = null as Foo7<Int>
interface FlowCollector<in T> {}
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit) = Flow(block)
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit): Flow<L> = Flow(block)
class Flow<out R>(private val block: suspend FlowCollector<R>.() -> Unit)
@@ -38,7 +38,7 @@ fun <R> select(vararg x: R) = x[0]
fun poll0(): Flow<String> {
return flow {
val inv = select(<!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!><!>, <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!><!>)
val inv = select(::bar, ::foo)
inv()
}
}
@@ -52,7 +52,7 @@ fun poll01(): Flow<String> {
fun poll02(): Flow<String> {
return flow {
val inv = select(<!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar3<!><!>, <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo3<!><!>)
val inv = select(::bar3, ::foo3)
inv()
}
}
@@ -66,7 +66,7 @@ fun poll03(): Flow<String> {
fun poll04(): Flow<String> {
return flow {
val inv = select(<!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar5<!><!>, <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo5<!><!>)
val inv = select(::bar5, ::foo5)
inv
}
}
@@ -143,7 +143,7 @@ fun poll17(flag: Boolean): Flow<String> {
fun poll2(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!><!> else -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!><!> }
val inv = when (flag) { true -> ::bar else -> ::foo }
inv()
}
}
@@ -157,7 +157,7 @@ fun poll21(flag: Boolean): Flow<String> {
fun poll22(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar3<!><!> else -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo3<!><!> }
val inv = when (flag) { true -> ::bar3 else -> ::foo3 }
inv()
}
}
@@ -171,7 +171,7 @@ fun poll23(flag: Boolean): Flow<String> {
fun poll24(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar5<!><!> else -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo5<!><!> }
val inv = when (flag) { true -> ::bar5 else -> ::foo5 }
inv
}
}
@@ -192,7 +192,7 @@ fun poll26(flag: Boolean): Flow<String> {
fun poll3(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!><!> false -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!><!> }
val inv = when (flag) { true -> ::bar false -> ::foo }
inv()
}
}
@@ -206,7 +206,7 @@ fun poll31(flag: Boolean): Flow<String> {
fun poll32(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar3<!><!> false -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo3<!><!> }
val inv = when (flag) { true -> ::bar3 false -> ::foo3 }
inv()
}
}
@@ -220,7 +220,7 @@ fun poll33(flag: Boolean): Flow<String> {
fun poll34(flag: Boolean): Flow<String> {
return flow {
val inv = when (flag) { true -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>bar5<!><!> false -> <!TYPE_INFERENCE_POSTPONED_VARIABLE_IN_RECEIVER_TYPE!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo5<!><!> }
val inv = when (flag) { true -> ::bar5 false -> ::foo5 }
inv
}
}
@@ -1,4 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -UNCHECKED_CAST -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// !LANGUAGE: +UnrestrictedBuilderInference
// !DIAGNOSTICS: -DEPRECATION -UNCHECKED_CAST -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
// FILE: main.kt
@@ -1,4 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -UNCHECKED_CAST -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// !LANGUAGE: +UnrestrictedBuilderInference
// !DIAGNOSTICS: -DEPRECATION -UNCHECKED_CAST -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
// FILE: main.kt
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -0,0 +1,73 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
// FILE: main.kt
import kotlin.experimental.ExperimentalTypeInference
interface TestInterface<R> {
fun emit(r: R)
fun get(): R
}
@UseExperimental(ExperimentalTypeInference::class)
fun <R1> build(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
fun Any.test() {}
fun Any?.test2() {}
fun test() {
val ret = build {
emit(1)
emit(null)
get()?.test()
get()?.test2()
get().test2()
get()?.hashCode()
get()?.equals(1)
// there is `String?.equals` extension
get().equals("")
val x = get()
x?.hashCode()
x?.equals(1)
x.equals("")
if (get() == null) {}
if (get() === null) {}
if (x != null) {
x?.hashCode()
x?.equals(1)
x.equals("")
x.hashCode()
x.toString()
x.test()
x?.test2()
x.test2()
}
if (x == null) {
x?.hashCode()
x?.equals(1)
x.equals("")
x.hashCode()
x.toString()
x.test()
x?.test2()
x.test2()
}
if (x === null) {
x?.hashCode()
x?.equals(1)
x.equals("")
x.hashCode()
x.toString()
x.test()
x?.test2()
x.test2()
}
""
}
}
@@ -0,0 +1,73 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
// FILE: main.kt
import kotlin.experimental.ExperimentalTypeInference
interface TestInterface<R> {
fun emit(r: R)
fun get(): R
}
@UseExperimental(ExperimentalTypeInference::class)
fun <R1> build(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
fun Any.test() {}
fun Any?.test2() {}
fun test() {
val ret = build {
emit(1)
emit(null)
get()?.test()
get()?.test2()
get().test2()
get()?.hashCode()
get()?.equals(1)
// there is `String?.equals` extension
<!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>get()<!>.equals("")
val x = get()
x?.hashCode()
x?.equals(1)
x.equals("")
if (get() == null) {}
if (get() === null) {}
if (x != null) {
x<!UNNECESSARY_SAFE_CALL!>?.<!>hashCode()
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1)
x.equals("")
x.hashCode()
x.toString()
x.test()
x<!UNNECESSARY_SAFE_CALL!>?.<!>test2()
x.test2()
}
if (x == null) {
<!DEBUG_INFO_CONSTANT!>x<!>?.hashCode()
<!DEBUG_INFO_CONSTANT!>x<!>?.equals(1)
x.equals("")
x.hashCode()
x.toString()
x.test()
<!DEBUG_INFO_CONSTANT!>x<!>?.test2()
x.test2()
}
if (x === null) {
<!DEBUG_INFO_CONSTANT!>x<!>?.hashCode()
<!DEBUG_INFO_CONSTANT!>x<!>?.equals(1)
x.equals("")
x.hashCode()
x.toString()
x.test()
<!DEBUG_INFO_CONSTANT!>x<!>?.test2()
x.test2()
}
""
}
}
@@ -0,0 +1,14 @@
package
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R1> build(/*0*/ @kotlin.BuilderInference block: TestInterface<R1>.() -> kotlin.Unit): R1
public fun test(): kotlin.Unit
public fun kotlin.Any.test(): kotlin.Unit
public fun kotlin.Any?.test2(): kotlin.Unit
public interface TestInterface</*0*/ R> {
public abstract fun emit(/*0*/ r: R): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun get(): R
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,62 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
// FILE: main.kt
import kotlin.experimental.ExperimentalTypeInference
interface TestInterface<R> {
fun emit(r: R)
fun get(): R
}
@UseExperimental(ExperimentalTypeInference::class)
fun <R1> build(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
@UseExperimental(ExperimentalTypeInference::class)
fun <R1 : Any> build2(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
@UseExperimental(ExperimentalTypeInference::class)
fun <R1 : R2, R2 : Any> build3(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
@UseExperimental(ExperimentalTypeInference::class)
fun <R1 : R2, R2> build4(x: R2, @BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
fun test(a: String?) {
val ret1 = build {
emit(1)
get()?.equals("")
val x = get()
x?.equals("")
x ?: 1
x!!
""
}
val ret2 = build2 {
emit(1)
get()?.equals("")
val x = get()
x?.equals("")
x ?: 1
x!!
""
}
val ret3 = build3 {
emit(1)
get()?.equals("")
val x = get()
x?.equals("")
x ?: 1
x!!
""
}
val ret4 = build4(1) {
emit(1)
get()?.equals("")
val x = get()
x?.equals("")
x ?: 1
x!!
""
}
}
@@ -0,0 +1,62 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED
// WITH_RUNTIME
// FILE: main.kt
import kotlin.experimental.ExperimentalTypeInference
interface TestInterface<R> {
fun emit(r: R)
fun get(): R
}
@UseExperimental(ExperimentalTypeInference::class)
fun <R1> build(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
@UseExperimental(ExperimentalTypeInference::class)
fun <R1 : Any> build2(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
@UseExperimental(ExperimentalTypeInference::class)
fun <R1 : R2, R2 : Any> build3(@BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
@UseExperimental(ExperimentalTypeInference::class)
fun <R1 : R2, R2> build4(x: R2, @BuilderInference block: TestInterface<R1>.() -> Unit): R1 = TODO()
fun test(a: String?) {
val ret1 = build {
emit(1)
get()?.equals("")
val x = get()
x?.equals("")
x ?: 1
x!!
""
}
val ret2 = build2 {
emit(1)
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
val x = get()
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
x <!USELESS_ELVIS!>?: 1<!>
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
""
}
val ret3 = build3 {
emit(1)
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
val x = get()
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
x <!USELESS_ELVIS!>?: 1<!>
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
""
}
val ret4 = build4(1) {
emit(1)
get()?.equals("")
val x = get()
x?.equals("")
x ?: 1
x!!
""
}
}
@@ -0,0 +1,15 @@
package
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R1> build(/*0*/ @kotlin.BuilderInference block: TestInterface<R1>.() -> kotlin.Unit): R1
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R1 : kotlin.Any> build2(/*0*/ @kotlin.BuilderInference block: TestInterface<R1>.() -> kotlin.Unit): R1
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R1 : R2, /*1*/ R2 : kotlin.Any> build3(/*0*/ @kotlin.BuilderInference block: TestInterface<R1>.() -> kotlin.Unit): R1
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R1 : R2, /*1*/ R2> build4(/*0*/ x: R2, /*1*/ @kotlin.BuilderInference block: TestInterface<R1>.() -> kotlin.Unit): R1
public fun test(/*0*/ a: kotlin.String?): kotlin.Unit
public interface TestInterface</*0*/ R> {
public abstract fun emit(/*0*/ r: R): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun get(): R
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
@@ -1,3 +1,4 @@
// !LANGUAGE: +StableBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME