Resolve collection literal expression as special array-like function
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun test() {
|
||||
val a = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>[]<!>
|
||||
val b: Array<Int> = []
|
||||
val c = [1, 2]
|
||||
val d: Array<Int> = [1, 2]
|
||||
val e: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>[1]<!>
|
||||
|
||||
val f: IntArray = [1, 2]
|
||||
val g = [f]
|
||||
}
|
||||
|
||||
fun check() {
|
||||
[1, 2] checkType { _<Array<Int>>() }
|
||||
[""] checkType { _<Array<String>>() }
|
||||
|
||||
val f: IntArray = [1]
|
||||
[f] checkType { _<Array<IntArray>>() }
|
||||
|
||||
[1, ""] checkType { _<Array<Any>>() }
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun check(): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun basicTypes() {
|
||||
val a: IntArray = [1]
|
||||
val b: ByteArray = [1]
|
||||
val c: BooleanArray = [true, false]
|
||||
val d: CharArray = ['a']
|
||||
val e: ShortArray = [1]
|
||||
val f: FloatArray = [1.0f]
|
||||
val g: LongArray = [1]
|
||||
val h: DoubleArray = [1.0]
|
||||
}
|
||||
|
||||
fun basicTypesWithErrors() {
|
||||
val a: IntArray = [<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!>]
|
||||
val b: ShortArray = [<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!>]
|
||||
val c: CharArray = [<!TYPE_MISMATCH!>"a"<!>]
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun basicTypes(): kotlin.Unit
|
||||
public fun basicTypesWithErrors(): kotlin.Unit
|
||||
Reference in New Issue
Block a user