Simplify compatibility mode with ll=1.0 on JDK dependent built-ins
A lot of problem arise with current solution (loading them with lowpriority annotation + additional call checkers): - We errorneously treated ArrayList.stream as an existing method, while it's just a fake override from List - The same problem arises when creating a class delegating to List. Also the latter case is failing with codegen internal error (see issue KT-16171) The negative side of this solution is that instead of reporting meaningful diagnostic, there will be UNRESOLVED_REFERENCE. But it seems to be better than having strange problems like ones described above. #KT-16073 Fixed #KT-16171 Fixed
This commit is contained in:
+30
-8
@@ -3,24 +3,44 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class A : java.util.ArrayList<String>() {
|
||||
override fun stream(): java.util.stream.Stream<String> = super.stream()
|
||||
// `stream` is defined in ArrayList, so it was impossible to override it in 1.0
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun stream(): java.util.stream.Stream<String> = super.<!UNRESOLVED_REFERENCE!>stream<!>()
|
||||
|
||||
// `sort` is defined in ArrayList, so it was possible to override it in 1.0
|
||||
override fun sort(c: Comparator<in String>?) {
|
||||
super.sort(c)
|
||||
}
|
||||
}
|
||||
|
||||
class A1 : java.util.ArrayList<String>() {
|
||||
fun stream(): java.util.stream.Stream<String> = super.stream()
|
||||
// `stream` is defined in ArrayList, so it was possible to declare it in 1.0 without an 'override' keyword
|
||||
fun stream(): java.util.stream.Stream<String> = super.<!UNRESOLVED_REFERENCE!>stream<!>()
|
||||
|
||||
// `sort` is defined in ArrayList, so it was impossible to declare it in 1.0 without an 'override' keyword
|
||||
<!VIRTUAL_MEMBER_HIDDEN!>fun sort(c: Comparator<in String>?)<!> {
|
||||
super.sort(c)
|
||||
}
|
||||
}
|
||||
|
||||
interface A2 : List<String> {
|
||||
<!UNSUPPORTED_FEATURE!>override<!> fun stream(): java.util.stream.Stream<String> = null!!
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun stream(): java.util.stream.Stream<String> = null!!
|
||||
}
|
||||
|
||||
class B : <!UNSUPPORTED_FEATURE!>Throwable<!>("", null, false, false)
|
||||
class B : <!NONE_APPLICABLE!>Throwable<!>("", null, false, false)
|
||||
|
||||
fun Throwable.<!EXTENSION_SHADOWED_BY_MEMBER!>fillInStackTrace<!>() = 1
|
||||
class B1 : RuntimeException() {
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun fillInStackTrace(): Throwable { // 'override' keyword must be prohibited, as it was in 1.0.x
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(x: List<String>, y: Throwable) {
|
||||
x.<!UNSUPPORTED_FEATURE!>stream<!>()
|
||||
java.util.ArrayList<String>().stream()
|
||||
class A3(val x: List<String>) : List<String> by x
|
||||
|
||||
fun Throwable.fillInStackTrace() = 1
|
||||
|
||||
fun foo(x: List<String>, y: Throwable, z: A3) {
|
||||
x.<!UNRESOLVED_REFERENCE!>stream<!>()
|
||||
java.util.ArrayList<String>().<!UNRESOLVED_REFERENCE!>stream<!>()
|
||||
|
||||
y.fillInStackTrace() checkType { _<Int>() }
|
||||
|
||||
@@ -28,6 +48,8 @@ fun foo(x: List<String>, y: Throwable) {
|
||||
|
||||
// Falls back to extension in stdlib
|
||||
y.printStackTrace()
|
||||
|
||||
z.<!UNRESOLVED_REFERENCE!>stream<!>()
|
||||
}
|
||||
|
||||
interface X {
|
||||
|
||||
Reference in New Issue
Block a user