diagnostics for deprecated syntax of function type parameter list
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun fooT22<T: Any>() : T? {
|
||||
fun <T: Any> fooT22() : T? {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package f
|
||||
|
||||
fun g<T>(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>a<!>: Any): List<T> {throw Exception()}
|
||||
fun g<T>(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>i<!>: Int): Collection<T> {throw Exception()}
|
||||
fun <T> g(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>a<!>: Any): List<T> {throw Exception()}
|
||||
fun <T> g(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>i<!>: Int): Collection<T> {throw Exception()}
|
||||
|
||||
fun test<T>() {
|
||||
fun <T> test() {
|
||||
val <!UNUSED_VARIABLE!>c<!>: List<T> = <!CANNOT_COMPLETE_RESOLVE!>g<!>(1, 1)
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
package f
|
||||
|
||||
fun h<R>(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>r<!>: R, <!UNUSED_PARAMETER!>f<!>: (Boolean) -> Int) = 1
|
||||
fun h<R>(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>r<!>: R, <!UNUSED_PARAMETER!>f<!>: (Boolean) -> Int) = 1
|
||||
fun <R> h(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>r<!>: R, <!UNUSED_PARAMETER!>f<!>: (Boolean) -> Int) = 1
|
||||
fun <R> h(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>r<!>: R, <!UNUSED_PARAMETER!>f<!>: (Boolean) -> Int) = 1
|
||||
|
||||
fun test() = <!CANNOT_COMPLETE_RESOLVE!>h<!>(1, 1, 1, { <!CANNOT_INFER_PARAMETER_TYPE!>b<!> -> 42 })
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package f
|
||||
|
||||
fun f<T>(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>c<!>: Collection<T>): List<T> {throw Exception()}
|
||||
fun f<T>(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>l<!>: List<T>): Collection<T> {throw Exception()}
|
||||
fun <T> f(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>c<!>: Collection<T>): List<T> {throw Exception()}
|
||||
fun <T> f(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>l<!>: List<T>): Collection<T> {throw Exception()}
|
||||
|
||||
fun test<T>(<!UNUSED_PARAMETER!>l<!>: List<T>) {
|
||||
fun <T> test(<!UNUSED_PARAMETER!>l<!>: List<T>) {
|
||||
<!CANNOT_COMPLETE_RESOLVE!>f<!>(1, <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>())
|
||||
}
|
||||
|
||||
fun emptyList<T>(): List<T> {throw Exception()}
|
||||
fun <T> emptyList(): List<T> {throw Exception()}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package f
|
||||
|
||||
fun f<T>(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>c<!>: MutableCollection<T>) {}
|
||||
fun f<T>(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>l<!>: MutableList<T>) {}
|
||||
fun <T> f(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>c<!>: MutableCollection<T>) {}
|
||||
fun <T> f(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>l<!>: MutableList<T>) {}
|
||||
|
||||
fun test(l: List<Int>) {
|
||||
<!NONE_APPLICABLE!>f<!>(1, "", l)
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS
|
||||
package f
|
||||
|
||||
fun h<R>(<!UNUSED_PARAMETER!>f<!>: (Boolean) -> R) = 1
|
||||
fun h<R>(<!UNUSED_PARAMETER!>f<!>: (String) -> R) = 2
|
||||
fun <R> h(<!UNUSED_PARAMETER!>f<!>: (Boolean) -> R) = 1
|
||||
fun <R> h(<!UNUSED_PARAMETER!>f<!>: (String) -> R) = 2
|
||||
|
||||
fun test() = <!CANNOT_COMPLETE_RESOLVE!>h<!>{ <!CANNOT_INFER_PARAMETER_TYPE!>i<!> -> getAnswer() }
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ class GenericClass<out T>
|
||||
|
||||
public fun <K, V> GenericClass<Map<K, V>>.foo() {}
|
||||
|
||||
public fun bar<T>(t: T, ext: GenericClass<T>.() -> Unit) {}
|
||||
public fun <T> bar(t: T, ext: GenericClass<T>.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
bar(mapOf(2 to 3)) { foo() }
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class GenericClass<out T>(val value: T) {
|
||||
public fun foo<P>(extension: T.() -> P) {}
|
||||
public fun <P> foo(extension: T.() -> P) {}
|
||||
}
|
||||
|
||||
public fun <E> GenericClass<List<E>>.bar() {
|
||||
|
||||
@@ -12,7 +12,7 @@ fun test() {
|
||||
val <!UNUSED_VARIABLE!>u<!> = 11.<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>elemAndListWithReceiver<!>(4, list("7"))
|
||||
}
|
||||
|
||||
fun list<T>(value: T) : ArrayList<T> {
|
||||
fun <T> list(value: T) : ArrayList<T> {
|
||||
val list = ArrayList<T>()
|
||||
list.add(value)
|
||||
return list
|
||||
|
||||
@@ -12,7 +12,7 @@ fun <R> elem(t: List<R>): R = t.get(0)
|
||||
|
||||
fun <R> elemAndList(<!UNUSED_PARAMETER!>r<!>: R, t: List<R>): R = t.get(0)
|
||||
|
||||
fun both<T>(t1: T, <!UNUSED_PARAMETER!>t2<!>: T) : T = t1
|
||||
fun <T> both(t1: T, <!UNUSED_PARAMETER!>t2<!>: T) : T = t1
|
||||
|
||||
fun test1() {
|
||||
val a = elem(list(2))
|
||||
@@ -42,12 +42,12 @@ fun test1() {
|
||||
checkSubtype<Any>(j)
|
||||
}
|
||||
|
||||
fun list<T>(value: T) : ArrayList<T> {
|
||||
fun <T> list(value: T) : ArrayList<T> {
|
||||
val list = ArrayList<T>()
|
||||
list.add(value)
|
||||
return list
|
||||
}
|
||||
|
||||
fun newList<S>() : ArrayList<S> {
|
||||
fun <S> newList() : ArrayList<S> {
|
||||
return ArrayList<S>()
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package a
|
||||
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun foo<T>(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l")
|
||||
fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l")
|
||||
|
||||
fun test() {
|
||||
val q = foo(fun Int.() {}, emptyList()) //type inference no information for parameter error
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package n
|
||||
|
||||
fun foo<T>(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>t1<!>: T) {}
|
||||
fun <T> foo(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>t1<!>: T) {}
|
||||
|
||||
fun test() {
|
||||
//no type inference error
|
||||
|
||||
@@ -3,7 +3,7 @@ package n
|
||||
//+JDK
|
||||
import java.util.*
|
||||
|
||||
fun expected<T>(t: T, <!UNUSED_PARAMETER!>f<!>: () -> T) : T = t
|
||||
fun <T> expected(t: T, <!UNUSED_PARAMETER!>f<!>: () -> T) : T = t
|
||||
|
||||
fun test(arrayList: ArrayList<Int>, list: List<Int>) {
|
||||
val <!UNUSED_VARIABLE!>t<!> = expected(arrayList, { list.reverse() })
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package n
|
||||
//+JDK
|
||||
import java.util.*
|
||||
|
||||
fun expected<T>(t: T, <!UNUSED_PARAMETER!>f<!>: () -> T) : T = t
|
||||
fun <T> expected(t: T, <!UNUSED_PARAMETER!>f<!>: () -> T) : T = t
|
||||
|
||||
fun test(arrayList: ArrayList<Int>, list: List<Int>) {
|
||||
val <!UNUSED_VARIABLE!>t<!> = expected(arrayList, l@ {return@l list.reverse() })
|
||||
|
||||
@@ -22,7 +22,7 @@ fun test() {
|
||||
// ---------------------
|
||||
// copy from kotlin util
|
||||
|
||||
fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size()))
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size()))
|
||||
|
||||
fun <T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
|
||||
for (element in this) result.add(element)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun foo<T>(t: T) = t
|
||||
fun <T> foo(t: T) = t
|
||||
|
||||
fun test(map: MutableMap<Int, Int>, t: Int) {
|
||||
map [t] = foo(t) // t was marked with black square
|
||||
|
||||
compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedForVariableAsFunctionCall.kt
Vendored
+1
-1
@@ -9,7 +9,7 @@ class B {
|
||||
operator fun <T> invoke(<!UNUSED_PARAMETER!>f<!>: (T) -> T): MyFunc<T> = throw Exception()
|
||||
}
|
||||
|
||||
fun id<R>(r: R) = r
|
||||
fun <R> id(r: R) = r
|
||||
|
||||
fun foo(a: A) {
|
||||
val <!UNUSED_VARIABLE!>r<!> : MyFunc<Int> = id (a.b { x -> x + 14 })
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ package aaa
|
||||
|
||||
fun <T> T.foo(t: T) = t
|
||||
|
||||
fun id<T>(t: T) = t
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
fun a() {
|
||||
val i = id(2 foo 3)
|
||||
|
||||
@@ -3,7 +3,7 @@ package b
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
public fun query<T>(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>args<!>: Map<String, Any>): List<T> {
|
||||
public fun <T> query(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>args<!>: Map<String, Any>): List<T> {
|
||||
return ArrayList<T>()
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ fun test(pair: Pair<String, Int>) {
|
||||
|
||||
|
||||
//from standard library
|
||||
fun mapOf<K, V>(vararg <!UNUSED_PARAMETER!>values<!>: Pair<K, V>): Map<K, V> { throw Exception() }
|
||||
fun <K, V> mapOf(vararg <!UNUSED_PARAMETER!>values<!>: Pair<K, V>): Map<K, V> { throw Exception() }
|
||||
|
||||
fun <A,B> A.to(<!UNUSED_PARAMETER!>that<!>: B): Pair<A, B> { throw Exception() }
|
||||
|
||||
@@ -26,7 +26,7 @@ fun println(<!UNUSED_PARAMETER!>message<!> : Any?) { throw Exception() }
|
||||
class Pair<out A, out B> () {}
|
||||
|
||||
//short example
|
||||
fun foo<T>(t: T) = t
|
||||
fun <T> foo(t: T) = t
|
||||
|
||||
fun test(t: String) {
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ fun test() {
|
||||
val <!UNUSED_VARIABLE!>n1<!> : List<String> = newList()
|
||||
}
|
||||
|
||||
fun newList<S>() : ArrayList<S> {
|
||||
fun <S> newList() : ArrayList<S> {
|
||||
return ArrayList<S>()
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ package a
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun g<T> (<!UNUSED_PARAMETER!>f<!>: () -> List<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> g (<!UNUSED_PARAMETER!>f<!>: () -> List<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun test() {
|
||||
//here possibly can be a cycle on constraints
|
||||
|
||||
@@ -13,5 +13,5 @@ fun test() {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun arrayList<T>(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
operator fun <T> Iterable<T>.plus(<!UNUSED_PARAMETER!>elements<!>: Iterable<T>): List<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
@@ -5,7 +5,7 @@ import java.util.ArrayList
|
||||
fun <T> foo(a : T, b : Collection<T>, c : Int) {
|
||||
}
|
||||
|
||||
fun arrayListOf<T>(vararg values: T): ArrayList<T> = throw Exception("$values")
|
||||
fun <T> arrayListOf(vararg values: T): ArrayList<T> = throw Exception("$values")
|
||||
|
||||
val bar = foo("", arrayListOf(),<!SYNTAX!><!> )
|
||||
val bar2 = foo<String>("", arrayListOf(),<!SYNTAX!><!> )
|
||||
@@ -25,7 +25,7 @@ fun test() {
|
||||
|
||||
//------------
|
||||
|
||||
fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size()))
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size()))
|
||||
|
||||
fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {
|
||||
return mapTo(java.util.ArrayList<R>(this.size), transform)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//KT-2294 Type inference infers DONT_CARE instead of correct type
|
||||
package a
|
||||
|
||||
public fun foo<E>(array: Array<E>): Array<E> = array
|
||||
public fun <E> foo(array: Array<E>): Array<E> = array
|
||||
|
||||
public fun test()
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ fun testSomeFunction() {
|
||||
fun assertEquals(<!UNUSED_PARAMETER!>expected<!>: Any?, <!UNUSED_PARAMETER!>actual<!>: Any?, <!UNUSED_PARAMETER!>message<!>: String = "") {
|
||||
}
|
||||
|
||||
fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size()))
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size()))
|
||||
|
||||
fun <T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
|
||||
for (element in this) result.add(element)
|
||||
|
||||
@@ -11,7 +11,7 @@ fun test() {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun arrayList<T>(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun <T, R> Collection<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun test<R>(callback: (R) -> Unit):Unit = callback(null!!)
|
||||
fun <R> test(callback: (R) -> Unit):Unit = callback(null!!)
|
||||
@@ -7,4 +7,4 @@ class B<T>(val x: List<T>)
|
||||
fun <T> f(x: T): B<T> = B(arrayList(x))
|
||||
|
||||
// from standard library
|
||||
fun arrayList<T>(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
@@ -8,7 +8,7 @@ interface MyType {}
|
||||
class MyClass<T> : MyType {}
|
||||
|
||||
public open class HttpResponse() {
|
||||
public open fun parseAs<T>(dataClass : MyClass<T>) : T {
|
||||
public open fun <T> parseAs(dataClass : MyClass<T>) : T {
|
||||
throw Exception()
|
||||
}
|
||||
public open fun parseAs(dataType : MyType) : Any? {
|
||||
@@ -16,7 +16,7 @@ public open class HttpResponse() {
|
||||
}
|
||||
}
|
||||
|
||||
fun test<R> (httpResponse: HttpResponse, rtype: MyClass<R>) {
|
||||
fun <R> test (httpResponse: HttpResponse, rtype: MyClass<R>) {
|
||||
val res = httpResponse.parseAs( rtype )
|
||||
checkSubtype<R>(res) //type mismatch: required R, found T
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ interface D
|
||||
class B : A, D
|
||||
class C : A, D
|
||||
|
||||
fun hashSetOf<T>(vararg values: T): HashSet<T> = throw Exception("$values")
|
||||
fun <T> hashSetOf(vararg values: T): HashSet<T> = throw Exception("$values")
|
||||
|
||||
fun foo(b: MyClass<B>, c: MyClass<C>) {
|
||||
val set1 : Set<MyClass<out D>> = hashSetOf(b, c) //type inference expected type mismatch
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package a
|
||||
|
||||
fun <T, R: Comparable<R>> Iterable<T>._sortBy(<!UNUSED_PARAMETER!>f<!>: (T) -> R): List<T> = throw Exception()
|
||||
fun _arrayList<T>(vararg <!UNUSED_PARAMETER!>values<!>: T) : List<T> = throw Exception()
|
||||
fun <T> _arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : List<T> = throw Exception()
|
||||
|
||||
class _Pair<A>(val a: A)
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
//KT-2838 Type inference failed on passing null as a nullable argument
|
||||
package a
|
||||
|
||||
fun foo<T>(a: T, b: Map<T, String>?) = b?.get(a)
|
||||
fun bar<T>(a: T, b: Map<T, String>) = b.get(a)
|
||||
fun <T> foo(a: T, b: Map<T, String>?) = b?.get(a)
|
||||
fun <T> bar(a: T, b: Map<T, String>) = b.get(a)
|
||||
|
||||
fun test(a: Int) {
|
||||
foo(a, null)
|
||||
|
||||
@@ -6,7 +6,7 @@ enum class TestEnum {
|
||||
SECOND
|
||||
}
|
||||
|
||||
fun inferenceTest<T>(a: T) : T = a
|
||||
fun <T> inferenceTest(a: T) : T = a
|
||||
|
||||
fun hello() {
|
||||
var enumElemFirst = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>inferenceTest(TestEnum.FIRST)<!>
|
||||
|
||||
@@ -17,4 +17,4 @@ fun test122() {
|
||||
}
|
||||
|
||||
//from library
|
||||
fun array<T>(vararg <!UNUSED_PARAMETER!>t<!>: T): Array<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> array(vararg <!UNUSED_PARAMETER!>t<!>: T): Array<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
@@ -2,11 +2,11 @@
|
||||
package a
|
||||
//+JDK
|
||||
|
||||
fun getJavaClass<T>() : java.lang.Class<T> { <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> getJavaClass() : java.lang.Class<T> { <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
public class Throwables() {
|
||||
companion object {
|
||||
public fun propagateIfInstanceOf<X : Throwable?>(throwable : Throwable?, declaredType : Class<X<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>>?) : Unit {
|
||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>>?) : Unit {
|
||||
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
||||
{
|
||||
throw declaredType?.cast(throwable)!!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//KT-832 Provide better diagnostics when type inference fails for an expression that returns a function
|
||||
package a
|
||||
|
||||
fun fooT2<T>() : (t : T) -> T {
|
||||
fun <T> fooT2() : (t : T) -> T {
|
||||
return {it}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
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 <R> foo (f: ()->R, r: MutableList<R>) = r.add(f())
|
||||
fun <R> bar (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'
|
||||
@@ -9,4 +9,4 @@ fun test() {
|
||||
}
|
||||
|
||||
// from standard library
|
||||
fun arrayListOf<T>(vararg <!UNUSED_PARAMETER!>values<!>: T) : MutableList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>values<!>: T) : MutableList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
class Bar<T>
|
||||
|
||||
fun bar<T>(): Bar<T> = null!!
|
||||
fun <T> bar(): Bar<T> = null!!
|
||||
|
||||
class Foo {
|
||||
fun <R> add(bar: Bar<R>): Foo {return this}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ fun test() {
|
||||
use(s)
|
||||
}
|
||||
|
||||
fun newList<S>() : ArrayList<S> {
|
||||
fun <S> newList() : ArrayList<S> {
|
||||
return ArrayList<S>()
|
||||
}
|
||||
|
||||
|
||||
Vendored
+5
-5
@@ -1,7 +1,7 @@
|
||||
package a
|
||||
|
||||
fun foo<V: U, U>(<!UNUSED_PARAMETER!>v<!>: V, u: U) = u
|
||||
fun bar<U, V: U>(<!UNUSED_PARAMETER!>v<!>: V, u: U) = u
|
||||
fun <V: U, U> foo(<!UNUSED_PARAMETER!>v<!>: V, u: U) = u
|
||||
fun <U, V: U> bar(<!UNUSED_PARAMETER!>v<!>: V, u: U) = u
|
||||
|
||||
fun test(a: Any, s: String) {
|
||||
val b = foo(a, s)
|
||||
@@ -10,13 +10,13 @@ fun test(a: Any, s: String) {
|
||||
checkItIsExactlyAny(a, arrayListOf(c))
|
||||
}
|
||||
|
||||
fun checkItIsExactlyAny<T>(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>l<!>: MutableList<T>) {}
|
||||
fun <T> checkItIsExactlyAny(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>l<!>: MutableList<T>) {}
|
||||
|
||||
fun baz<V : U, U>(<!UNUSED_PARAMETER!>v<!>: V, u: MutableSet<U>) = u
|
||||
fun <V : U, U> baz(<!UNUSED_PARAMETER!>v<!>: V, u: MutableSet<U>) = u
|
||||
|
||||
fun test(a: Any, s: MutableSet<String>) {
|
||||
<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>baz<!>(a, s)
|
||||
}
|
||||
|
||||
//from standard library
|
||||
fun arrayListOf<T>(vararg <!UNUSED_PARAMETER!>t<!>: T): MutableList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>t<!>: T): MutableList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
Reference in New Issue
Block a user