Don't fail on requesting members of Java collection classes
RuntimeTypeMapper assumed that JavaPropertyDescriptor was necessarily backed by JavaField, which has changed when we started to load Java method (or a pair of methods) overriding a Kotlin property as a property, not as a method. Another example of this situation is special built-in properties which are mapped to Java methods, e.g. java.util.Collection#size() <-> kotlin.Collection#size. This change adds support for the case of a property backed by a JavaMethod. Note that callable references or usage of any reflection API related to built-in members is not supported anyway and will currently fail with errors #KT-11258 Fixed
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
// FULL_JDK
|
||||
// See KT-11258 Incorrect resolution sequence for Java field
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun box(): String {
|
||||
listOf(
|
||||
ArrayList::class,
|
||||
LinkedList::class,
|
||||
AbstractList::class,
|
||||
HashSet::class,
|
||||
TreeSet::class,
|
||||
HashMap::class,
|
||||
TreeMap::class,
|
||||
AbstractMap::class,
|
||||
AbstractMap.SimpleEntry::class
|
||||
).map {
|
||||
it.members.map(Any::toString)
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
+15
@@ -4428,6 +4428,21 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/specialBuiltIns")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SpecialBuiltIns extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInSpecialBuiltIns() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/specialBuiltIns"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("getMembersOfStandardJavaClasses.kt")
|
||||
public void testGetMembersOfStandardJavaClasses() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/specialBuiltIns/getMembersOfStandardJavaClasses.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/regressions")
|
||||
|
||||
Reference in New Issue
Block a user