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