Files
kotlin-fork/compiler/testData/codegen/box/specialBuiltins/charBuffer.kt
T
Dmitriy Novozhilov 3f2e996803 [FIR2IR] Load builtin classes instead of creating them on the fly
This change uncovered KT-61282, which was hidden because of incorrect
  module fragments used as parent for builtin classes
2023-08-22 18:36:20 +00:00

43 lines
1.0 KiB
Kotlin
Vendored

// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR
// Ignore reason: KT-61282
// MODULE: lib
// FILE: CharBuffer.java
public abstract class CharBuffer implements CharSequence {
public final int length() {
return 0;
}
public final char charAt(int index) {
return 'K';
}
// The key problem here is that `get` has the same signature as kotlin.CharSequence.get but completely different semantics
public abstract char get(int index);
public abstract CharBuffer subSequence(int start, int end);
public static CharBuffer impl() {
return new CharBuffer() {
@Override
public char get(int index) {
return 'O';
}
@Override
public CharBuffer subSequence(int start, int end) {
return null;
}
};
}
}
// MODULE: main(lib)
// FILE: 1.kt
fun box(): String {
val cb: CharBuffer = CharBuffer.impl()
return cb.get(0).toString() + (cb as CharSequence).get(1).toString()
}