Revert "'async' reserved in front of function literals"

This reverts commit 6155d836a5.
This commit is contained in:
Denis Zharkov
2016-05-19 14:04:21 +03:00
parent 7d3333e86e
commit 1af9321c20
4 changed files with 0 additions and 44 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.types.expressions
import com.google.common.collect.Lists
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
import org.jetbrains.kotlin.builtins.isFunctionType
@@ -28,9 +27,7 @@ import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.checkReservedPrefixWord
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.BindingContext.EXPECTED_RETURN_TYPE
@@ -58,7 +55,6 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
isDeclaration: Boolean,
statementScope: LexicalWritableScope? // must be not null if isDeclaration
): KotlinTypeInfo {
checkReservedAsync(context, function)
if (!isDeclaration) {
// function expression
if (!function.getTypeParameters().isEmpty()) {
@@ -135,8 +131,6 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
}
override fun visitLambdaExpression(expression: KtLambdaExpression, context: ExpressionTypingContext): KotlinTypeInfo? {
checkReservedAsync(context, expression)
if (!expression.functionLiteral.hasBody()) return null
val expectedType = context.expectedType
@@ -159,10 +153,6 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
return components.dataFlowAnalyzer.createCheckedTypeInfo(resultType, context, expression)
}
private fun checkReservedAsync(context: ExpressionTypingContext, expression: PsiElement) {
checkReservedPrefixWord(context.trace, expression, "async", "async block/lambda. Use 'async() { ... }' or 'async(fun...)'")
}
private fun createFunctionLiteralDescriptor(
expression: KtLambdaExpression,
context: ExpressionTypingContext
-23
View File
@@ -1,23 +0,0 @@
fun async(f: () -> Unit) {
f()
}
infix fun Any.async(f: () -> Unit) = f()
fun test(foo: Any) {
<!UNSUPPORTED!>async<!> { }
`async` { }
<!UNSUPPORTED!>async<!> /**/ { }
foo <!UNSUPPORTED!>async<!> { }
async() { }
async({ })
foo async ({ })
foo <!UNSUPPORTED!>async<!> fun () {}
foo `async` fun () {}
foo async (fun () {})
async (fun () {})
}
-5
View File
@@ -1,5 +0,0 @@
package
public fun async(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public fun test(/*0*/ foo: kotlin.Any): kotlin.Unit
public infix fun kotlin.Any.async(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
@@ -571,12 +571,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("ReservedAsync.kt")
public void testReservedAsync() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/ReservedAsync.kt");
doTest(fileName);
}
@TestMetadata("ResolveOfJavaGenerics.kt")
public void testResolveOfJavaGenerics() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/ResolveOfJavaGenerics.kt");