1bb40afada
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
65 lines
2.0 KiB
Kotlin
Vendored
65 lines
2.0 KiB
Kotlin
Vendored
// !CHECK_TYPE
|
|
// !LANGUAGE: -AdditionalBuiltInsMembers
|
|
// SKIP_TXT
|
|
|
|
class A : java.util.ArrayList<String>() {
|
|
// `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>() {
|
|
// `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> {
|
|
<!NOTHING_TO_OVERRIDE!>override<!> fun stream(): java.util.stream.Stream<String> = null!!
|
|
}
|
|
|
|
class B : <!NONE_APPLICABLE!>Throwable<!>("", null, false, false)
|
|
|
|
class B1 : RuntimeException() {
|
|
<!NOTHING_TO_OVERRIDE!>override<!> fun fillInStackTrace(): Throwable { // 'override' keyword must be prohibited, as it was in 1.0.x
|
|
return this
|
|
}
|
|
}
|
|
|
|
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>() }
|
|
|
|
HashMap<String, Int>().getOrDefault(Any(), null)
|
|
|
|
// Falls back to extension in stdlib
|
|
y.printStackTrace()
|
|
|
|
z.<!UNRESOLVED_REFERENCE!>stream<!>()
|
|
}
|
|
|
|
interface X {
|
|
fun foo(): Int = 1
|
|
val hidden: Boolean
|
|
}
|
|
|
|
class Y : X {
|
|
// There should not be UNSUPPORTED_FEATURE diagnostic
|
|
override fun foo() = 1
|
|
override var hidden: Boolean = true
|
|
}
|