diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetCallExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetCallExpression.java index 3d208f266a2..987a7481529 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetCallExpression.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetCallExpression.java @@ -6,6 +6,7 @@ import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lexer.JetTokens; import java.util.Collections; import java.util.List; @@ -49,26 +50,31 @@ public class JetCallExpression extends JetExpression implements JetCallElement { @NotNull public List getFunctionLiteralArguments() { JetExpression calleeExpression = getCalleeExpression(); + ASTNode node; if (calleeExpression instanceof JetFunctionLiteralExpression) { - List result = new SmartList(); - ASTNode treeNext = calleeExpression.getNode().getTreeNext(); - while (treeNext != null) { - PsiElement psi = treeNext.getPsi(); - if (psi instanceof JetFunctionLiteralExpression) { - result.add((JetFunctionLiteralExpression) psi); - } - else if (psi instanceof JetLabelQualifiedExpression) { - JetLabelQualifiedExpression labelQualifiedExpression = (JetLabelQualifiedExpression) psi; - JetExpression labeledExpression = labelQualifiedExpression.getLabeledExpression(); + node = calleeExpression.getNode().getTreeNext(); + } + else { + node = getNode().getFirstChildNode(); + } + List result = new SmartList(); + while (node != null) { + PsiElement psi = node.getPsi(); + if (psi instanceof JetFunctionLiteralExpression) { + result.add((JetFunctionLiteralExpression) psi); + } + else if (psi instanceof JetPrefixExpression) { + JetPrefixExpression prefixExpression = (JetPrefixExpression) psi; + if (JetTokens.LABELS.contains(prefixExpression.getOperationSign().getReferencedNameElementType())) { + JetExpression labeledExpression = prefixExpression.getBaseExpression(); if (labeledExpression instanceof JetFunctionLiteralExpression) { result.add(labeledExpression); } } - treeNext = treeNext.getTreeNext(); } - return result; + node = node.getTreeNext(); } - return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL_EXPRESSION); + return result; } @Override diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet new file mode 100644 index 00000000000..49bd3b8b550 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet @@ -0,0 +1,7 @@ +// KT-439 Support labeled function lliterals in call arguments + +inline fun run1(body : fun() : T) : T = body() + +fun main1(args : Array) { + run1 @l{ 1 } // should not be an error +}