[FIR] Add PLATFORM_CLASS_MAPPED_TO_KOTLIN

This commit is contained in:
Ivan Kochurkin
2021-11-23 18:08:35 +03:00
committed by TeamCityServer
parent 51b73bb6ae
commit f046f2964b
49 changed files with 180 additions and 127 deletions
@@ -1,18 +0,0 @@
// JET-72 Type inference doesn't work when iterating over ArrayList
import java.util.ArrayList
abstract class Item(val room: Object) {
abstract val name : String
}
val items: ArrayList<Item> = ArrayList<Item>()
fun test(room : Object) {
for(item: Item? in items) {
if (item?.room === room) {
// item?.room is not null
System.out.println("You see " + <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>item<!UNNECESSARY_SAFE_CALL!>?.<!>name<!>)
}
}
}
@@ -1,3 +1,5 @@
// FIR_IDENTICAL
// WITH_EXTENDED_CHECKERS
// JET-72 Type inference doesn't work when iterating over ArrayList
import java.util.ArrayList
@@ -1,8 +1,9 @@
// !CHECK_TYPE
// WITH_EXTENDED_CHECKERS
import java.lang.Comparable as Comparable
import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<!> as Comparable
fun f(c: Comparable<*>) {
fun f(c: <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Comparable<*><!>) {
checkSubtype<kotlin.Comparable<*>>(<!ARGUMENT_TYPE_MISMATCH!>c<!>)
checkSubtype<java.lang.Comparable<*>>(c)
}
checkSubtype<<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<*><!>>(c)
}
@@ -1,4 +1,5 @@
// !CHECK_TYPE
// WITH_EXTENDED_CHECKERS
import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<!> as Comparable
@@ -1,8 +0,0 @@
// JAVAC_EXPECTED_FILE
// KT-498 Very strange error in the type checker
class IdUnavailableException() : Exception() {}
fun <T : Any> T.getJavaClass() : Class<T> {
return ((this as Object).getClass()) <!UNCHECKED_CAST!>as Class<T><!> // Some error here, because of Exception() used above. ?!!!
}
@@ -1,3 +1,5 @@
// FIR_IDENTICAL
// WITH_EXTENDED_CHECKERS
// JAVAC_EXPECTED_FILE
// KT-498 Very strange error in the type checker
@@ -1,16 +0,0 @@
// KT-716 Type inference failed
class TypeInfo<T>
fun <T> typeinfo() : TypeInfo<T> = null <!CAST_NEVER_SUCCEEDS!>as<!> TypeInfo<T>
fun <T> TypeInfo<T>.getJavaClass() : java.lang.Class<T> {
val t : java.lang.Object = this as java.lang.Object
return t.getClass() <!UNCHECKED_CAST!>as java.lang.Class<T><!> // inferred type is Object but Serializable was expected
}
fun <T> getJavaClass() = typeinfo<T>().getJavaClass()
fun main() {
System.out.println(getJavaClass<String>())
}
@@ -1,3 +1,5 @@
// FIR_IDENTICAL
// WITH_EXTENDED_CHECKERS
// KT-716 Type inference failed
class TypeInfo<T>
@@ -1,7 +0,0 @@
import java.util.ArrayList
fun foo(p: java.util.List<String>) {
p.iterator(); // forcing resolve of java.util.List.iterator()
ArrayList<String>().iterator(); // this provoked exception in SignaturesPropagationData
}
@@ -1,3 +1,5 @@
// FIR_IDENTICAL
// WITH_EXTENDED_CHECKERS
import java.util.ArrayList
fun foo(p: <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util.List<String><!>) {