Merge branch 'master' of git+ssh://git.labs.intellij.net/jet into KT-337
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
//KT-600 Problem with 'sure' extension function type inference
|
||||
|
||||
fun <T : Any> T?.sure() : T { if (this != null) return this else throw NullPointerException() }
|
||||
|
||||
fun test() {
|
||||
val i : Int? = 10
|
||||
val <!UNUSED_VARIABLE!>i2<!> : Int = i.sure() // inferred type is Int? but Int was excepted
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
+4
-2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace abstract
|
||||
|
||||
class MyClass() {
|
||||
@@ -235,7 +237,7 @@ abstract class B3(i: Int) {
|
||||
this(): this(1)
|
||||
}
|
||||
|
||||
fun foo(a: B3) {
|
||||
fun foo(c: B3) {
|
||||
val <!UNUSED_VARIABLE!>a<!> = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B3()<!>
|
||||
val <!UNUSED_VARIABLE!>b<!> = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B1(2, "s")<!>
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class AClass() {
|
||||
val x : Any? = 1
|
||||
|
||||
fun Any?.vars(a: Any?) : Int {
|
||||
var <!UNUSED_VARIABLE!>b<!>: Int = 0
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>b<!>: Int = 0
|
||||
if (ns.y is Int) {
|
||||
b = <!UNUSED_VALUE!>ns.y<!>
|
||||
}
|
||||
@@ -74,7 +74,7 @@ trait T {}
|
||||
|
||||
open class C {
|
||||
fun foo() {
|
||||
var <!UNUSED_VARIABLE!>t<!> : T? = null
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>t<!> : T? = null
|
||||
if (this is T) {
|
||||
t = <!UNUSED_VALUE!>this<!>
|
||||
}
|
||||
@@ -88,4 +88,4 @@ open class C {
|
||||
t = <!UNUSED_VALUE!>this@C<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ class C() {
|
||||
}
|
||||
|
||||
fun f(): Unit {
|
||||
var x: Int? = 1
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>x<!>: Int? = 1
|
||||
x = 1
|
||||
x <!UNSAFE_INFIX_CALL!>+<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!>plus<!> 1
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
namespace html {
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace Jet86
|
||||
|
||||
class A {
|
||||
@@ -27,4 +29,4 @@ val s = <!NO_CLASS_OBJECT!>System<!> // error
|
||||
fun test() {
|
||||
System.out?.println()
|
||||
java.lang.System.out?.println()
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
trait A {
|
||||
fun foo() : Int = 1
|
||||
fun foo2() : Int = 1
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun Int?.optint() : Unit {}
|
||||
val Int?.optval : Unit = ()
|
||||
|
||||
@@ -68,4 +70,4 @@ namespace null_safety {
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class NotRange1() {
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun none() {}
|
||||
|
||||
fun unitEmptyInfer() {}
|
||||
@@ -209,4 +211,4 @@ fun testFunctionLiterals() {
|
||||
object A {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace foo
|
||||
|
||||
class X {}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace foobar
|
||||
|
||||
namespace a {
|
||||
@@ -60,4 +62,4 @@ abstract class Collection<E> : Iterable<E> {
|
||||
}
|
||||
return iteratee.done()
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun test() {
|
||||
val a : Int? = 0
|
||||
if (a != null) {
|
||||
@@ -277,4 +279,4 @@ fun f9(a : Int?) : Int {
|
||||
if (a != null)
|
||||
return a
|
||||
return 1
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
// Fixpoint generic in Java: Enum<T extends Enum<T>>
|
||||
fun test(a : annotation.RetentionPolicy) {
|
||||
|
||||
@@ -17,4 +19,4 @@ fun test(a : java.util.ArrayList<Int>) {
|
||||
|
||||
fun test(a : java.lang.Class<Int>) {
|
||||
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.*
|
||||
import util.*
|
||||
import <!UNRESOLVED_REFERENCE!>utils<!>.*
|
||||
@@ -49,4 +51,4 @@ fun test(l : java.util.List<Int>) {
|
||||
|
||||
namespace xxx {
|
||||
import java.lang.Class;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -16,7 +16,7 @@ fun t1(b : Boolean) {
|
||||
}
|
||||
doSmth(<!UNINITIALIZED_VARIABLE!>u<!>)
|
||||
|
||||
var r: String
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>r<!>: String
|
||||
if (b) {
|
||||
r = "s"
|
||||
}
|
||||
@@ -63,10 +63,10 @@ fun t4(a: A, val b: A, var c: A) {
|
||||
// reassigned vals
|
||||
|
||||
fun t1() {
|
||||
val <!UNUSED_VARIABLE!>a<!> : Int = 1
|
||||
val <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>a<!> : Int = 1
|
||||
<!VAL_REASSIGNMENT!>a<!> = <!UNUSED_VALUE!>2<!>
|
||||
|
||||
var <!UNUSED_VARIABLE!>b<!> : Int = 1
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>b<!> : Int = 1
|
||||
b = <!UNUSED_VALUE!>3<!>
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ class AnonymousInitializers(var a: String, val b: String) {
|
||||
|
||||
{
|
||||
<!VAL_REASSIGNMENT!>$i<!> = 13
|
||||
<!NO_BACKING_FIELD!>$j<!> = 30
|
||||
<!VAL_REASSIGNMENT!>j<!> = 34
|
||||
<!NO_BACKING_FIELD, VAL_REASSIGNMENT!>$j<!> = 30
|
||||
j = 34
|
||||
}
|
||||
|
||||
val k: String
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun t1() : Int{
|
||||
return 0
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace unused_variables
|
||||
|
||||
fun testSimpleCases() {
|
||||
var i = 2
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>i<!> = 2
|
||||
i = <!UNUSED_VALUE!>34<!>
|
||||
i = 34
|
||||
doSmth(i)
|
||||
@@ -9,7 +9,7 @@ fun testSimpleCases() {
|
||||
|
||||
var j = 2
|
||||
j = <!UNUSED_CHANGED_VALUE!>j++<!>
|
||||
j = <!UNUSED_CHANGED_VALUE, UNUSED_VALUE!>j--<!>
|
||||
j = <!UNUSED_VALUE, UNUSED_CHANGED_VALUE!>j--<!>
|
||||
}
|
||||
|
||||
class IncDec() {
|
||||
@@ -45,7 +45,7 @@ class MyTest() {
|
||||
fun testSimple() {
|
||||
a = "rro"
|
||||
|
||||
var <!UNUSED_VARIABLE!>i<!> = 1;
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>i<!> = 1;
|
||||
i = <!UNUSED_VALUE!>34<!>;
|
||||
i = <!UNUSED_VALUE!>456<!>;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class MyTest() {
|
||||
}
|
||||
|
||||
fun testIf() {
|
||||
var a : Any
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>a<!> : Any
|
||||
if (1 < 2) {
|
||||
a = 23
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class MyTest() {
|
||||
}
|
||||
|
||||
fun testInnerFunctions() {
|
||||
var <!UNUSED_VARIABLE!>y<!> = 1
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>y<!> = 1
|
||||
fun foo() {
|
||||
y = <!UNUSED_VALUE!>1<!>
|
||||
}
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
class Foo1() : java.util.ArrayList<Int>()
|
||||
|
||||
open class Bar() {
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// KT-389 Wrong type inference for varargs etc.
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
@@ -23,4 +24,4 @@ fun test() {
|
||||
fool(1, 2, 3)
|
||||
food(1.0, 2.0, 3.0)
|
||||
foof(1.0.flt, 2.0.flt, 3.0.flt)
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = l as List<*>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(a: Any) = <!UNCHECKED_CAST!>a as List<String><!>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = l is <!CANNOT_CHECK_FOR_ERASED!>List<String><!>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = l is List<*>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = when(l) {
|
||||
+1
-1
@@ -179,7 +179,7 @@ fun declarations(a: Any?) {
|
||||
}
|
||||
}
|
||||
fun vars(a: Any?) {
|
||||
var <!UNUSED_VARIABLE!>b<!>: Int = 0
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>b<!>: Int = 0
|
||||
if (a is Int) {
|
||||
b = <!UNUSED_VALUE!>a<!>
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.*
|
||||
import util.*
|
||||
|
||||
@@ -63,4 +65,4 @@ fun main(args: Array<String>) {
|
||||
catch(e: Throwable) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// JET-72 Type inference doesn't work when iterating over ArrayList
|
||||
// +JDK
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//KT-235 Illegal assignment return type
|
||||
// +JDK
|
||||
|
||||
namespace kt235
|
||||
|
||||
@@ -16,7 +17,7 @@ fun main(args: Array<String>) {
|
||||
<!EXPECTED_TYPE_MISMATCH!>x = 2<!> //the same
|
||||
}
|
||||
val array1 = MyArray1()
|
||||
val <!UNUSED_VARIABLE!>x<!> = { (): String =>
|
||||
val <!UNUSED_VARIABLE!>i<!> = { (): String =>
|
||||
<!EXPECTED_TYPE_MISMATCH!>array1[2] = 23<!>
|
||||
}
|
||||
|
||||
@@ -46,4 +47,4 @@ class MyArray1() {
|
||||
|
||||
class MyNumber() {
|
||||
fun inc(): MyNumber = MyNumber()
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// KT-258 Support equality constraints in type inference
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// KT-287 Infer constructor type arguments
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun attributes() : Map<String, String> = HashMap() // Should be inferred;
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// KT-313 Bug in substitutions in a function returning its type parameter T
|
||||
// +JDK
|
||||
|
||||
fun <T> Iterable<T>.join(separator : String?) : String {
|
||||
return separator.npe()
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference)
|
||||
// KT-335 Type inference fails on Collections.sort
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
import java.lang.Comparable as Comparable
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// KT-385 type inference does not work properly`
|
||||
// KT-109 Good code is red: type arguments are not inferred
|
||||
// KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
@@ -31,4 +32,4 @@ inline fun run<T>(body : fun() : T) : T = body()
|
||||
fun main(args : Array<String>) {
|
||||
|
||||
println(run { 1 })
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
// KT-459 Type argument inference fails when class names are fully qualified
|
||||
// +JDK
|
||||
|
||||
fun test() {
|
||||
val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure!
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace kt469
|
||||
|
||||
//KT-512 plusAssign() : Unit does not work properly
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
//KT-549 type inference failed
|
||||
// +JDK
|
||||
|
||||
namespace demo
|
||||
|
||||
fun filter<T>(list : Array<T>, filter : fun (T) : Boolean) : java.util.List<T> {
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
//KT-58 Allow finally around definite returns
|
||||
// +JDK
|
||||
|
||||
namespace kt58
|
||||
|
||||
@@ -88,4 +89,4 @@ fun t7() : Int {
|
||||
}
|
||||
|
||||
fun doSmth(i: Int) {
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,11 +1,13 @@
|
||||
//KT-580 Type inference failed
|
||||
// +JDK
|
||||
|
||||
namespace whats.the.difference
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun iarray(vararg a : String) = a // BUG
|
||||
|
||||
fun main(vals : IntArray) {
|
||||
fun main() {
|
||||
val vals = iarray("789", "678", "567")
|
||||
val diffs = ArrayList<Int>
|
||||
for (i in vals.indices) {
|
||||
@@ -17,4 +19,4 @@ fun main(vals : IntArray) {
|
||||
}
|
||||
|
||||
fun <T> Array<T>.lastIndex() = size - 1
|
||||
val <T> Array<T>.lastIndex : Int get() = size - 1
|
||||
val <T> Array<T>.lastIndex : Int get() = size - 1
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user