diagnostics for deprecated syntax of function type parameter list

This commit is contained in:
Dmitry Jemerov
2015-10-05 20:26:47 +02:00
parent c5d3673b6b
commit 7c20630272
156 changed files with 236 additions and 213 deletions
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
View File
@@ -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()
+1 -1
View File
@@ -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))
}
+2 -2
View File
@@ -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)!!
+1 -1
View File
@@ -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>())
+1 -1
View File
@@ -4,4 +4,4 @@ class List<T>(val head: T, val tail: List<T>? = null)
fun <T : Any> T?.sure() : T = this!!
fun <T, Q> List<T>.map(f: (T)-> Q): List<T>? = tail.sure<List<T>>().map(f)
fun foo<T>(t : T) : T = foo(t)
fun <T> foo(t : T) : T = foo(t)