Add expected type constraints in a builder inference call
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// 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: MutableList<CharSequence> = this@buildList
|
||||
}
|
||||
buildList {
|
||||
add("")
|
||||
val x: StringBuilder = get(0)
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// 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("")
|
||||
val x: MutableList<CharSequence> = this@buildList
|
||||
}
|
||||
buildList {
|
||||
add(<!TYPE_MISMATCH, TYPE_MISMATCH!>""<!>)
|
||||
val x: StringBuilder = get(0)
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user