diagnostic tests changes after collections mapping

This commit is contained in:
Svetlana Isakova
2012-09-04 16:51:28 +04:00
parent bab20717ee
commit 7c828b9ff7
52 changed files with 39 additions and 104 deletions
@@ -1,5 +1,4 @@
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.List
public object RefreshQueue {
private val queue = ConcurrentLinkedQueue<List<String>>
@@ -1,6 +1,5 @@
package pack
import java.util.Collection
import java.util.ArrayList
import java.util.regex.Pattern
@@ -1,7 +1,6 @@
//KT-1800 error/NonExistentClass generated on runtime
package i
import java.util.Collection
import java.util.ArrayList
public class User(val firstName: String,
@@ -1,4 +1,3 @@
import java.util.Collection
class JsonObject() {
}
@@ -1,4 +1,3 @@
import java.util.Collection
import java.util.ArrayList
class JsonObject {
@@ -1,12 +1,11 @@
import java.util.HashMap
import java.util.Map
import java.io.*
fun <K, V> Map<K, V>.set(key : K, value : V) = put(key, value)
fun <K, V> MutableMap<K, V>.set(key : K, value : V) = put(key, value)
fun box() : String {
val commands : Map<String, String> = HashMap()
val commands : MutableMap<String, String> = HashMap()
commands["c1"] = "239"
if(commands["c1"] != "239") return "fail"
@@ -1,11 +1,10 @@
import java.util.ArrayList
import java.util.List
fun Int.plus(a: Int?) = this + a.sure()
public open class PerfectNumberFinder() {
open public fun isPerfect(number : Int) : Boolean {
var factors : List<Int?> = ArrayList<Int?>()
var factors : MutableList<Int?> = ArrayList<Int?>()
factors?.add(1)
factors?.add(number)
for (i in 2..(Math.sqrt((number).toDouble()) - 1).toInt())
@@ -1,4 +1,3 @@
import java.util.Set
import java.util.HashSet
fun foo() : Int =
@@ -9,7 +8,7 @@ fun foo() : Int =
"s"
}
fun bar(set : Set<Int>) : Set<Int> =
fun bar(set : MutableSet<Int>) : Set<Int> =
try {
set
}
@@ -148,7 +148,7 @@ fun html(init : HTML.() -> Unit) : HTML {
}
// An excerpt from the Standard Library
fun <K, V> Map<K, V>.set(key : K, value : V) = this.put(key, value)
fun <K, V> MutableMap<K, V>.set(key : K, value : V) = this.put(key, value)
fun println(message : Any?) {
System.out.println(message)
@@ -1,4 +1,3 @@
trait A {
fun foo() : Int = 1
fun foo2() : Int = 1
@@ -21,8 +20,7 @@ abstract class B() : A {
override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>a1<!> = 1.toDouble()
abstract override fun <X> g() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!>
abstract override fun <X> g1() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>java.util.List<X><!>
abstract override fun <X> g1() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>List<X><!>
abstract override val <X> g : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Iterator<Int><!>
}
}
@@ -4,8 +4,8 @@
package foobar.a
import java.*
val a : util.List<Int>? = null
val a1 : <!UNRESOLVED_REFERENCE!>List<!><Int>? = null
val a : <!CLASS_HAS_KOTLIN_ANALOG!>util.List<Int><!>? = null
val a1 : List<Int>? = null
// FILE: b.kt
package foobar
@@ -18,7 +18,7 @@ abstract class Foo<T>() {
package foobar.a
import java.util.*
val b : List<Int>? = a
val b : List<Int>? = <!TYPE_MISMATCH!>a<!>
val b1 : <!UNRESOLVED_REFERENCE!>util<!>.List<Int>? = a
// FILE: b.kt
@@ -64,4 +64,4 @@ abstract class Collection<E> : Iterable<E> {
}
return iteratee.done()
}
}
}
@@ -5,7 +5,7 @@ fun test(<!UNUSED_PARAMETER!>a<!> : annotation.RetentionPolicy) {
fun test() {
java.util.Collections.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()
val <!UNUSED_VARIABLE!>a<!> : java.util.Collection<String>? = java.util.Collections.emptyList()
val <!UNUSED_VARIABLE!>a<!> : Collection<String>? = java.util.Collections.emptyList()
}
fun test(<!UNUSED_PARAMETER!>a<!> : <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Comparable<Int><!>) {
@@ -9,11 +9,11 @@ import <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Comparable<!> as Com
val l : List<in Int> = ArrayList<Int>()
fun test(<!UNUSED_PARAMETER!>l<!> : java.util.List<Int>) {
fun test(<!UNUSED_PARAMETER!>l<!> : <!CLASS_HAS_KOTLIN_ANALOG!>java.util.List<Int><!>) {
val <!UNUSED_VARIABLE!>x<!> : java.<!UNRESOLVED_REFERENCE!>List<!>
val <!UNUSED_VARIABLE!>y<!> : java.util.List<Int>
val <!UNUSED_VARIABLE!>y<!> : <!CLASS_HAS_KOTLIN_ANALOG!>java.util.List<Int><!>
val <!UNUSED_VARIABLE!>b<!> : <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Object<!>
val <!UNUSED_VARIABLE!>a<!> : util.List<Int>
val <!UNUSED_VARIABLE!>a<!> : <!CLASS_HAS_KOTLIN_ANALOG!>util.List<Int><!>
val <!UNUSED_VARIABLE!>z<!> : java.<!UNRESOLVED_REFERENCE!>utils<!>.List<Int>
val <!UNUSED_VARIABLE!>f<!> : java.io.File? = null
@@ -1,5 +1,2 @@
import java.util.List;
import java.util.Collection;
fun ff(c: Collection<String>) = c <!CAST_NEVER_SUCCEEDS!>as<!> List<Int>
@@ -1,5 +1,2 @@
import java.util.List;
import java.util.Collection;
fun ff(c: Collection<String>) = c as List<String>
@@ -1,5 +1,3 @@
import java.util.List;
fun ff(l: Any) = l as List<*>
@@ -1,4 +1,2 @@
import java.util.List;
fun ff(a: Any) = <!UNCHECKED_CAST!>a as List<String><!>
@@ -1,7 +1,4 @@
import java.util.Collection;
import java.util.List;
open class A
class B : A()
@@ -1,6 +1,3 @@
import java.util.Collection;
import java.util.List;
fun ff(l: Collection<String>) = l is List<String>
@@ -1,6 +1,3 @@
import java.util.Collection;
import java.util.List;
fun ff<T>(l: Collection<T>) = l is List<T>
@@ -1,4 +1,2 @@
import java.util.List;
fun ff(l: Any) = l is <!CANNOT_CHECK_FOR_ERASED!>List<String><!>
@@ -1,4 +1,2 @@
import java.util.List
fun f(a : List<out Any>) = a is <!CANNOT_CHECK_FOR_ERASED!>List<out Int><!>
@@ -1,4 +1,2 @@
import java.util.List;
fun ff(l: Any) = l is List<*>
@@ -1,6 +1,4 @@
import java.util.List;
fun ff(l: Any) = when(l) {
is <!CANNOT_CHECK_FOR_ERASED!>List<String><!> -> 1
else <!SYNTAX!>2<!>
@@ -2,8 +2,6 @@
package kt1027
import java.util.List
fun foo(<!UNUSED_PARAMETER!>c<!>: List<Int>) {
var <!UNUSED_VARIABLE!>i<!> = 2
@@ -2,8 +2,6 @@
package kt1066
import java.util.Set
fun randomDigit() = 0.toChar()
fun foo(excluded: Set<Char>) {
@@ -1,8 +1,6 @@
// KT-2667 Support multi-declarations in for-loops in control flow analysis
package d
import java.util.List
class A {
fun component1() = 1
fun component2() = 2
@@ -3,8 +3,8 @@ package conflictingSubstitutions
import java.util.*
fun <R> elemAndList(r: R, <!UNUSED_PARAMETER!>t<!>: List<R>): R = r
fun <R> R.elemAndListWithReceiver(r: R, <!UNUSED_PARAMETER!>t<!>: List<R>): R = r
fun <R> elemAndList(r: R, <!UNUSED_PARAMETER!>t<!>: MutableList<R>): R = r
fun <R> R.elemAndListWithReceiver(r: R, <!UNUSED_PARAMETER!>t<!>: MutableList<R>): R = r
fun test() {
val <!UNUSED_VARIABLE!>s<!> = <!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>elemAndList<!>(11, list("72"))
@@ -22,7 +22,7 @@ fun test() {
fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
fun <in T, C: Collection<in T>> Array<T>.toCollection(result: C) : C {
fun <in T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
@@ -27,6 +27,6 @@ fun foo() {
fun <T> array(vararg t : T) : Array<T> = t
fun <T, R> Array<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : java.util.List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> Array<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : java.util.List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
@@ -2,8 +2,6 @@
package d
import java.util.List
fun <T> asList(<!UNUSED_PARAMETER!>t<!>: T) : List<T>? {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun main(args : Array<String>) {
@@ -8,6 +8,6 @@ fun test(numbers: Iterable<Int>) {
}
//from library
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : java.util.List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
@@ -2,10 +2,7 @@
//+JDK
package d
import java.util.Collection
import java.util.List
public fun <T> Collection<out T>.filterToMy(result : List<in T>, filter : (T) -> Boolean) : Collection<out T> {
public fun <T> Collection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : Collection<out T> {
for (t in this){
if (filter(t)){
result.add(t)
@@ -14,11 +11,11 @@ public fun <T> Collection<out T>.filterToMy(result : List<in T>, filter : (T) ->
return this
}
fun foo(result: List<in String>, val collection: Collection<String>, prefix : String){
fun foo(result: MutableList<in String>, val collection: Collection<String>, prefix : String){
collection.filterToMy(result, {it.startsWith(prefix)})
}
fun test(result: List<in Any>, val collection: Collection<String>, prefix : String){
fun test(result: MutableList<in Any>, val collection: Collection<String>, prefix : String){
val c = collection.filterToMy(result, {it.startsWith(prefix)})
c: Collection<out String>
}
@@ -1,10 +1,6 @@
//KT-1558 Exception while analyzing
package j
//+JDK
import java.util.List
fun testArrays(val ci: List<Int?>, val cii: List<Int?>) {
val c1: Array<Int?> = cii.sure().toArray(<!FUNCTION_CALL_EXPECTED!><!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>Array<!><Int?><!>)
@@ -1,7 +1,6 @@
//KT-1718 compiler error when not using temporary variable
package n
import java.util.List
import java.util.ArrayList
fun test() {
@@ -25,17 +25,17 @@ fun test() {
fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
fun <T, R> java.util.Collection<T>.map(transform : (T) -> R) : java.util.List<R> {
fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
fun <T, R, C: Collection<in R>> java.util.Collection<T>.mapTo(result: C, transform : (T) -> R) : C {
fun <T, R, C: MutableCollection<in R>> Collection<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
fun <in T, C: Collection<in T>> Array<T>.toCollection(result: C) : C {
fun <in T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
@@ -4,7 +4,7 @@ package n
abstract class Buggy {
abstract val coll : java.util.Collection<Int>
abstract val coll : Collection<Int>
fun getThree(): Int? {
return coll.find{ it > 3 } // works fine
@@ -27,7 +27,7 @@ fun assertEquals(<!UNUSED_PARAMETER!>expected<!>: Any?, <!UNUSED_PARAMETER!>actu
fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
fun <in T, C: Collection<in T>> Array<T>.toCollection(result: C) : C {
fun <in T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
@@ -2,7 +2,6 @@
package a
//+JDK
import java.util.List
fun <T> Array<T>.forEach(operation: (T) -> Unit) : Unit = for (element in this) operation(element)
@@ -1,8 +1,6 @@
//KT-2394 java.lang.Iterable<T> should be visible as jet.Iterable<out T>
package d
import java.util.Collection
fun foo(iterable: Iterable<Int>, iterator: Iterator<Int>, comparable: Comparable<Any>) {
iterable : Iterable<Any>
iterator : Iterator<Any>
@@ -1,5 +1,4 @@
import java.util.Collections
import java.util.List
val ab = Collections.emptyList<Int>() : List<Int>?
@@ -7,4 +7,4 @@ fun test() {
attributes["href"] = "1" // inference fails, but it shouldn't
}
fun <K, V> java.util.Map<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
fun <K, V> MutableMap<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
@@ -5,4 +5,4 @@ fun test() {
attributes["href"] = "1" // inference fails, but it shouldn't
}
fun <K, V> java.util.Map<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
fun <K, V> Map<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
@@ -4,14 +4,14 @@ package kt469
//KT-512 plusAssign() : Unit does not work properly
import java.util.*
fun bar(list : List<Int>) {
fun bar(list : MutableList<Int>) {
for (i in 1..10) {
list += i // error
}
System.out.println(list)
}
fun <T> List<T>.plusAssign(t : T) {
fun <T> MutableList<T>.plusAssign(t : T) {
add(t)
}
@@ -2,7 +2,7 @@
package demo
fun filter<T>(list : Array<T>, filter : (T) -> Boolean) : java.util.List<T> {
fun filter<T>(list : Array<T>, filter : (T) -> Boolean) : List<T> {
val answer = java.util.ArrayList<T>();
for (l in list) {
if (filter(l)) answer.add(l)
@@ -4,7 +4,7 @@ package kotlin.util
import java.util.*
fun <T, U: Collection<in T>> Iterator<T>.to(container: U) : U {
fun <T, U: MutableCollection<in T>> Iterator<T>.to(container: U) : U {
while(hasNext())
container.add(next())
return container
@@ -1,7 +1,5 @@
package i
import java.util.List
val <T> List<T>.length = <!UNRESOLVED_REFERENCE!>size<!>()
val <T> List<T>.length1 : Int get() = size()
@@ -1,7 +1,7 @@
//FILE:a.kt
//+JDK
package a
import java.util.Map.*
import jet.Map.*
fun foo(b : Entry<String, String>) = b
@@ -9,12 +9,11 @@ fun foo(b : Entry<String, String>) = b
//+JDK
package b
import java.util.Map.Entry
import jet.Map.Entry
fun bar(b : Entry<String, String>) = b
//FILE:c.kt
//+JDK
package c
import java.util.Map
fun fff(b: Map.Entry<String, String>) = b
@@ -1,4 +1,3 @@
import java.util.List
fun testArrays(ci : List<Int>) {
ci.toArray<Int>(<!UNRESOLVED_REFERENCE!>x<!>)
@@ -1,9 +1,7 @@
import java.util.List
import java.lang.CharSequence
fun foo(p: List<CharSequence>) = 1
// method: namespace::foo
// jvm signature: (Ljava/util/List;)I
// generic signature: (Ljava/util/List<Ljava/lang/CharSequence;>;)I
// kotlin signature: (Ljava/util/List<Mjava/lang/CharSequence;>;)I // TODO: skip Kotlin signature
// kotlin signature: (Ljava/util/List<Ljava/lang/CharSequence;>;)I // TODO: skip Kotlin signature
@@ -1,7 +1,6 @@
import java.util.List
fun listOfStar(): List<*> = throw Exception()
// method: namespace::listOfStar
// jvm signature: ()Ljava/util/List;
// generic signature: ()Ljava/util/List<+Ljava/lang/Object;>;
@@ -1,4 +1,3 @@
import java.util.Collection
class TestingKotlinCollections(val arguments: Collection<String>)