New J2K: Split old j2k and new j2k tests
This commit is contained in:
committed by
Ilya Kirillov
parent
02a206bf7c
commit
b411e8e18e
@@ -1,10 +0,0 @@
|
||||
// ERROR: Unresolved reference: x
|
||||
internal class C {
|
||||
private val s: String? = x()
|
||||
|
||||
fun foo() {
|
||||
if (s == null) {
|
||||
print("null")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import javaApi.Derived
|
||||
|
||||
internal class C : Derived() {
|
||||
override fun foo(s: String?): String? {
|
||||
|
||||
return s
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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
@@ -1,15 +0,0 @@
|
||||
// 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 ""
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// 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?) {}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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 ""
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
//method
|
||||
// !specifyLocalVariableTypeByDefault: true
|
||||
String bar() {
|
||||
return null;
|
||||
}
|
||||
void foo() {
|
||||
String s = bar();
|
||||
if (s != null) {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
// !specifyLocalVariableTypeByDefault: true
|
||||
fun bar(): String? {
|
||||
return null
|
||||
}
|
||||
fun foo() {
|
||||
val s: String? = bar()
|
||||
if (s != null) {
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// 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?) {}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package test
|
||||
|
||||
class Test {
|
||||
private var myProp: String? = null
|
||||
private var myIntProp: Int? = null
|
||||
fun onCreate() {
|
||||
myProp = ""
|
||||
myIntProp = 1
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
foo1(myProp!!)
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
foo2(myProp)
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
foo3(myProp)
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
myProp!![myIntProp!!]
|
||||
println(myProp)
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
val b = "aaa" == myProp
|
||||
val s = "aaa$myProp"
|
||||
}
|
||||
|
||||
fun test6() {
|
||||
myProp!!.compareTo(myProp!!, ignoreCase = true)
|
||||
}
|
||||
|
||||
fun test7() {
|
||||
val list: MutableList<Int> = ArrayList()
|
||||
list.remove(myIntProp!!)
|
||||
}
|
||||
|
||||
fun foo1(s: String) {}
|
||||
fun foo2(s: String?) {}
|
||||
fun foo3(s: String?) {}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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]
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
class TestJava {
|
||||
private var notNullInitializerFieldNullableUsage: String? = "aaa"
|
||||
private var notNullInitializerFieldNotNullUsage = "aaa"
|
||||
private var nullInitializerFieldNullableUsage: String? = null
|
||||
private var nullInitializerFieldNotNullUsage: String? = null
|
||||
fun testNotNull(obj: Any?) {
|
||||
if (true) {
|
||||
notNullInitializerFieldNullableUsage = obj as String?
|
||||
notNullInitializerFieldNotNullUsage = "str"
|
||||
notNullInitializerFieldNullableUsage!![1]
|
||||
notNullInitializerFieldNotNullUsage[1]
|
||||
} else {
|
||||
nullInitializerFieldNullableUsage = obj as String?
|
||||
nullInitializerFieldNotNullUsage = "str"
|
||||
nullInitializerFieldNullableUsage!![1]
|
||||
nullInitializerFieldNotNullUsage!![1]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user