[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: -SafeCastCheckBoundSmartCasts
|
||||
|
||||
interface SomeClass {
|
||||
val data: Any?
|
||||
}
|
||||
|
||||
interface SomeSubClass : SomeClass {
|
||||
val foo: Any?
|
||||
}
|
||||
|
||||
fun g(a: SomeClass?) {
|
||||
if (a as? SomeSubClass != null) {
|
||||
// 'a' can be cast to SomeSubClass
|
||||
a.hashCode()
|
||||
a.foo
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(a as SomeSubClass).foo
|
||||
}
|
||||
val b = (a as? SomeSubClass)?.foo
|
||||
if (b != null) {
|
||||
// 'a' can be cast to SomeSubClass
|
||||
a.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(a as SomeSubClass).foo
|
||||
}
|
||||
val c = a as? SomeSubClass
|
||||
if (c != null) {
|
||||
// 'a' and 'c' can be cast to SomeSubClass
|
||||
a.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
c.hashCode()
|
||||
c.foo
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
|
||||
|
||||
interface SomeClass {
|
||||
val data: Any?
|
||||
}
|
||||
|
||||
interface SomeSubClass : SomeClass {
|
||||
val foo: Any?
|
||||
}
|
||||
|
||||
fun g(a: SomeClass?) {
|
||||
if (a as? SomeSubClass != null) {
|
||||
// 'a' can be cast to SomeSubClass
|
||||
a.hashCode()
|
||||
a.foo
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(a as SomeSubClass).foo
|
||||
}
|
||||
val b = (a as? SomeSubClass)?.foo
|
||||
if (b != null) {
|
||||
// 'a' can be cast to SomeSubClass
|
||||
a.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(a as SomeSubClass).foo
|
||||
}
|
||||
val c = a as? SomeSubClass
|
||||
if (c != null) {
|
||||
// 'a' and 'c' can be cast to SomeSubClass
|
||||
a.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
c.hashCode()
|
||||
c.foo
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
|
||||
// See KT-20752
|
||||
|
||||
class Unstable {
|
||||
val first: String? get() = null
|
||||
}
|
||||
|
||||
class StringList {
|
||||
fun remove(s: String) = s
|
||||
}
|
||||
|
||||
fun StringList.remove(s: String?) = s ?: ""
|
||||
|
||||
fun foo(list: StringList, arg: Unstable) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first as? String != null) {
|
||||
// Should be still resolved to extension, without smart cast or smart cast impossible
|
||||
list.remove(arg.first)
|
||||
}
|
||||
val s = arg.first as? String
|
||||
if (s != null) {
|
||||
// Should be still resolved to extension, without smart cast or smart cast impossible
|
||||
list.remove(arg.first)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
|
||||
// See KT-19007
|
||||
|
||||
// Stub
|
||||
fun String.indexOf(arg: String) = this.length - arg.length
|
||||
|
||||
// Stub
|
||||
fun String.toLowerCase() = this
|
||||
|
||||
fun foo(a: Any) {
|
||||
// Should compile in 1.2
|
||||
(a as? String)?.indexOf(a.toLowerCase())
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
class Item(val link: String?)
|
||||
|
||||
fun test(item: Item) {
|
||||
if (item.link != null) {
|
||||
val href: String = item.link
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
|
||||
interface SomeClass {
|
||||
val data: Any?
|
||||
}
|
||||
|
||||
interface SomeSubClass : SomeClass {
|
||||
val foo: Any?
|
||||
}
|
||||
|
||||
object Impl : SomeSubClass {
|
||||
override val data = ""
|
||||
override val foo = 42
|
||||
}
|
||||
|
||||
fun g(a: SomeClass?) {
|
||||
var b = (a as? SomeSubClass)?.foo
|
||||
b = "Hello"
|
||||
if (b != null) {
|
||||
// 'a' cannot be cast to SomeSubClass!
|
||||
a.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(a as SomeSubClass).foo
|
||||
}
|
||||
var c = a as? SomeSubClass
|
||||
c = Impl
|
||||
if (c != null) {
|
||||
// 'a' cannot be cast to SomeSubClass
|
||||
a.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(a as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
c.hashCode()
|
||||
c.foo
|
||||
}
|
||||
}
|
||||
|
||||
fun f(a: SomeClass?) {
|
||||
var aa = a
|
||||
|
||||
if (aa as? SomeSubClass != null) {
|
||||
aa = null
|
||||
// 'aa' cannot be cast to SomeSubClass
|
||||
aa.<!UNRESOLVED_REFERENCE!>hashCode<!>()
|
||||
aa.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(aa as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(aa as SomeSubClass).foo
|
||||
}
|
||||
val b = (aa as? SomeSubClass)?.foo
|
||||
aa = null
|
||||
if (b != null) {
|
||||
// 'aa' cannot be cast to SomeSubClass
|
||||
aa.<!UNRESOLVED_REFERENCE!>hashCode<!>()
|
||||
aa.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(aa as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
(aa as SomeSubClass).foo
|
||||
}
|
||||
aa = a
|
||||
val c = aa as? SomeSubClass
|
||||
if (c != null) {
|
||||
// 'c' can be cast to SomeSubClass
|
||||
aa.<!UNRESOLVED_REFERENCE!>hashCode<!>()
|
||||
aa.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
(aa as? SomeSubClass).<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
c.hashCode()
|
||||
c.foo
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user