Fix for IDEA complains when assigning Kotlin objects where java.lang.Object is expected
#KT-4355 Fixed
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// KT-4355 IDEA complains when assigning Kotlin objects where java.lang.Object is expected
|
||||
class AssignKotlinClassToObjectInJava {
|
||||
void test(KotlinTrait trait) {
|
||||
Object kotlinClass = new KotlinClass();
|
||||
Object kotlinTrait = trait;
|
||||
|
||||
KotlinClass foo = null;
|
||||
foo.equals(foo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
class KotlinClass
|
||||
trait KotlinTrait
|
||||
@@ -0,0 +1,23 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import test.TestPackage;
|
||||
|
||||
class AssignMappedKotlinType {
|
||||
void test() {
|
||||
int i1 = TestPackage.getInt();
|
||||
Integer i2 = TestPackage.getInt();
|
||||
Number number = TestPackage.getNumber();
|
||||
String str = TestPackage.getString();
|
||||
|
||||
Collection<Integer> intCollection = TestPackage.getList();
|
||||
List<Integer> intList = TestPackage.getList();
|
||||
|
||||
Collection<Integer> intMutableCollection = TestPackage.getMutableList();
|
||||
List<Integer> intMutableList = TestPackage.getMutableList();
|
||||
|
||||
Collection<String> stringsCollection = TestPackage.getArrayList();
|
||||
ArrayList<String> arrayListCollection = TestPackage.getArrayList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun getInt(): Int = 12
|
||||
fun getString(): String = "Test"
|
||||
fun getNumber(): Number? = null
|
||||
|
||||
fun getList(): List<Int> = listOf(1, 2, 3)
|
||||
fun getMutableList(): MutableList<Int> = ArrayList<Int>()
|
||||
fun getArrayList(): ArrayList<String> = ArrayList<String>()
|
||||
@@ -0,0 +1,6 @@
|
||||
class UseKotlinSubclassesOfMappedTypes {
|
||||
void test() {
|
||||
Iterable<String> iterable = new KotlinIterableTraitTest();
|
||||
Comparable<Integer> comparable = new KotlinComparableTest();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class KotlinComparableTest : Comparable<Int> {
|
||||
override fun compareTo(other: Int): Int {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinIterableTraitTest : Iterable<String> {
|
||||
override fun iterator(): Iterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user