K2: Refine how JDK members are mapped to built-in classes
Previously, the semantic was more-or-less correct for most of the cases but some corner one, like `sort` in MutableList didn't work properly. Namely, `sort` should be marked there in a way to forbid to call it everywhere beside super-calls. Also, overriding it should be allowed. Mostly, the logic was re-written to K2 model from K1-related JvmBuiltInsCustomizer. ^KT-57694 In progress ^KT-57269 Fixed
This commit is contained in:
committed by
Space Team
parent
161fe1d2ca
commit
2e5b783cc6
-6
@@ -1,6 +0,0 @@
|
||||
enum class E {
|
||||
ENTRY;
|
||||
|
||||
fun getDeclaringClass() {}
|
||||
fun finalize() {}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
enum class E {
|
||||
ENTRY;
|
||||
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
enum class TestEnum {
|
||||
ENTRY;
|
||||
|
||||
fun getDeclaringClass() {}
|
||||
fun finalize() {}
|
||||
}
|
||||
|
||||
class TestFinalize {
|
||||
fun finalize() {}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
enum class TestEnum {
|
||||
ENTRY;
|
||||
|
||||
|
||||
+3
-3
@@ -3,11 +3,11 @@
|
||||
|
||||
interface A : MutableCollection<String> {
|
||||
// Override of deprecated function could be marked as deprecated too
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun nonExistingMethod(x: String) = ""
|
||||
override fun nonExistingMethod(x: String) = ""
|
||||
}
|
||||
|
||||
fun foo(x: MutableCollection<Int>, y: Collection<String>, z: A) {
|
||||
x.<!UNRESOLVED_REFERENCE!>nonExistingMethod<!>(1).checkType { _<String>() }
|
||||
x.<!UNRESOLVED_REFERENCE!>nonExistingMethod<!>(1).<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<String>() }
|
||||
y.<!UNRESOLVED_REFERENCE!>nonExistingMethod<!>("")
|
||||
z.nonExistingMethod("")
|
||||
z.<!UNRESOLVED_REFERENCE!>nonExistingMethod<!>("")
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
enum class E {
|
||||
ENTRY;
|
||||
|
||||
fun getDeclaringClass() {}
|
||||
fun finalize() {}
|
||||
fun <!VIRTUAL_MEMBER_HIDDEN!>getDeclaringClass<!>() {}
|
||||
<!ACCIDENTAL_OVERRIDE!>fun <!VIRTUAL_MEMBER_HIDDEN!>finalize<!>()<!> {}
|
||||
}
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// FULL_JDK
|
||||
|
||||
abstract class A : MutableList<String> {
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun sort(/*0*/ p0: java.util.Comparator<in String>) {
|
||||
super.<!UNRESOLVED_REFERENCE!>sort<!>(p0)
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(x: MutableList<String>, y: java.util.ArrayList<String>, z: A, p: java.util.Comparator<in String>) {
|
||||
x.<!DEPRECATION_ERROR!>sort<!>(p)
|
||||
y.sort(p)
|
||||
|
||||
z.sort(p)
|
||||
}
|
||||
|
||||
fun bar(x: MutableList<String>, y: java.util.ArrayList<String>, z: A) {
|
||||
x.<!DEPRECATION_ERROR!>sort<!> { a, b -> a.length - b.length }
|
||||
y.sort { a, b -> a.length - b.length }
|
||||
|
||||
z.<!DEPRECATION_ERROR!>sort<!> { a, b -> a.length - b.length }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FULL_JDK
|
||||
|
||||
abstract class A : MutableList<String> {
|
||||
|
||||
Reference in New Issue
Block a user