New J2K: Fix existing test data
This commit is contained in:
committed by
Ilya Kirillov
parent
5236858c20
commit
f752796408
@@ -0,0 +1,10 @@
|
||||
// ERROR: Unresolved reference: x
|
||||
internal class C {
|
||||
private val s: String? = x()
|
||||
|
||||
fun foo() {
|
||||
if (s == null) {
|
||||
print("null")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import javaApi.Derived
|
||||
|
||||
internal class C : Derived() {
|
||||
override fun foo(s: String?): String? {
|
||||
|
||||
return s
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
internal class A {
|
||||
|
||||
/* rare nullable, handle with caution */
|
||||
fun nullableString(): String? {
|
||||
return if (Math.random() > 0.999) {
|
||||
"a string"
|
||||
} else null
|
||||
}
|
||||
|
||||
fun takesNotNullString(s: String) {
|
||||
println(s.substring(1))
|
||||
}
|
||||
|
||||
fun aVoid() {
|
||||
var aString: String?
|
||||
if (nullableString() != null) {
|
||||
aString = nullableString()
|
||||
if (aString != null) {
|
||||
for (i in 0..9) {
|
||||
takesNotNullString(aString!!) // Bang-bang here
|
||||
aString = nullableString()
|
||||
}
|
||||
} else {
|
||||
aString = "aaa"
|
||||
}
|
||||
} else {
|
||||
aString = "bbbb"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
internal interface I {
|
||||
val string: String?
|
||||
}
|
||||
|
||||
internal class C {
|
||||
fun foo(i: I, b: Boolean) {
|
||||
var result = i.string
|
||||
if (b) result = null
|
||||
if (result != null) {
|
||||
print(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// ERROR: Return type of 'get' is not a subtype of the return type of the overridden member 'public abstract fun get(): String defined in Getter'
|
||||
internal interface Getter {
|
||||
fun get(): String?
|
||||
}
|
||||
|
||||
internal class C {
|
||||
fun foo(b: Boolean): String {
|
||||
val getter: Getter = object : Getter {
|
||||
override fun get(): String? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// ERROR: There's a cycle in the inheritance hierarchy for this type
|
||||
// ERROR: There's a cycle in the inheritance hierarchy for this type
|
||||
internal open class A : B() {
|
||||
open fun foo(s: String?) {}
|
||||
}
|
||||
|
||||
internal open class B : A() {
|
||||
open fun foo(s: String?) {}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
internal open class Base {
|
||||
open fun foo(s: String?): String? {
|
||||
return ""
|
||||
}
|
||||
|
||||
open fun bar(s: String?): String? {
|
||||
return if (s != null) s + 1 else null
|
||||
}
|
||||
|
||||
open fun zoo(o: Any?): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
internal interface I {
|
||||
fun zoo(o: Any?): String?
|
||||
}
|
||||
|
||||
internal class C : Base(), I {
|
||||
override fun foo(s: String?): String? {
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun bar(s: String?): String? {
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun zoo(o: Any?): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// ERROR: Type mismatch: inferred type is Passenger.PassChild? but Passenger.PassChild was expected
|
||||
// ERROR: Type mismatch: inferred type is Passenger.PassChild? but Passenger.PassChild was expected
|
||||
class Passenger {
|
||||
open class PassParent
|
||||
|
||||
class PassChild : PassParent()
|
||||
|
||||
fun provideNullable(p: Int): PassParent? {
|
||||
return if (p > 0) PassChild() else null
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
val pass = provideNullable(1)!!
|
||||
accept1(pass as PassChild)
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
val pass = provideNullable(1)
|
||||
if (1 == 2) {
|
||||
assert(pass != null)
|
||||
accept2(pass as PassChild?)
|
||||
}
|
||||
accept2(pass as PassChild?)
|
||||
}
|
||||
|
||||
fun accept1(p: PassChild?) {}
|
||||
|
||||
fun accept2(p: PassChild?) {}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class TestJava {
|
||||
|
||||
var nullableInitializerFieldCast = nullableObj(3) as String?
|
||||
private val nullableInitializerPrivateFieldCast = nullableObj(3) as String?
|
||||
fun nullableObj(p: Int): Any? {
|
||||
return if (p > 0) "response" else null
|
||||
}
|
||||
|
||||
fun testProperty() {
|
||||
nullableInitializerFieldCast!![0]
|
||||
nullableInitializerPrivateFieldCast!![0]
|
||||
}
|
||||
|
||||
fun testLocalVariable() {
|
||||
val nullableInitializerValCast = nullableObj(3) as String?
|
||||
|
||||
nullableInitializerValCast!![0]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user