checking subtype for invariant type with error generic argument may success

This commit is contained in:
Svetlana Isakova
2012-12-26 18:58:57 +04:00
parent 38cc3e39e4
commit 70cde87052
3 changed files with 20 additions and 1 deletions
@@ -0,0 +1,12 @@
package a
fun foo<R> (f: ()->R, r: MutableList<R>) = r.add(f())
fun bar<R> (r: MutableList<R>, f: ()->R) = r.add(f())
fun test() {
val <!UNUSED_VARIABLE!>a<!> = <!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>foo<!>({1}, arrayListOf("")) //no type inference error on 'arrayListOf'
val <!UNUSED_VARIABLE!>b<!> = <!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>bar<!>(arrayListOf(""), {1})
}
// from standard library
fun arrayListOf<T>(vararg <!UNUSED_PARAMETER!>values<!>: T) : MutableList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>