From f8926c8a937c310af6d82574aa28f46fea85b455 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Sat, 9 Jun 2012 15:48:34 +0400 Subject: [PATCH] Absence of type is not enough for concluding function has type inference --- .../jetbrains/jet/lang/psi/JetModifiableBlockHelper.java | 2 +- idea/testData/codeInsight/outOfBlock/InFunInFunWithBody.kt | 6 ++++++ .../jet/plugin/codeInsight/OutOfBlockModificationTest.java | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 idea/testData/codeInsight/outOfBlock/InFunInFunWithBody.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java index a5e3ddf140c..8133034391d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java @@ -65,7 +65,7 @@ public final class JetModifiableBlockHelper { if (declaration != null) { if (declaration instanceof JetNamedFunction) { JetNamedFunction function = (JetNamedFunction) declaration; - if (!function.hasDeclaredReturnType()) { + if (!function.hasDeclaredReturnType() && !function.hasBlockBody()) { return true; } } diff --git a/idea/testData/codeInsight/outOfBlock/InFunInFunWithBody.kt b/idea/testData/codeInsight/outOfBlock/InFunInFunWithBody.kt new file mode 100644 index 00000000000..d936f0e3748 --- /dev/null +++ b/idea/testData/codeInsight/outOfBlock/InFunInFunWithBody.kt @@ -0,0 +1,6 @@ +// FALSE +fun test() { + fun hello() { + + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTest.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTest.java index 91fdb68703a..dbe4cb306c5 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTest.java @@ -46,6 +46,10 @@ public class OutOfBlockModificationTest extends LightCodeInsightFixtureTestCase doTest(); } + public void testInFunInFunWithBody() { + doTest(); + } + public void testInFunWithInference() { doTest(); }