From 74a08c97473fa421bad629788949a8d36dab42f6 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 17 Dec 2014 16:31:06 +0300 Subject: [PATCH] Added tests for simple approximation (of Captured(out/in Int)) --- .../capturedTypes/overApproximationForInCaptured.kt | 8 ++++++++ .../capturedTypes/overApproximationForInCaptured.txt | 4 ++++ .../capturedTypes/overApproximationForOutCaptured.kt | 8 ++++++++ .../overApproximationForOutCaptured.txt | 4 ++++ .../jet/checkers/JetDiagnosticsTestGenerated.java | 12 ++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.txt create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.txt diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt new file mode 100644 index 00000000000..139f01f98b6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +fun foo(a: Array): T = null!! + +fun test(a: Array) { + foo(a) checkType { it : _ } +} diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.txt new file mode 100644 index 00000000000..da1d38689ea --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.txt @@ -0,0 +1,4 @@ +package + +internal fun foo(/*0*/ a: kotlin.Array): T +internal fun test(/*0*/ a: kotlin.Array): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt new file mode 100644 index 00000000000..4efbf29e4a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +fun foo(a: Array): T = null!! + +fun test(a: Array) { + foo(a) checkType { it : _ } +} diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.txt new file mode 100644 index 00000000000..1c44eb0b19f --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.txt @@ -0,0 +1,4 @@ +package + +internal fun foo(/*0*/ a: kotlin.Array): T +internal fun test(/*0*/ a: kotlin.Array): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 6f97d0d3757..aa9245e9439 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -5195,6 +5195,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/kt2872.kt"); doTest(fileName); } + + @TestMetadata("overApproximationForInCaptured.kt") + public void testOverApproximationForInCaptured() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt"); + doTest(fileName); + } + + @TestMetadata("overApproximationForOutCaptured.kt") + public void testOverApproximationForOutCaptured() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/inference/constraints")