Files
kotlin-fork/compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt
T
Denis.Zharkov a750d9466e FIR2IR: Rework resulted overridden-relation structure
The difference is how we deal with intermediate fake overrides
E.g., in case

interface A { /* $1 */ fun foo() }
interface B : A {
     /* $2 */ fake_override fun foo()
}
interface C : B {
   /* $3 */ override fun foo()
}

We've got FIR declarations only for $1 and $3, but we've got
a fake override for $2 in IR.

Previously, override $3 had $1 as its overridden IR symbol, just because
FIR declaration of $3 doesn't know anything about $2.

Now, when generating IR for $2, we save the necessary information
and using it for $3, so it has $2 as overridden.

So, it's consistent with the overridden structure of FE 1.0 and this
structure is necessary prerequisite for proper building of bridges
for special built-ins.
2021-02-20 10:59:22 +03:00

41 lines
1.5 KiB
Kotlin
Vendored

// JVM_TARGET: 1.8
// WITH_RUNTIME
// FULL_JDK
// FILE: TestMap.java
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
public class TestMap<K, V> implements Map<K, V> {
public void clear() {}
public boolean isEmpty() { return true; }
public int size() { return 0; }
public boolean containsKey(Object key) { return false; }
public boolean containsValue(Object value) { return false; }
public V get(Object key) { return null; }
public V put(K key, V value) { return null; }
public V remove(Object key) { return null; }
public void putAll(Map<? extends K, ? extends V> m) {}
public Set<K> keySet() { return Collections.EMPTY_SET; }
public Collection<V> values() {return Collections.EMPTY_SET; }
public Set<Map.Entry<K, V>> entrySet() { return Collections.EMPTY_SET; }
}
// FILE: main.kt
class MyMap: TestMap<String, String>()
// The Kotlin version of getOrDefault, which redirects to the default implementation in java.util.Map
// 1 public bridge getOrDefault\(Ljava/lang/String;Ljava/lang/String;\)Ljava/lang/String;
// Test expectations differ between JVM and JVM IR backends, because of KT-40277. This should be revisited once KT-40277 is resolved.
// JVM_TEMPLATES:
// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/Object;\)Ljava/lang/Object;
// JVM_IR_TEMPLATES:
// 1 public bridge getOrDefault\(Ljava/lang/String;Ljava/lang/String;\)Ljava/lang/String;
// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/String;\)Ljava/lang/String;