Add Map.getOrDefault method as PlatformDependent declaration with refined signature

- First parameter should have type of K instead of Any
- Special bridge should return second parameter if a key has wrong type
- Special bridge may throw an exception if defaultValue has wrong type

 #KT-13209 Fixed
This commit is contained in:
Denis Zharkov
2016-07-27 12:14:08 +03:00
parent 169acf2f31
commit 915e36cb02
15 changed files with 353 additions and 26 deletions
@@ -139,6 +139,12 @@ public class DiagnosticsWithJava8TestGenerated extends AbstractDiagnosticsWithFu
doTest(fileName);
}
@TestMetadata("getOrDefault.kt")
public void testGetOrDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/getOrDefault.kt");
doTest(fileName);
}
@TestMetadata("mutableMapRemove.kt")
public void testMutableMapRemove() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/mutableMapRemove.kt");
@@ -179,6 +179,33 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
}
}
@TestMetadata("compiler/testData/codegen/java8/box/mapGetOrDefault")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MapGetOrDefault extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInMapGetOrDefault() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/mapGetOrDefault"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("noTypeSafeBridge.kt")
public void testNoTypeSafeBridge() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/mapGetOrDefault/noTypeSafeBridge.kt");
doTest(fileName);
}
@TestMetadata("typeSafeBridge.kt")
public void testTypeSafeBridge() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/mapGetOrDefault/typeSafeBridge.kt");
doTest(fileName);
}
@TestMetadata("typeSafeBridgeNotNullAny.kt")
public void testTypeSafeBridgeNotNullAny() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/mapGetOrDefault/typeSafeBridgeNotNullAny.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/java8/box/mapRemove")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)