Adjust testData to CharSequence.length transformation
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cb562e7ea5
commit
f0e3fd617d
@@ -2,5 +2,5 @@ package foo
|
||||
|
||||
fun test() {
|
||||
Int::toByte
|
||||
String::length
|
||||
String::get
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt:4:5: error: callable references for builtin members are not supported yet: 'Int::toByte'
|
||||
Int::toByte
|
||||
^
|
||||
compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt:5:5: error: callable references for builtin members are not supported yet: 'String::length'
|
||||
String::length
|
||||
compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt:5:5: error: callable references for builtin members are not supported yet: 'String::get'
|
||||
String::get
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class Outer(val foo: StringBuilder) {
|
||||
inner class Inner() {
|
||||
fun len() : Int {
|
||||
return foo.length()
|
||||
return foo.length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ fun box() : String {
|
||||
val w = object : Comparator<String?> {
|
||||
|
||||
override fun compare(o1 : String?, o2 : String?) : Int {
|
||||
val l1 : Int = o1?.length() ?: 0
|
||||
val l2 = o2?.length() ?: 0
|
||||
val l1 : Int = o1?.length ?: 0
|
||||
val l2 = o2?.length ?: 0
|
||||
return l1 - l2
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ interface B<T> {
|
||||
}
|
||||
|
||||
fun String.foo() = object : B<String> {
|
||||
override val bar: String = length().toString()
|
||||
override val bar: String = length.toString()
|
||||
}
|
||||
|
||||
class C {
|
||||
|
||||
fun String.extension() = this.length()
|
||||
fun String.extension() = this.length
|
||||
|
||||
fun String.fooInClass() = object : B<String> {
|
||||
override val bar: String = extension().toString()
|
||||
|
||||
@@ -8,7 +8,7 @@ fun box(): String {
|
||||
if (y != 5) return "Fail 2 $y"
|
||||
|
||||
var z = ""
|
||||
do { z += z.length() } while (z.length() < 5)
|
||||
do { z += z.length } while (z.length < 5)
|
||||
if (z != "01234") return "Fail 3 $z"
|
||||
|
||||
return "OK"
|
||||
|
||||
@@ -12,7 +12,7 @@ public fun testCoalesce() {
|
||||
else -> "Hello world"
|
||||
}
|
||||
|
||||
printlnMock(value.length())
|
||||
printlnMock(value.length)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ object StringHandler {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
a.foo = 42
|
||||
a.foo = a.foo + baz.length()
|
||||
a.foo = a.foo + baz.length
|
||||
a.foo = 239
|
||||
A.bar = baz + a.foo
|
||||
baz + A.bar
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun escapeChar(c : Char) : String? = when (c) {
|
||||
}
|
||||
|
||||
tailrec fun String.escape(i : Int = 0, result : StringBuilder = StringBuilder()) : String =
|
||||
if (i == length()) result.toString()
|
||||
if (i == length) result.toString()
|
||||
else escape(i + 1, result.append(escapeChar(get(i))))
|
||||
|
||||
fun box() : String {
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ tailrec fun String.repeat(num : Int, acc : StringBuilder = StringBuilder()) : St
|
||||
|
||||
fun box() : String {
|
||||
val s = "a".repeat(10000)
|
||||
return if (s.length() == 10000) "OK" else "FAIL: ${s.length()}"
|
||||
return if (s.length == 10000) "OK" else "FAIL: ${s.length}"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun StringBuilder.takeFirst(): Char {
|
||||
if (this.length() == 0) return 0.toChar()
|
||||
if (this.length == 0) return 0.toChar()
|
||||
val c = this.get(0)
|
||||
this.deleteCharAt(0)
|
||||
return c
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ fun box(): String {
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.length() == 0) return "OK"
|
||||
if (sb.length == 0) return "OK"
|
||||
return "Fail:\n$sb"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ fun box(): String {
|
||||
val list = java.util.ArrayList<String>()
|
||||
list.add("0")
|
||||
list[0][0]
|
||||
list[0].length()
|
||||
list[0].length
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ fun escapeChar(c : Char) : String? = when (c) {
|
||||
}
|
||||
|
||||
fun String.escape(i : Int = 0, result : String = "") : String =
|
||||
if (i == length()) result
|
||||
if (i == length) result
|
||||
else escape(i + 1, result + escapeChar(get(i)))
|
||||
|
||||
fun box() : String {
|
||||
@@ -19,7 +19,7 @@ fun box() : String {
|
||||
System.out?.println("}");
|
||||
System.out?.println();
|
||||
System.out?.println("fun String.escape(i : Int = 0, result : String = \"\") : String =");
|
||||
System.out?.println(" if (i == length()) result");
|
||||
System.out?.println(" if (i == length) result");
|
||||
System.out?.println(" else escape(i + 1, result + escapeChar(this.get(i)))");
|
||||
System.out?.println();
|
||||
System.out?.println("fun main(args : Array<String>) {");
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ class Test {
|
||||
private val b : String get() = a
|
||||
|
||||
fun outer() : Int {
|
||||
return b.length()
|
||||
return b.length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
fun t1() : Boolean {
|
||||
val s1 : String? = "sff"
|
||||
val s2 : String? = null
|
||||
return s1?.length() == 3 && s2?.length() == null
|
||||
return s1?.length == 3 && s2?.length == null
|
||||
}
|
||||
|
||||
fun t2() : Boolean {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class Thing(delegate: CharSequence) : CharSequence by delegate
|
||||
|
||||
fun box(): String {
|
||||
val l = Thing("hello there").length()
|
||||
val l = Thing("hello there").length
|
||||
return if (l == 11) "OK" else "Fail $l"
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ class Thing(val delegate: CharSequence) : CharSequence {
|
||||
override fun get(index: Int): Char {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
override fun length(): Int = 0
|
||||
override val length: Int get() = 0
|
||||
override fun subSequence(start: Int, end: Int) = delegate.subSequence(start, end)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ fun box() : String {
|
||||
|
||||
val test5 =
|
||||
"""
|
||||
${s.length()}
|
||||
${s.length}
|
||||
"""
|
||||
if (test5 != "\n 3\n") return "Fail 5: $test5"
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ fun box(): String {
|
||||
|
||||
override fun condition(): Boolean {
|
||||
result = "OK"
|
||||
return result.length() == 2
|
||||
return result.length== 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-10
@@ -2,16 +2,6 @@ import java.lang.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static class IterableImpl implements Iterable<String> {
|
||||
public Iterator<String> iterator() { return new IteratorImpl(); }
|
||||
}
|
||||
|
||||
public static class IteratorImpl implements Iterator<String> {
|
||||
public boolean hasNext() { return false; }
|
||||
public String next() { return null; }
|
||||
public void remove() { }
|
||||
}
|
||||
|
||||
public static class MapEntryImpl implements Map.Entry<String, String> {
|
||||
public String getKey() { return null; }
|
||||
public String getValue() { return null; }
|
||||
|
||||
+2
-8
@@ -1,14 +1,8 @@
|
||||
class MyIterable : Test.IterableImpl()
|
||||
class MyIterator : Test.IteratorImpl()
|
||||
//class MyIterable : Test.IterableImpl()
|
||||
//class MyIterator : Test.IteratorImpl()
|
||||
class MyMapEntry : Test.MapEntryImpl()
|
||||
|
||||
fun box(): String {
|
||||
MyIterable().iterator()
|
||||
|
||||
val a = MyIterator()
|
||||
a.hasNext()
|
||||
a.next()
|
||||
a.remove()
|
||||
|
||||
val b = MyMapEntry()
|
||||
b.getKey()
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
fun box(): String =
|
||||
if (listOf("abc", "de", "f").map(String::length) == listOf(3, 2, 1)) "OK" else "Fail"
|
||||
if (listOf("abc", "de", "f").map(String::length.getter) == listOf(3, 2, 1)) "OK" else "Fail"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Evaluator(val expr: StringBuilder) {
|
||||
fun evaluateArg(): Int {
|
||||
return expr.length()
|
||||
return expr.length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -16,8 +16,8 @@ fun test() : Unit {
|
||||
checkSubtype<Int?>(y as? Int?)
|
||||
|
||||
val <!UNUSED_VARIABLE!>s<!> = "" <!USELESS_CAST!>as Any<!>
|
||||
("" as String?)?.length()
|
||||
(data@("" as String?))?.length()
|
||||
(<!WRONG_ANNOTATION_TARGET!>@MustBeDocumented()<!>( "" as String?))?.length()
|
||||
("" as String?)?.length
|
||||
(data@("" as String?))?.length
|
||||
(<!WRONG_ANNOTATION_TARGET!>@MustBeDocumented()<!>( "" as String?))?.length
|
||||
Unit
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,6 +60,6 @@ public class B {
|
||||
lateinit var a: String
|
||||
|
||||
init {
|
||||
a.length()
|
||||
a.length
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ fun box() : String {
|
||||
|
||||
val test5 =
|
||||
"""
|
||||
${s.length()}
|
||||
${s.length}
|
||||
"""
|
||||
if (test5 != "\n 3\n") return "Fail 5: $test5"
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ class SomeClass {
|
||||
get() = "A"
|
||||
}
|
||||
|
||||
fun @receiver:Ann String.length2() = length()
|
||||
fun @receiver:Ann String.length2() = length
|
||||
|
||||
val @receiver:Ann String.extensionProperty: String
|
||||
get() = "A"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
import kotlin.reflect.*
|
||||
|
||||
val String.countCharacters: Int
|
||||
get() = length()
|
||||
get() = length
|
||||
|
||||
var Int.meaning: Long
|
||||
get() = 42L
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
fun illegalWhenBlock(a: Any): Int {
|
||||
when(a) {
|
||||
is Int -> return <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||
is String -> return <!DEBUG_INFO_SMARTCAST!>a<!>.length()
|
||||
is String -> return <!DEBUG_INFO_SMARTCAST!>a<!>.length
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
fun foo(o: Any) {
|
||||
if (o is String) {
|
||||
val s = o <!USELESS_CAST!>as String<!>
|
||||
s.length()
|
||||
s.length
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(o: Any) {
|
||||
if (o is String) {
|
||||
<!DEBUG_INFO_SMARTCAST!>o<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>o<!>.length
|
||||
val s = o
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
fun test(a: Any?, flag: Boolean, x: Any?) {
|
||||
if (a !is String) return
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>a<!>.length
|
||||
|
||||
val b: Any?
|
||||
|
||||
if (flag) {
|
||||
b = a
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>b<!>.length
|
||||
}
|
||||
else {
|
||||
b = x
|
||||
|
||||
@@ -2,7 +2,7 @@ fun test(a: Any?) {
|
||||
when (a) {
|
||||
is String -> {
|
||||
val s = a
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
"" -> {
|
||||
val s = a
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ fun test(x: Any) {
|
||||
if (y !is String) return
|
||||
class Local {
|
||||
init {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ fun test(x: Any?) {
|
||||
if (x !is String) return
|
||||
|
||||
class C {
|
||||
val v = <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
val v = <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
|
||||
val vGet: Int
|
||||
get() = <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
get() = <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
|
||||
val s: String = <!DEBUG_INFO_SMARTCAST!>x<!>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
fun foo(x: Any?) {
|
||||
if (x is String) {
|
||||
object : Base(<!DEBUG_INFO_SMARTCAST!>x<!>) {
|
||||
fun bar() = <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
fun bar() = <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ fun test(x: Any) {
|
||||
class LocalOuter {
|
||||
inner class Local {
|
||||
init {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
fun testWhen(t: String?, x: String?): Int {
|
||||
return when {
|
||||
t == null -> 0
|
||||
x == null -> <!DEBUG_INFO_SMARTCAST!>t<!>.length() // Wrong error report here. t can be inferred as not-null. (And it actually does if you replace when with if/else if)
|
||||
else -> (<!DEBUG_INFO_SMARTCAST!>t<!> + x).length()
|
||||
x == null -> <!DEBUG_INFO_SMARTCAST!>t<!>.length // Wrong error report here. t can be inferred as not-null. (And it actually does if you replace when with if/else if)
|
||||
else -> (<!DEBUG_INFO_SMARTCAST!>t<!> + x).length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ fun test(param: String) {
|
||||
|
||||
val local_val = 4
|
||||
val bar = fun B.(fun_param: Int) {
|
||||
param.length()
|
||||
param.length
|
||||
b_fun()
|
||||
val inner_bar = local_val + fun_param
|
||||
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
fun <T : Any?> foo(x: T) {
|
||||
if (x is String<!USELESS_NULLABLE_CHECK!>?<!>) {
|
||||
x<!UNSAFE_CALL!>.<!>length()
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
if (x != null) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
if (x is String) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
if (x != null) {
|
||||
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
|
||||
x.bar1()
|
||||
x.bar2()
|
||||
@@ -23,11 +23,11 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
}
|
||||
|
||||
x<!UNSAFE_CALL!>.<!>length()
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
if (x is String) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!><!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!><!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||
x.bar2()
|
||||
@@ -35,8 +35,8 @@ fun <T : CharSequence?> foo(x: T) {
|
||||
}
|
||||
|
||||
if (x is CharSequence) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||
x.bar2()
|
||||
|
||||
+5
-5
@@ -10,8 +10,8 @@ fun <T : String?> T.foo() {
|
||||
if (this != null) {
|
||||
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
||||
|
||||
length()
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
length
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
|
||||
bar1()
|
||||
bar2()
|
||||
@@ -22,11 +22,11 @@ fun <T : String?> T.foo() {
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
||||
}
|
||||
|
||||
<!UNSAFE_CALL!>length<!>()
|
||||
<!UNSAFE_CALL!>length<!>
|
||||
|
||||
if (this is String) {
|
||||
length()
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length()
|
||||
length
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||
|
||||
bar1()
|
||||
bar2()
|
||||
|
||||
@@ -8,11 +8,11 @@ fun <T : CharSequence> T.bar3() {}
|
||||
fun <T, R> T.let(f: (T) -> R): R = f(this)
|
||||
|
||||
fun <T : String?> foo(x: T) {
|
||||
x<!UNSAFE_CALL!>.<!>length()
|
||||
x?.length()
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
x?.length
|
||||
|
||||
if (1 == 1) {
|
||||
x!!.length()
|
||||
x!!.length
|
||||
}
|
||||
|
||||
|
||||
@@ -24,5 +24,5 @@ fun <T : String?> foo(x: T) {
|
||||
|
||||
x.<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
|
||||
|
||||
x?.let { it<!UNSAFE_CALL!>.<!>length() }
|
||||
x?.let { it<!UNSAFE_CALL!>.<!>length }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package n
|
||||
import java.util.*
|
||||
|
||||
fun test() {
|
||||
val foo = arrayList("").map { it -> it.length() }.fold(0, { x, y -> Math.max(x, y) })
|
||||
val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) })
|
||||
checkSubtype<Int>(foo)
|
||||
checkSubtype<String>(<!TYPE_MISMATCH!>foo<!>)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ fun <T> Array<T>.forEach(operation: (T) -> Unit) : Unit { for (element in this)
|
||||
fun bar(operation: (String) -> Unit) = operation("")
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args.forEach { a : String -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { a -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { it.length() } // This works!
|
||||
args.forEach { a : String -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { a -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found
|
||||
args.forEach { it.length } // This works!
|
||||
|
||||
bar { a: String -> a.length() }
|
||||
bar { a -> a.length() }
|
||||
bar { it.length() }
|
||||
bar { a: String -> a.length }
|
||||
bar { a -> a.length }
|
||||
bar { it.length }
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import java.util.*
|
||||
|
||||
fun foo(lines: List<String>) {
|
||||
val w = max(lines, comparator {o1, o2 ->
|
||||
val l1 : Int = o1.length() // Types of o1 and o2 are ERROR
|
||||
val l2 = o2.length()
|
||||
val l1 : Int = o1.length // Types of o1 and o2 are ERROR
|
||||
val l2 = o2.length
|
||||
l1 - l2
|
||||
}).sure()
|
||||
checkSubtype<String>(w)
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
|
||||
inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) {
|
||||
bar1 label@ {
|
||||
this@label.length()
|
||||
this@label.length
|
||||
}
|
||||
|
||||
bar1 {
|
||||
this.length()
|
||||
this.length
|
||||
}
|
||||
//unmute after KT-4247 fix
|
||||
//bar1 {
|
||||
|
||||
+1
-1
@@ -15,6 +15,6 @@ public class Y extends X<String> {
|
||||
// FILE: test.kt
|
||||
|
||||
fun main() {
|
||||
Y().foo().length()
|
||||
Y().foo().length
|
||||
Y().bar(null)
|
||||
}
|
||||
|
||||
@@ -2,20 +2,20 @@ package
|
||||
|
||||
public open class C : kotlin.CharSequence {
|
||||
public constructor C()
|
||||
public open override /*1*/ val length: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@java.lang.Override() public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@java.lang.Override() public open override /*1*/ fun length(): kotlin.Int
|
||||
@java.lang.Override() public open override /*1*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence
|
||||
@java.lang.Override() public open override /*1*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class T : C {
|
||||
public constructor T()
|
||||
public open override /*1*/ /*fake_override*/ val length: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@java.lang.Override() public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@java.lang.Override() public open override /*1*/ /*fake_override*/ fun length(): kotlin.Int
|
||||
@java.lang.Override() public open override /*1*/ /*fake_override*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence
|
||||
@java.lang.Override() public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
|
||||
fun foo(bar1: (String.() -> Int) -> Int) {
|
||||
bar1 {
|
||||
this.length()
|
||||
this.length
|
||||
}
|
||||
|
||||
bar1 {
|
||||
this@bar1.length()
|
||||
this@bar1.length
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,18 @@ package kt244
|
||||
|
||||
fun f(s: String?) {
|
||||
if (s != null) {
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length() //ok
|
||||
var <!UNUSED_VARIABLE!>i<!> = <!DEBUG_INFO_SMARTCAST!>s<!>.length() //error: Only safe calls are allowed on a nullable receiver
|
||||
System.out.println(<!DEBUG_INFO_SMARTCAST!>s<!>.length()) //error
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length //ok
|
||||
var <!UNUSED_VARIABLE!>i<!> = <!DEBUG_INFO_SMARTCAST!>s<!>.length //error: Only safe calls are allowed on a nullable receiver
|
||||
System.out.println(<!DEBUG_INFO_SMARTCAST!>s<!>.length) //error
|
||||
}
|
||||
}
|
||||
|
||||
// more tests
|
||||
class A(a: String?) {
|
||||
val b = if (a != null) <!DEBUG_INFO_SMARTCAST!>a<!>.length() else 1
|
||||
val b = if (a != null) <!DEBUG_INFO_SMARTCAST!>a<!>.length else 1
|
||||
init {
|
||||
if (a != null) {
|
||||
val <!UNUSED_VARIABLE!>c<!> = <!DEBUG_INFO_SMARTCAST!>a<!>.length()
|
||||
val <!UNUSED_VARIABLE!>c<!> = <!DEBUG_INFO_SMARTCAST!>a<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class A(a: String?) {
|
||||
|
||||
init {
|
||||
if (a is String) {
|
||||
i = <!DEBUG_INFO_SMARTCAST!>a<!>.length()
|
||||
i = <!DEBUG_INFO_SMARTCAST!>a<!>.length
|
||||
}
|
||||
else {
|
||||
i = 3
|
||||
|
||||
+2
-2
@@ -8,10 +8,10 @@ fun withLambda(o : Int, block : Int.(String) -> Unit) {
|
||||
|
||||
fun test() {
|
||||
withLambda {
|
||||
it.length()
|
||||
it.length
|
||||
}
|
||||
|
||||
withLambda { r -> // no error should be here
|
||||
r.length()
|
||||
r.length
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@ fun withLambda(block : Int.(String, String) -> Unit) {
|
||||
|
||||
fun test() {
|
||||
withLambda { r ->
|
||||
r.length()
|
||||
r.length
|
||||
}
|
||||
|
||||
withLambda { x, y ->
|
||||
x.length() + y.length()
|
||||
x.length + y.length
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ fun test(j: J) {
|
||||
j.j()!!.j()
|
||||
|
||||
val ann = j.foo<String>()
|
||||
ann!!.length()
|
||||
ann.length()
|
||||
ann!!.length
|
||||
ann.length
|
||||
|
||||
val a = j.foo<J>()
|
||||
a!!.j()
|
||||
|
||||
@@ -12,5 +12,5 @@ public class J {
|
||||
import p.*
|
||||
|
||||
fun test(j: J) {
|
||||
j.s()?.length() ?: ""
|
||||
j.s()?.length ?: ""
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ public class J {
|
||||
// FILE: k.kt
|
||||
|
||||
fun safeCall(c: J?) {
|
||||
c?.nn()?.length()
|
||||
c?.nn()?.length
|
||||
}
|
||||
|
||||
fun ifelse(c: J): Any? {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class J {
|
||||
|
||||
fun foo(collection: Collection<J>) {
|
||||
val mapped = collection.map { it.method() }
|
||||
mapped[0]<!UNSAFE_CALL!>.<!>length()
|
||||
mapped[0]<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
public fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
|
||||
|
||||
@@ -4,6 +4,6 @@ fun foo() {
|
||||
val list = ArrayList<String?>()
|
||||
|
||||
for (s in list) {
|
||||
s<!UNSAFE_CALL!>.<!>length()
|
||||
s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,5 @@ public class J {
|
||||
import p.*
|
||||
|
||||
fun test(j: J) {
|
||||
j.s()?.length().checkType { _<Int?>() }
|
||||
j.s()?.length.checkType { _<Int?>() }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ fun takeFirst(expr: StringBuilder): Char {
|
||||
}
|
||||
|
||||
fun evaluateArg(expr: CharSequence, numbers: ArrayList<Int>): Int {
|
||||
if (expr.length() == 0) throw Exception("Syntax error: Character expected");
|
||||
if (expr.length == 0) throw Exception("Syntax error: Character expected");
|
||||
val c = takeFirst(<!TYPE_MISMATCH!>expr<!>)
|
||||
if (c >= '0' && c <= '9') {
|
||||
val n = c - '0'
|
||||
@@ -22,7 +22,7 @@ fun evaluateArg(expr: CharSequence, numbers: ArrayList<Int>): Int {
|
||||
|
||||
fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateArg(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
if (expr.length > 0) {
|
||||
|
||||
}
|
||||
return lhs
|
||||
@@ -30,7 +30,7 @@ fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
|
||||
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateAdd(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
if (expr.length > 0) {
|
||||
val <!UNUSED_VARIABLE!>c<!> = expr.get(0)
|
||||
expr.deleteCharAt(0)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package jet121
|
||||
fun box() : String {
|
||||
val answer = apply("OK") {
|
||||
get(0)
|
||||
length()
|
||||
length
|
||||
}
|
||||
|
||||
return if (answer == 2) "OK" else "FAIL"
|
||||
|
||||
@@ -11,7 +11,7 @@ package demo
|
||||
}
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
for (a in filter(args, {it.length() > 1})) {
|
||||
for (a in filter(args, {it.length > 1})) {
|
||||
System.out.println("Hello, ${a}!")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ fun main() {
|
||||
val diffs = ArrayList<Int>()
|
||||
for (i in vals.indices) {
|
||||
for (j in i..vals.lastIndex()) // Type inference failed
|
||||
diffs.add(vals[i].length() - vals[j].length())
|
||||
diffs.add(vals[i].length - vals[j].length)
|
||||
for (j in i..vals.lastIndex) // Type inference failed
|
||||
diffs.add(vals[i].length() - vals[j].length())
|
||||
diffs.add(vals[i].length - vals[j].length)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,5 +5,5 @@
|
||||
fun foo(i: Int) {}
|
||||
|
||||
fun test(s: String?) {
|
||||
foo(<!TYPE_MISMATCH!>s?.length()<!>)
|
||||
foo(<!TYPE_MISMATCH!>s?.length<!>)
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,16 +3,16 @@ package kt939
|
||||
//KT-939 CommonSupertypes erases scopes associated to types
|
||||
|
||||
fun compare(o1 : String?, o2 : String?) : Int {
|
||||
val l1 = o1?.length() ?: 0
|
||||
val l2 = o2?.length() ?: 0
|
||||
val l1 = o1?.length ?: 0
|
||||
val l2 = o2?.length ?: 0
|
||||
return l1 - l2 // '-' is unresolved, because the type of l1 is Int with an empty member scope
|
||||
}
|
||||
|
||||
//KT-1117 Unresolved reference to multiply sign
|
||||
|
||||
fun test() {
|
||||
(System.getProperty("path.separator")?.length() ?: 4) * 55 + 5
|
||||
(System.getProperty("path.separator")?.length ?: 4) * 55 + 5
|
||||
|
||||
val x = System.getProperty("path.separator")?.length() ?: 4
|
||||
val x = System.getProperty("path.separator")?.length ?: 4
|
||||
x * 55 + 5
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A {
|
||||
constructor(x: Any, y: Any, z: Any)
|
||||
constructor(x: String?, y: String?): this(x!!, <!DEBUG_INFO_SMARTCAST!>x<!>.length().toString() + y!!, "") {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length() + <!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
constructor(x: String?, y: String?): this(x!!, <!DEBUG_INFO_SMARTCAST!>x<!>.length.toString() + y!!, "") {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length + <!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ enum class D(val prop: Int) {
|
||||
};
|
||||
|
||||
constructor(): this(1)
|
||||
constructor(x: String): this(x.length())
|
||||
constructor(x: String): this(x.length)
|
||||
|
||||
abstract fun f(): Int
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
fun <T> array(vararg x: T): Array<T> = null!!
|
||||
|
||||
open class B(x: Int) {
|
||||
constructor(vararg y: String): this(y[0].length())
|
||||
constructor(vararg y: String): this(y[0].length)
|
||||
}
|
||||
|
||||
class A : B {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package foo
|
||||
fun dispatch(request: Request) {
|
||||
val <!UNUSED_VARIABLE!>url<!> = request.getRequestURI() as String
|
||||
|
||||
if (request.getMethod()?.length() != 0) {
|
||||
if (request.getMethod()?.length != 0) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
fun foo(p1: String?, p2: String?) {
|
||||
if (p2 != null) {
|
||||
val v = p1 ?: <!DEBUG_INFO_SMARTCAST!>p2<!>
|
||||
val size = v.length()
|
||||
val size = v.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(p: String?): Int {
|
||||
// We should get smart cast here
|
||||
val x = if (p != null) { <!DEBUG_INFO_SMARTCAST!>p<!> } else "a"
|
||||
return x.length()
|
||||
return x.length
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//KT-5455 Need warning about redundant type cast
|
||||
fun foo(o: Any): Int {
|
||||
if (o is String) {
|
||||
return (o <!USELESS_CAST!>as String<!>).length()
|
||||
return (o <!USELESS_CAST!>as String<!>).length
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public fun test(o: String?): Boolean {
|
||||
return when {
|
||||
// Data flow info should propagate from o == null to o.length()
|
||||
o == null, <!DEBUG_INFO_SMARTCAST!>o<!>.length() == 0 -> false
|
||||
// Data flow info should propagate from o == null to o.length
|
||||
o == null, <!DEBUG_INFO_SMARTCAST!>o<!>.length == 0 -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,10 +2,10 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
val z = x ?: if (y == null) break else <!DEBUG_INFO_SMARTCAST!>y<!>
|
||||
// z is not null in both branches
|
||||
z.length()
|
||||
z.length
|
||||
// y is nullable if x != null
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// y is null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -7,11 +7,11 @@ public fun foo(x: String?): Int {
|
||||
null -> break@loop
|
||||
"abc" -> return 0
|
||||
"xyz" -> return 1
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
// y is always Int after when
|
||||
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
}
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ public fun foo(x: String?, z: String?, w: String?): Int {
|
||||
gav(w!!, if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>, z!!)
|
||||
} while (bar())
|
||||
// w is not null because of w!!
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length
|
||||
// z is nullable despite of z!!
|
||||
z<!UNSAFE_CALL!>.<!>length()
|
||||
z<!UNSAFE_CALL!>.<!>length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ public fun foo(x: String?, z: String?): Int {
|
||||
gav(if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>, z!!)
|
||||
} while (bar())
|
||||
// z is nullable despite of z!!
|
||||
z<!UNSAFE_CALL!>.<!>length()
|
||||
z<!UNSAFE_CALL!>.<!>length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ public fun foo(x: String?): Int {
|
||||
} while (bar())
|
||||
y.hashCode()
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ public fun foo(x: String?, z: String?): Int {
|
||||
gav(z!!, if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
} while (bar())
|
||||
// z is not null because of z!!
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ public fun foo(x: String?, z: String?, w: String?): Int {
|
||||
gav(z!!, w!!, if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
} while (bar())
|
||||
// w is not null because of w!!
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length
|
||||
// z is not null because of z!!
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// See KT-6283
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
// Do-while loop is executed at least once, so
|
||||
// p should be not null here
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// See KT-6283
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (p == "abc") break
|
||||
} while (!x())
|
||||
// p should be smart casted despite of break
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// See KT-6283
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (p == "abc") continue
|
||||
} while (!x())
|
||||
// p should be smart casted despite of continue
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -6,8 +6,8 @@ public fun foo(p: String?): Int {
|
||||
do {
|
||||
if (y()) break
|
||||
// We do not always reach this statement
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
// Here we have do while loop but p is still nullable due to break before
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ public fun foo(p: String?): Int {
|
||||
do {
|
||||
if (y()) continue
|
||||
// We do not always reach this statement
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
// Here we have do while loop but p is still nullable due to continue before
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(s: String?): Int {
|
||||
do {
|
||||
} while (s!!.length() > 0)
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
} while (s!!.length > 0)
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ fun bar(): Boolean { return true }
|
||||
fun foo(s: String?): Int {
|
||||
do {
|
||||
if (bar()) break
|
||||
} while (s!!.length() > 0)
|
||||
} while (s!!.length > 0)
|
||||
// This call is unsafe due to break
|
||||
return s<!UNSAFE_CALL!>.<!>length()
|
||||
return s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -3,8 +3,8 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// Exotic variant with unused literal
|
||||
do <!UNUSED_FUNCTION_LITERAL!>{ ->
|
||||
p!!.length()
|
||||
p!!.length
|
||||
}<!> while (!x())
|
||||
// Literal is not called so p.length() is unsafe
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
// Literal is not called so p.length is unsafe
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+1
-1
@@ -6,5 +6,5 @@ public fun foo(p: String?): Int {
|
||||
if (p != null) break
|
||||
} while (!x())
|
||||
// p can be null despite of the break
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(s: String?): Int {
|
||||
do {
|
||||
} while (s==null)
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
+1
-1
@@ -5,5 +5,5 @@ fun foo(s: String?): Int {
|
||||
if (bar()) break
|
||||
} while (s==null)
|
||||
// This call is unsafe due to break
|
||||
return s<!UNSAFE_CALL!>.<!>length()
|
||||
return s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -3,8 +3,8 @@ public fun foo(x: String?): Int {
|
||||
// After the check, smart cast should work
|
||||
x ?: break
|
||||
// x is not null in both branches
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
} while (true)
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
x ?: if (y == null) break
|
||||
// y is nullable if x != null
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// y is null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
public fun foo(x: String?): Int {
|
||||
do {
|
||||
// After the check, smart cast should work
|
||||
x ?: x!!.length()
|
||||
x ?: x!!.length
|
||||
// x is not null in both branches
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>.length() == 0) break
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>.length == 0) break
|
||||
} while (true)
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
(if (x != null) break else y) ?: y!!
|
||||
// y is not null in both branches but it's hard to determine
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// y can be null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+3
-3
@@ -5,8 +5,8 @@ public fun foo(p: String?, y: String?): Int {
|
||||
"null".toString()
|
||||
break
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
p!!.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
p!!.length
|
||||
} while (true)
|
||||
return y?.length() ?: -1
|
||||
return y?.length ?: -1
|
||||
}
|
||||
+1
-1
@@ -10,5 +10,5 @@ public fun foo(x: String?): Int {
|
||||
} while (bar())
|
||||
y.hashCode()
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ public fun foo(x: String?): Int {
|
||||
// In future we can infer this initialization
|
||||
<!UNINITIALIZED_VARIABLE!>y<!>.hashCode()
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ public fun foo(x: String?): Int {
|
||||
// After the check, smart cast should work
|
||||
val y = if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>
|
||||
// y is not null in both branches
|
||||
y.length()
|
||||
y.length
|
||||
}
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,13 +3,13 @@ public fun foo(x: String?, y: String?): Int {
|
||||
// After the check, smart cast should work
|
||||
if (x != null) {
|
||||
if (x == "abc") break
|
||||
y!!.length()
|
||||
y!!.length
|
||||
} else {
|
||||
y!!.length()
|
||||
y!!.length
|
||||
}
|
||||
// y!! in both branches
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
} while (true)
|
||||
// break is possible before so !! is necessary
|
||||
return y!!.length()
|
||||
return y!!.length
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user