Add a test for getOrDefault() bridge

This commit is contained in:
Georgy Bronnikov
2020-02-28 19:08:03 +03:00
parent dd7d5dfdb3
commit 8b559b20e2
4 changed files with 41 additions and 2 deletions
@@ -0,0 +1,30 @@
// 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>()
// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/Object;\)Ljava/lang/Object;
@@ -9,7 +9,6 @@ import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.TestJdkKind
import org.junit.Assert
import java.io.File
import java.util.*
@@ -22,7 +21,7 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
createEnvironmentWithMockJdkAndIdeaAnnotations(
ConfigurationKind.ALL,
files,
TestJdkKind.MOCK_JDK,
getJdkKind(files),
*listOfNotNull(writeJavaFiles(files)).toTypedArray()
)
loadMultiFiles(files)
@@ -259,6 +259,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/kt9603.kt");
}
@TestMetadata("mapGetOrDefault.kt")
public void testMapGetOrDefault() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt");
}
@TestMetadata("maxStackAfterOptimizations.kt")
public void testMaxStackAfterOptimizations() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/maxStackAfterOptimizations.kt");
@@ -259,6 +259,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/kt9603.kt");
}
@TestMetadata("mapGetOrDefault.kt")
public void testMapGetOrDefault() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt");
}
@TestMetadata("maxStackAfterOptimizations.kt")
public void testMaxStackAfterOptimizations() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/maxStackAfterOptimizations.kt");