diagnostics for deprecated syntax of function type parameter list
This commit is contained in:
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user