complete type inference(*) for variable as function call as well
* dependent on expected type + get rid of instanceof ResolvedCallImpl check
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
package a
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
public fun <T> Iterable<T>.withIndices(): List<Pair<Int, T>> {
|
||||
val answer = ArrayList<Pair<Int, T>>()
|
||||
var nextIndex = 1
|
||||
for (e in this) {
|
||||
answer.add(Pair(nextIndex, e))
|
||||
nextIndex++
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
//from standard library
|
||||
public class Pair<out A, out B>(
|
||||
public val first: A,
|
||||
public val second: B
|
||||
)
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package j
|
||||
|
||||
trait MyFunc<T> {}
|
||||
|
||||
class A(val b: B) {
|
||||
}
|
||||
|
||||
class B {
|
||||
fun <T> invoke(<!UNUSED_PARAMETER!>f<!>: (T) -> T): MyFunc<T> = throw Exception()
|
||||
}
|
||||
|
||||
fun id<R>(r: R) = r
|
||||
|
||||
fun foo(a: A) {
|
||||
val <!UNUSED_VARIABLE!>r<!> : MyFunc<Int> = id (a.b { x -> x + 14 })
|
||||
}
|
||||
Reference in New Issue
Block a user