Adjust testData to CharSequence.length transformation
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cb562e7ea5
commit
f0e3fd617d
@@ -5,7 +5,7 @@ package n
|
||||
import java.util.*
|
||||
|
||||
fun test() {
|
||||
val foo = arrayList("").map { it -> it.length() }.fold(0, { x, y -> Math.max(x, y) })
|
||||
val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) })
|
||||
checkSubtype<Int>(foo)
|
||||
checkSubtype<String>(<!TYPE_MISMATCH!>foo<!>)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ fun <T> Array<T>.forEach(operation: (T) -> Unit) : Unit { for (element in this)
|
||||
fun bar(operation: (String) -> Unit) = operation("")
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args.forEach { a : String -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { a -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { it.length() } // This works!
|
||||
args.forEach { a : String -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { a -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { it.length } // This works!
|
||||
|
||||
bar { a: String -> a.length() }
|
||||
bar { a -> a.length() }
|
||||
bar { it.length() }
|
||||
bar { a: String -> a.length }
|
||||
bar { a -> a.length }
|
||||
bar { it.length }
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import java.util.*
|
||||
|
||||
fun foo(lines: List<String>) {
|
||||
val w = max(lines, comparator {o1, o2 ->
|
||||
val l1 : Int = o1.length() // Types of o1 and o2 are ERROR
|
||||
val l2 = o2.length()
|
||||
val l1 : Int = o1.length // Types of o1 and o2 are ERROR
|
||||
val l2 = o2.length
|
||||
l1 - l2
|
||||
}).sure()
|
||||
checkSubtype<String>(w)
|
||||
|
||||
Reference in New Issue
Block a user