diagnostics for deprecated syntax of function type parameter list
This commit is contained in:
+2
-2
@@ -37,6 +37,6 @@ fun test() {
|
||||
1.buzz<<!UPPER_BOUND_VIOLATED!>Double<!>>()
|
||||
}
|
||||
|
||||
fun foo<T : Any>() {}
|
||||
fun bar<T : Int?>() {}
|
||||
fun <T : Any> foo() {}
|
||||
fun <T : Int?> bar() {}
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> Int.buzz() : Unit {}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ abstract class Tag(val name : String) : Element {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
protected fun initTag<T : Element>(tag : T, init : T.() -> Unit) : T {
|
||||
protected fun <T : Element> initTag(tag : T, init : T.() -> Unit) : T {
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
|
||||
@@ -14,11 +14,11 @@ fun foo2() : (i : () -> Unit) -> Unit {
|
||||
return {}
|
||||
}
|
||||
|
||||
fun fooT1<T>(t : T) : () -> T {
|
||||
fun <T> fooT1(t : T) : () -> T {
|
||||
return {t}
|
||||
}
|
||||
|
||||
fun fooT2<T>() : (t : T) -> T {
|
||||
fun <T> fooT2() : (t : T) -> T {
|
||||
return {it}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// A generic funciton is always less specific than a non-generic one
|
||||
fun foo<T>(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
||||
fun <T> foo(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
||||
fun foo(<!UNUSED_PARAMETER!>i<!> : Int) : Int = 1
|
||||
|
||||
fun test() {
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ val y1 = foobar.a.b
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun done<O>(result : O) : Iteratee<Any?, O> = StrangeIterateeImpl<Any?, O>(result)
|
||||
fun <O> done(result : O) : Iteratee<Any?, O> = StrangeIterateeImpl<Any?, O>(result)
|
||||
|
||||
abstract class Iteratee<in I, out O> {
|
||||
abstract fun process(item : I) : Iteratee<I, O>
|
||||
@@ -58,7 +58,7 @@ abstract class Sum() : Iteratee<Int, Int>() {
|
||||
}
|
||||
|
||||
abstract class Collection<E> : Iterable<E> {
|
||||
fun iterate<O>(iteratee : Iteratee<E, O>) : O {
|
||||
fun <O> iterate(iteratee : Iteratee<E, O>) : O {
|
||||
var current = iteratee
|
||||
for (x in this) {
|
||||
val it = current.process(x)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun getT<T>() {}
|
||||
fun getTT<A, B>() {}
|
||||
fun getTTT<A, B, C>(<!UNUSED_PARAMETER!>x<!> : Any) {}
|
||||
fun <T> getT() {}
|
||||
fun <A, B> getTT() {}
|
||||
fun <A, B, C> getTTT(<!UNUSED_PARAMETER!>x<!> : Any) {}
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!> : Any?) {}
|
||||
|
||||
public fun main() {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ class C<T>() {
|
||||
}
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>c<!>: C<Int>) {}
|
||||
fun bar<T>() : C<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> bar() : C<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val <!UNUSED_VARIABLE!>a<!> : C<Int> = C();
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
|
||||
fun ff<T>(l: MutableCollection<T>) = l is MutableList<T>
|
||||
fun <T> ff(l: MutableCollection<T>) = l is MutableList<T>
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class G<T>
|
||||
|
||||
fun f<Q>(q: Q) = q is G<*>
|
||||
fun <Q> f(q: Q) = q is G<*>
|
||||
@@ -1,8 +1,8 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
fun f1<T>(): KClass<Array<T>> = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>Array<T>::class<!>
|
||||
fun f2<T>(): KClass<Array<Array<T>>> = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>Array<Array<T>>::class<!>
|
||||
inline fun f3<reified T>() = Array<T>::class
|
||||
inline fun f4<reified T>() = Array<Array<T>>::class
|
||||
fun <T> f1(): KClass<Array<T>> = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>Array<T>::class<!>
|
||||
fun <T> f2(): KClass<Array<Array<T>>> = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>Array<Array<T>>::class<!>
|
||||
inline fun <reified T> f3() = Array<T>::class
|
||||
inline fun <reified T> f4() = Array<Array<T>>::class
|
||||
fun f5(): KClass<Array<Any>> = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>Array<*>::class<!>
|
||||
fun f6(): KClass<Array<Int?>> = Array<Int?>::class
|
||||
@@ -8,7 +8,7 @@ val a2 = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>A?<!REDUNDANT_NULLABLE!>?<!>::class<!>
|
||||
val l1 = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>List<String>?::class<!>
|
||||
val l2 = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>List?::class<!>
|
||||
|
||||
fun foo<T : Any>() {
|
||||
fun <T : Any> foo() {
|
||||
val t1 = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>T::class<!>
|
||||
val t2 = <!CLASS_LITERAL_LHS_NOT_A_CLASS!>T?::class<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class D {
|
||||
val cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>IncorrectThis<A>()<!>
|
||||
|
||||
class IncorrectThis<T> {
|
||||
fun get<R>(t: Any?, p: PropertyMetadata): Int {
|
||||
fun <R> get(t: Any?, p: PropertyMetadata): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
Vendored
+3
-3
@@ -13,9 +13,9 @@ class A(outer: Outer) {
|
||||
var f: String by <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty<!>()) <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>-<!> 1
|
||||
}
|
||||
|
||||
fun foo<A, B>(<!UNUSED_PARAMETER!>a<!>: Any?) = MyProperty<A, B>()
|
||||
fun <A, B> foo(<!UNUSED_PARAMETER!>a<!>: Any?) = MyProperty<A, B>()
|
||||
|
||||
fun getMyProperty<A, B>() = MyProperty<A, B>()
|
||||
fun <A, B> getMyProperty() = MyProperty<A, B>()
|
||||
|
||||
fun getMyConcreteProperty() = MyProperty<Any?, String>()
|
||||
|
||||
@@ -35,7 +35,7 @@ operator fun <R, T> MyProperty<R, T>.plus() = MyProperty<R, T>()
|
||||
operator fun <R, T> MyProperty<R, T>.minus(<!UNUSED_PARAMETER!>i<!>: Int) = MyProperty<R, T>()
|
||||
|
||||
object O {
|
||||
fun getMyProperty<A, B>() = MyProperty<A, B>()
|
||||
fun <A, B> getMyProperty() = MyProperty<A, B>()
|
||||
}
|
||||
|
||||
interface MyPropertyContainer {
|
||||
|
||||
Vendored
+2
-2
@@ -5,7 +5,7 @@ class A {
|
||||
var b5: String by <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getMyProperty1<!>()
|
||||
}
|
||||
|
||||
fun getMyProperty1<A, B>() = MyProperty1<A, B>()
|
||||
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
|
||||
|
||||
class MyProperty1<T, R> {
|
||||
|
||||
@@ -25,7 +25,7 @@ class B {
|
||||
var b5: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>getMyProperty2()<!>
|
||||
}
|
||||
|
||||
fun getMyProperty2<A, B>() = MyProperty2<A, B>()
|
||||
fun <A, B> getMyProperty2() = MyProperty2<A, B>()
|
||||
|
||||
class MyProperty2<T, R> {
|
||||
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ class A1 {
|
||||
var c1: String by getMyProperty1()
|
||||
var d1: String by MyProperty1()
|
||||
|
||||
fun getMyProperty1<A, B>() = MyProperty1<A, B>()
|
||||
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
|
||||
|
||||
class MyProperty1<R, T> {
|
||||
|
||||
@@ -32,7 +32,7 @@ class A2 {
|
||||
var c2: String by getMyProperty2()
|
||||
var d2: String by MyProperty2()
|
||||
|
||||
fun getMyProperty2<A>() = MyProperty2<A>()
|
||||
fun <A> getMyProperty2() = MyProperty2<A>()
|
||||
|
||||
class MyProperty2<T> {
|
||||
|
||||
@@ -56,7 +56,7 @@ class A3 {
|
||||
var c3: String by getMyProperty3()
|
||||
var d3: String by MyProperty3()
|
||||
|
||||
fun getMyProperty3<A>() = MyProperty3<A>()
|
||||
fun <A> getMyProperty3() = MyProperty3<A>()
|
||||
|
||||
class MyProperty3<T> {
|
||||
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ class A1 {
|
||||
val c1: String by getMyProperty1()
|
||||
val d1: String by MyProperty1()
|
||||
|
||||
fun getMyProperty1<A, B>() = MyProperty1<A, B>()
|
||||
fun <A, B> getMyProperty1() = MyProperty1<A, B>()
|
||||
|
||||
class MyProperty1<R, T> {
|
||||
|
||||
@@ -28,7 +28,7 @@ class A2 {
|
||||
val c2: String by getMyProperty2()
|
||||
val d2: String by MyProperty2()
|
||||
|
||||
fun getMyProperty2<A>() = MyProperty2<A>()
|
||||
fun <A> getMyProperty2() = MyProperty2<A>()
|
||||
|
||||
class MyProperty2<T> {
|
||||
|
||||
@@ -48,7 +48,7 @@ class A3 {
|
||||
val c3: String by getMyProperty3()
|
||||
val d3: String by MyProperty3()
|
||||
|
||||
fun getMyProperty3<A>() = MyProperty3<A>()
|
||||
fun <A> getMyProperty3() = MyProperty3<A>()
|
||||
|
||||
class MyProperty3<T> {
|
||||
|
||||
|
||||
+1
-1
@@ -7,5 +7,5 @@ class Delegate {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun propertyDelegated<T>(p: PropertyMetadata) {}
|
||||
fun <T> propertyDelegated(p: PropertyMetadata) {}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ fun funcParamReceiver(param: <!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>.()->U
|
||||
fun funcParamParam(param: (<!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>)->Unit) { param(<!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>()) }
|
||||
fun funcParamRetVal(param: ()-><!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>) { param() }
|
||||
|
||||
fun constraint<T: <!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>>() {}
|
||||
fun <T: <!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>> constraint() {}
|
||||
|
||||
fun <!DEPRECATED_SYMBOL_WITH_MESSAGE!>Obsolete<!>.receiver() {}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
fun listOf<T>(): List<T> = null!!
|
||||
fun <T> listOf(): List<T> = null!!
|
||||
|
||||
fun test(a: (Int) -> Int) {
|
||||
test(fun (x) = 4)
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ interface A
|
||||
interface B
|
||||
interface C: A, B
|
||||
|
||||
fun foo<T>(<!UNUSED_PARAMETER!>a<!>: A, f: () -> T): T = f()
|
||||
fun foo<T>(<!UNUSED_PARAMETER!>b<!>: B, f: () -> T): T = f()
|
||||
fun <T> foo(<!UNUSED_PARAMETER!>a<!>: A, f: () -> T): T = f()
|
||||
fun <T> foo(<!UNUSED_PARAMETER!>b<!>: B, f: () -> T): T = f()
|
||||
|
||||
fun test(c: C) {
|
||||
<!CANNOT_COMPLETE_RESOLVE!>foo<!>(c) f@ {
|
||||
|
||||
@@ -8,4 +8,4 @@ fun main(args : Array<String>) {
|
||||
|
||||
fun <T : Any, R> T.let(f: (T) -> R): R = f(this)
|
||||
operator fun <T> Iterable<T>.plus(<!UNUSED_PARAMETER!>element<!>: T): List<T> = null!!
|
||||
fun listOf<T>(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
|
||||
fun <T> listOf(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
|
||||
Vendored
+1
-1
@@ -15,4 +15,4 @@ fun test3() {
|
||||
}
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
|
||||
Vendored
+1
-1
@@ -8,4 +8,4 @@ fun test2(a: Int) {
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
Vendored
+1
-1
@@ -5,4 +5,4 @@ fun test2() {
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
Vendored
+1
-1
@@ -11,4 +11,4 @@ fun test1() {
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+1
-1
@@ -6,4 +6,4 @@ fun test() {
|
||||
}
|
||||
}
|
||||
|
||||
fun run1<T>(f: () -> T): T { return f() }
|
||||
fun <T> run1(f: () -> T): T { return f() }
|
||||
+1
-1
@@ -11,4 +11,4 @@ fun test() {
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+1
-1
@@ -10,4 +10,4 @@ fun test() {
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+1
-1
@@ -5,4 +5,4 @@ fun test(a: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+1
-1
@@ -8,4 +8,4 @@ fun test(a: Int) {
|
||||
checkSubtype<Unit>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
val flag = true
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
|
||||
// type of a was checked by txt
|
||||
val a = run { // () -> Unit
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
fun listOf<T>(): List<T> = null!!
|
||||
fun listOf<T>(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
|
||||
fun <T> listOf(): List<T> = null!!
|
||||
fun <T> listOf(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
|
||||
|
||||
val flag = true
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -8,4 +8,4 @@ fun test(a: Int) {
|
||||
run<Int>{ 1 }
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+1
-1
@@ -13,4 +13,4 @@ fun test(a: C, b: B) {
|
||||
checkSubtype<A>(x)
|
||||
}
|
||||
|
||||
fun run<T>(f: () -> T): T { return f() }
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!>: (T) -> R): List<R> = null!!
|
||||
fun listOf<T>(): List<T> = null!!
|
||||
fun listOf<T>(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
|
||||
fun <T> listOf(): List<T> = null!!
|
||||
fun <T> listOf(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
|
||||
|
||||
fun commonSystemFailed(a: List<Int>) {
|
||||
a.map {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package d
|
||||
|
||||
interface A<T>
|
||||
|
||||
fun infer<T>(<!UNUSED_PARAMETER!>a<!>: A<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> infer(<!UNUSED_PARAMETER!>a<!>: A<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun test(nothing: Nothing?) {
|
||||
val <!UNUSED_VARIABLE!>i<!> = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>infer<!>(<!TYPE_MISMATCH!>nothing<!>)
|
||||
|
||||
@@ -20,7 +20,7 @@ fun test(expectedSum : Int, vararg data : Int) {
|
||||
assertEquals(actualSum, expectedSum, "\ndata = ${Arrays.toString(data)}\n" +
|
||||
"sum(data) = ${actualSum}, but must be $expectedSum ")
|
||||
}
|
||||
fun assertEquals<T: Any>(actual : T?, expected : T?, message : Any? = null) {
|
||||
fun <T: Any> assertEquals(actual : T?, expected : T?, message : Any? = null) {
|
||||
if (actual != expected) {
|
||||
if (message == null)
|
||||
throw AssertionError()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//!DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo<T>(i: Int, t: T) {}
|
||||
fun foo<T>(s: String, t: T) {}
|
||||
fun <T> foo(i: Int, t: T) {}
|
||||
fun <T> foo(s: String, t: T) {}
|
||||
|
||||
fun bar(i: Int) {}
|
||||
fun bar(s: String) {}
|
||||
|
||||
+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!>}<!>
|
||||
@@ -1,7 +1,7 @@
|
||||
//KT-2195 error "Only safe calls are allowed ..." but it is function param (val)
|
||||
package foo
|
||||
|
||||
private fun sendCommand<T>(errorCallback: (()->Unit)? = null) {
|
||||
private fun <T> sendCommand(errorCallback: (()->Unit)? = null) {
|
||||
if (errorCallback != null) {
|
||||
<!DEBUG_INFO_SMARTCAST!>errorCallback<!>()
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
// The type checker used to think that T is not null no matter what the upper bound
|
||||
|
||||
fun nullableUpperBound<T, INDIRECT: T>(t: T, ind: INDIRECT) {
|
||||
fun <T, INDIRECT: T> nullableUpperBound(t: T, ind: INDIRECT) {
|
||||
if (t == null) {} // was a warning
|
||||
if (t != null) {} // was a warning
|
||||
if (ind == null) {} // was a warning
|
||||
if (ind != null) {} // was a warning
|
||||
}
|
||||
|
||||
fun notNullUpperBound<T: Any, INDIRECT: T>(t: T, ind: INDIRECT) {
|
||||
fun <T: Any, INDIRECT: T> notNullUpperBound(t: T, ind: INDIRECT) {
|
||||
if (<!SENSELESS_COMPARISON!>t == null<!>) {} // still a warning
|
||||
if (<!SENSELESS_COMPARISON!>t != null<!>) {} // still a warning
|
||||
if (<!SENSELESS_COMPARISON!>ind == null<!>) {} // still a warning
|
||||
|
||||
+5
-5
@@ -1,24 +1,24 @@
|
||||
fun nonMisleadingNullable<NN: Any, NNN: NN>(
|
||||
fun <NN: Any, NNN: NN> nonMisleadingNullable(
|
||||
<!UNUSED_PARAMETER!>nn<!>: NN?,
|
||||
<!UNUSED_PARAMETER!>nnn<!>: NNN?
|
||||
) {}
|
||||
|
||||
fun twoBounds<NN: Any, TWO_BOUNDS: Any>(
|
||||
fun <NN: Any, TWO_BOUNDS: Any> twoBounds(
|
||||
<!UNUSED_PARAMETER!>tb<!>: TWO_BOUNDS?
|
||||
|
||||
) where TWO_BOUNDS : NN {}
|
||||
|
||||
fun misleadingNullableSimple<T, N: T, INDIRECT: N>(
|
||||
fun <T, N: T, INDIRECT: N> misleadingNullableSimple(
|
||||
<!UNUSED_PARAMETER!>t<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>t2<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>n<!>: N<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>ind<!>: INDIRECT<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>
|
||||
) {}
|
||||
|
||||
fun misleadingNullableMultiBound<FIRST_BOUND: Any?, SECOND_BOUND: Any>(
|
||||
fun <FIRST_BOUND: Any?, SECOND_BOUND: Any> misleadingNullableMultiBound(
|
||||
<!UNUSED_PARAMETER!>fb<!>: FIRST_BOUND<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>sb<!>: SECOND_BOUND<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>
|
||||
) where FIRST_BOUND: Any, SECOND_BOUND: Any? {
|
||||
}
|
||||
|
||||
fun interactionWithRedundant<T>(<!UNUSED_PARAMETER!>t<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!><!REDUNDANT_NULLABLE!>?<!>) {}
|
||||
fun <T> interactionWithRedundant(<!UNUSED_PARAMETER!>t<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!><!REDUNDANT_NULLABLE!>?<!>) {}
|
||||
+1
-1
@@ -3,7 +3,7 @@ interface X: A<!NULLABLE_SUPERTYPE!>?<!><!REDUNDANT_NULLABLE!>?<!> {
|
||||
|
||||
}
|
||||
|
||||
fun interaction<T>(t: T) {
|
||||
fun <T> interaction(t: T) {
|
||||
if (t == null) {}
|
||||
|
||||
}
|
||||
+2
-2
@@ -4,10 +4,10 @@ package a
|
||||
|
||||
class A {}
|
||||
|
||||
fun A.foo<T>(<!UNUSED_PARAMETER!>f<!> : T) {}
|
||||
fun <T> A.foo(<!UNUSED_PARAMETER!>f<!> : T) {}
|
||||
|
||||
val o = object {
|
||||
fun foo<T>(f: T) {
|
||||
fun <T> foo(f: T) {
|
||||
A().foo(f) // Ambiguity here!
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ import p.*
|
||||
|
||||
fun <T : Any> T.foo() {}
|
||||
|
||||
fun test<D>(b: Boolean) {
|
||||
fun <D> test(b: Boolean) {
|
||||
val c = if (b) Utils.c() else null
|
||||
|
||||
c?.foo()
|
||||
|
||||
+1
-1
@@ -38,4 +38,4 @@ fun test() {
|
||||
}
|
||||
|
||||
fun <T: Super> Collection<T>.foo(): T = null!!
|
||||
fun listOf<T>(t: T): List<T> = null!!
|
||||
fun <T> listOf(t: T): List<T> = null!!
|
||||
+1
-1
@@ -12,7 +12,7 @@ import p.*
|
||||
|
||||
fun <T : Any> T.foo() {}
|
||||
|
||||
fun test<D>(b: Boolean) {
|
||||
fun <D> test(b: Boolean) {
|
||||
val str = if (b) Utils.str() else null
|
||||
|
||||
str?.foo()
|
||||
|
||||
@@ -21,7 +21,7 @@ class Test {
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun arrayOf<T>(): Array<T> = null!!
|
||||
fun <T> arrayOf(): Array<T> = null!!
|
||||
|
||||
fun main() {
|
||||
val raw = Test.rawAField
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun Pair<<!REDECLARATION, REDECLARATION!>T<!>, <!REDECLARATION, REDECLARATION!>T<!>>() {}
|
||||
fun <<!REDECLARATION, REDECLARATION!>T<!>, <!REDECLARATION, REDECLARATION!>T<!>> Pair() {}
|
||||
|
||||
class P<<!REDECLARATION!>T<!>, <!REDECLARATION!>T<!>> {}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class Point() {
|
||||
|
||||
class G<T>() {}
|
||||
|
||||
fun f<T>(<!UNUSED_PARAMETER!>expression<!> : T) : G<out T> = G<T>()
|
||||
fun <T> f(<!UNUSED_PARAMETER!>expression<!> : T) : G<out T> = G<T>()
|
||||
|
||||
|
||||
fun foo() : G<Point> {
|
||||
@@ -13,7 +13,7 @@ fun foo() : G<Point> {
|
||||
|
||||
class Out<out T>() {}
|
||||
|
||||
fun fout<T>(<!UNUSED_PARAMETER!>expression<!> : T) : Out<<!REDUNDANT_PROJECTION!>out<!> T> = Out<T>()
|
||||
fun <T> fout(<!UNUSED_PARAMETER!>expression<!> : T) : Out<<!REDUNDANT_PROJECTION!>out<!> T> = Out<T>()
|
||||
|
||||
fun fooout() : Out<Point> {
|
||||
val p = Point();
|
||||
|
||||
@@ -12,7 +12,7 @@ class C {
|
||||
}
|
||||
}
|
||||
|
||||
fun foo<X : AutoCloseable>(<!UNUSED_PARAMETER!>x<!> : X, <!UNUSED_PARAMETER!>body<!> : (X) -> Unit) {
|
||||
fun <X : AutoCloseable> foo(<!UNUSED_PARAMETER!>x<!> : X, <!UNUSED_PARAMETER!>body<!> : (X) -> Unit) {
|
||||
}
|
||||
|
||||
fun p() : Resource? = null
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun assertEquals<T>(a: T, b: T) {
|
||||
fun <T> assertEquals(a: T, b: T) {
|
||||
if (a != b) throw AssertionError("$a != $b")
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ fun <T> generic_invoker(gen : () -> T) : T {
|
||||
|
||||
fun println(message : Int) { System.out.println(message) }
|
||||
fun println(message : Long) { System.out.println(message) }
|
||||
inline fun run<T>(body : () -> T) : T = body()
|
||||
inline fun <T> run(body : () -> T) : T = body()
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// KT-439 Support labeled function literals in call arguments
|
||||
|
||||
inline fun run1<T>(body : () -> T) : T = body()
|
||||
inline fun <T> run1(body : () -> T) : T = body()
|
||||
|
||||
fun main1(<!UNUSED_PARAMETER!>args<!> : Array<String>) {
|
||||
run1 l@{ 1 } // should not be an error
|
||||
|
||||
@@ -4,7 +4,7 @@ class A<T> {
|
||||
|
||||
class Foo<T>(<!UNUSED_PARAMETER!>i<!>: Int)
|
||||
|
||||
public fun Foo<E>(c: A<E>) {
|
||||
public fun <E> Foo(c: A<E>) {
|
||||
val <!UNUSED_VARIABLE!>a<!> = Foo<E>(c.size()) // Check no overload resolution ambiguity
|
||||
val <!UNUSED_VARIABLE!>b<!>: Foo<E> = Foo(c.size()) // OK
|
||||
val <!NAME_SHADOWING, UNUSED_VARIABLE!>c<!>: Foo<Int> = Foo(c.size()) // OK
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package demo
|
||||
|
||||
fun filter<T>(list : Array<T>, filter : (T) -> Boolean) : List<T> {
|
||||
fun <T> filter(list : Array<T>, filter : (T) -> Boolean) : List<T> {
|
||||
val answer = java.util.ArrayList<T>();
|
||||
for (l in list) {
|
||||
if (filter(l)) answer.add(l)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ package kt58
|
||||
|
||||
import java.util.concurrent.locks.Lock
|
||||
|
||||
fun lock<T>(lock : Lock, body : () -> T) : T {
|
||||
fun <T> lock(lock : Lock, body : () -> T) : T {
|
||||
lock.lock()
|
||||
try {
|
||||
return body()
|
||||
|
||||
@@ -6,7 +6,7 @@ open class B() : A() {
|
||||
|
||||
|
||||
class C() {
|
||||
fun a<T>(x: (T)->T, y: T): T {
|
||||
fun <T> a(x: (T)->T, y: T): T {
|
||||
return x(x(y))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// KT-702 Type inference failed
|
||||
fun getJavaClass<T>() : java.lang.Class<T> { return "" <!CAST_NEVER_SUCCEEDS!>as<!> Class<T> }
|
||||
fun <T> getJavaClass() : java.lang.Class<T> { return "" <!CAST_NEVER_SUCCEEDS!>as<!> Class<T> }
|
||||
|
||||
public class Throwables() {
|
||||
companion object {
|
||||
public fun propagateIfInstanceOf<X : Throwable?>(throwable : Throwable?, declaredType : Class<X<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>>?) {
|
||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>>?) {
|
||||
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
||||
{
|
||||
throw declaredType?.cast(throwable)!!
|
||||
|
||||
@@ -9,7 +9,7 @@ fun <T> TypeInfo<T>.getJavaClass() : java.lang.Class<T> {
|
||||
return <!UNCHECKED_CAST!>t.getClass() as java.lang.Class<T><!> // inferred type is Object but Serializable was expected
|
||||
}
|
||||
|
||||
fun getJavaClass<T>() = typeinfo<T>().getJavaClass()
|
||||
fun <T> getJavaClass() = typeinfo<T>().getJavaClass()
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
System.out.println(getJavaClass<String>())
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user