Files
kotlin-fork/compiler/testData/codegen/box/specialBuiltins/charBuffer.kt
T
Dmitriy Novozhilov 7813bb35cf [FIR2IR] Provide remapped f/o symbols to declaration storage
After a generation of fake overrides some code may still to refer old
  symbols from declaration storage (like computation of overridden
  symbols for lazy functions), so we need to remap those symbols using
  information from IR f/o generator
2023-12-15 15:38:10 +00:00

42 lines
1018 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// 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
abstract class KCB : CharBuffer()
fun box(): String {
val cb: CharBuffer = CharBuffer.impl()
return cb.get(0).toString() + (cb as CharSequence).get(1).toString()
}