Files
kotlin-fork/compiler/testData/codegen/box/fir/CustomHashSetSize.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

66 lines
1.4 KiB
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// MODULE: m1
// FILE: m1/THash.java
package m1;
public class THash {
public int size() { return 1; }
}
// FILE: m1/TObjectHash.java
package m1;
public class TObjectHash<T> extends THash {}
// FILE: m1/THashSet.java
package m1;
import java.util.*;
public class THashSet<T> extends TObjectHash<T> implements Set<T> {
public Iterator<T> iterator() { return null; }
public boolean isEmpty() { return false; }
public boolean contains(Object o) { return false; }
public Object[] toArray() { return new Object[1]; }
public <T> T[] toArray(T[] a) { throw new RuntimeException(); }
public boolean add(T e) { return false; }
public boolean remove(Object o) { return false; }
public boolean containsAll(Collection<?> c) { return false; }
public boolean addAll(Collection<? extends T> c) { return false; }
public boolean retainAll(Collection<?> c) { return false; }
public boolean removeAll(Collection<?> c) { return false; }
public void clear() {}
}
// MODULE: m2(m1)
// FILE: box.kt
package m2
import m1.THashSet
interface HeaderSet : Set<String>
class MutableHeaderSet : HeaderSet, MutableSet<String>, THashSet<String>()
fun box(): String {
val size1 = THashSet<String>().size
val size2 = MutableHeaderSet().size
return if (size1 == 1 && size2 == 1) "OK" else "$size1/$size2"
}