diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index 0fbcb9cb949..2a96cc21f21 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -193,7 +193,7 @@ public class ExpressionTypingServices { ? context.replaceExpectedType(NO_EXPECTED_TYPE) : context; - expressionTypingFacade.getTypeInfo(bodyExpression, newContext, !blockBody); + expressionTypingFacade.getTypeInfo(bodyExpression, newContext, blockBody); } @NotNull @@ -247,7 +247,7 @@ public class ExpressionTypingServices { ExpressionTypingContext context = ExpressionTypingContext.newContext( this, trace, functionInnerScope, dataFlowInfo, NO_EXPECTED_TYPE, ExpressionPosition.FREE ); - JetTypeInfo typeInfo = expressionTypingFacade.getTypeInfo(bodyExpression, context, !function.hasBlockBody()); + JetTypeInfo typeInfo = expressionTypingFacade.getTypeInfo(bodyExpression, context, function.hasBlockBody()); trace.record(STATEMENT, bodyExpression, false); JetType type = typeInfo.getType(); diff --git a/compiler/testData/codegen/box/properties/generalAccess.kt b/compiler/testData/codegen/box/properties/generalAccess.kt index ccb206e0a84..696610ff9e4 100644 --- a/compiler/testData/codegen/box/properties/generalAccess.kt +++ b/compiler/testData/codegen/box/properties/generalAccess.kt @@ -25,7 +25,7 @@ open class A(val init: String) { public var backingField : Int = 0 get() = $backingField.myInc - set(s) = $backingField = s + set(s) { $backingField = s } } diff --git a/compiler/testData/diagnostics/tests/controlStructures/ForbidStatementAsDirectFunctionBody.kt b/compiler/testData/diagnostics/tests/controlStructures/ForbidStatementAsDirectFunctionBody.kt new file mode 100644 index 00000000000..aa884b4de23 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlStructures/ForbidStatementAsDirectFunctionBody.kt @@ -0,0 +1,11 @@ + +fun foo1() = while (b()) {} + +fun foo2() = for (i in 10) {} + +fun foo3() = when (b()) { + true -> 1 + else -> 0 +} + +fun b(): Boolean = true \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt index b7bd29d8726..41b4c4d50f9 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.kt @@ -42,8 +42,8 @@ fun box() : Int { //More tests -fun test1() = while(true) {} -fun test2(): Unit = while(true) {} +fun test1() { while(true) {} } +fun test2(): Unit { while(true) {} } fun testCoercionToUnit() { val simple: ()-> Unit = { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt index cfa7459e9b3..4a779371524 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt @@ -3,7 +3,7 @@ package a //+JDK -fun Array.forEach(operation: (T) -> Unit) : Unit = for (element in this) operation(element) +fun Array.forEach(operation: (T) -> Unit) : Unit { for (element in this) operation(element) } fun bar(operation: (String) -> Unit) = operation("") diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt1028.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt1028.kt index 87a1f14bfe1..924d83be3e4 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/kt1028.kt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt1028.kt @@ -9,7 +9,7 @@ class event() fun plusAssign(f : (T) -> Unit) = callbacks.add(f) fun minusAssign(f : (T) -> Unit) = callbacks.remove(f) - fun call(value : T) = for(c in callbacks) c(value) + fun call(value : T) { for(c in callbacks) c(value) } } class MouseMovedEventArgs() diff --git a/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt b/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt index dfa950e6192..b1b8f43e5c6 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt @@ -4,7 +4,7 @@ import java.util.* -fun Iterator.foreach(operation: (element: T) -> Unit) : Unit = while(hasNext()) operation(next()) +fun Iterator.foreach(operation: (element: T) -> Unit) : Unit { while(hasNext()) operation(next()) } fun Iterator.foreach(operation: (index: Int, element: T) -> Unit) : Unit { var k = 0 diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index ae0c066ff82..f5955b11713 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -1557,6 +1557,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/controlStructures/ForWithoutBraces.kt"); } + @TestMetadata("ForbidStatementAsDirectFunctionBody.kt") + public void testForbidStatementAsDirectFunctionBody() throws Exception { + doTest("compiler/testData/diagnostics/tests/controlStructures/ForbidStatementAsDirectFunctionBody.kt"); + } + @TestMetadata("kt1075.kt") public void testKt1075() throws Exception { doTest("compiler/testData/diagnostics/tests/controlStructures/kt1075.kt"); diff --git a/libraries/stdlib/src/kotlin/StringsJVM.kt b/libraries/stdlib/src/kotlin/StringsJVM.kt index 0a314bc5b83..d3e159ff534 100644 --- a/libraries/stdlib/src/kotlin/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/StringsJVM.kt @@ -253,7 +253,7 @@ public inline fun String.reverse(): String = StringBuilder(this).reverse().toStr * * @includeFunctionBody ../../test/StringTest.kt forEach */ -public inline fun String.forEach(operation: (Char) -> Unit): Unit = for(c in this) operation(c) +public inline fun String.forEach(operation: (Char) -> Unit) { for(c in this) operation(c) } /** * Returns *true* if all characters match the given *predicate*