A bug with single-parameter closures without type annotations fixed
This commit is contained in:
@@ -1024,6 +1024,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!dontExpectParameters) {
|
} else if (!dontExpectParameters) {
|
||||||
|
PsiBuilder.Marker parameterList = mark();
|
||||||
PsiBuilder.Marker parameter = mark();
|
PsiBuilder.Marker parameter = mark();
|
||||||
int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos)));
|
int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos)));
|
||||||
|
|
||||||
@@ -1041,6 +1042,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
errorUntilOffset("Expecting '=>'", doubleArrowPos);
|
errorUntilOffset("Expecting '=>'", doubleArrowPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameterList.done(VALUE_PARAMETER_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
expectNoAdvance(DOUBLE_ARROW, "Expecting '=>'");
|
expectNoAdvance(DOUBLE_ARROW, "Expecting '=>'");
|
||||||
|
|||||||
@@ -756,10 +756,15 @@ public class JetTypeInferrer {
|
|||||||
for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) {
|
for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) {
|
||||||
JetParameter parameter = parameters.get(i);
|
JetParameter parameter = parameters.get(i);
|
||||||
JetTypeReference typeReference = parameter.getTypeReference();
|
JetTypeReference typeReference = parameter.getTypeReference();
|
||||||
if (typeReference == null) {
|
|
||||||
throw new UnsupportedOperationException("Type inference for parameters is not implemented yet");
|
JetType type;
|
||||||
|
if (typeReference != null) {
|
||||||
|
type = typeResolver.resolveType(scope, typeReference);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
trace.getErrorHandler().genericError(parameter.getNode(), "Type inference for parameters is not implemented yet");
|
||||||
|
type = ErrorUtils.createErrorType("Not inferred");
|
||||||
}
|
}
|
||||||
JetType type = typeResolver.resolveType(scope, typeReference);
|
|
||||||
ValueParameterDescriptor valueParameterDescriptor = classDescriptorResolver.resolveValueParameterDescriptor(functionDescriptor, parameter, i, type);
|
ValueParameterDescriptor valueParameterDescriptor = classDescriptorResolver.resolveValueParameterDescriptor(functionDescriptor, parameter, i, type);
|
||||||
parameterTypes.add(valueParameterDescriptor.getOutType());
|
parameterTypes.add(valueParameterDescriptor.getOutType());
|
||||||
valueParameterDescriptors.add(valueParameterDescriptor);
|
valueParameterDescriptors.add(valueParameterDescriptor);
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ JetFile: FunctionLiterals.jet
|
|||||||
PsiWhiteSpace('\n\n ')
|
PsiWhiteSpace('\n\n ')
|
||||||
FUNCTION_LITERAL
|
FUNCTION_LITERAL
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
VALUE_PARAMETER
|
VALUE_PARAMETER_LIST
|
||||||
PsiElement(IDENTIFIER)('a')
|
VALUE_PARAMETER
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(DOUBLE_ARROW)('=>')
|
PsiElement(DOUBLE_ARROW)('=>')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ JetFile: FunctionLiterals_ERR.jet
|
|||||||
FUNCTION_LITERAL
|
FUNCTION_LITERAL
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
VALUE_PARAMETER
|
VALUE_PARAMETER_LIST
|
||||||
PsiErrorElement:Expecting parameter name
|
VALUE_PARAMETER
|
||||||
<empty list>
|
PsiErrorElement:Expecting parameter name
|
||||||
|
<empty list>
|
||||||
PsiElement(DOUBLE_ARROW)('=>')
|
PsiElement(DOUBLE_ARROW)('=>')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
BODY
|
BODY
|
||||||
@@ -26,12 +27,13 @@ JetFile: FunctionLiterals_ERR.jet
|
|||||||
PsiWhiteSpace('\n ')
|
PsiWhiteSpace('\n ')
|
||||||
FUNCTION_LITERAL
|
FUNCTION_LITERAL
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
VALUE_PARAMETER
|
VALUE_PARAMETER_LIST
|
||||||
PsiElement(IDENTIFIER)('a')
|
VALUE_PARAMETER
|
||||||
PsiErrorElement:To specify many parameters, use the full notation: {(p1, p2, ...) => ...}
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(COMMA)(',')
|
PsiErrorElement:To specify many parameters, use the full notation: {(p1, p2, ...) => ...}
|
||||||
PsiWhiteSpace(' ')
|
PsiElement(COMMA)(',')
|
||||||
PsiElement(IDENTIFIER)('b')
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(DOUBLE_ARROW)('=>')
|
PsiElement(DOUBLE_ARROW)('=>')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
@@ -275,13 +277,14 @@ JetFile: FunctionLiterals_ERR.jet
|
|||||||
PsiWhiteSpace('\n\n ')
|
PsiWhiteSpace('\n\n ')
|
||||||
FUNCTION_LITERAL
|
FUNCTION_LITERAL
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
VALUE_PARAMETER
|
VALUE_PARAMETER_LIST
|
||||||
PsiElement(IDENTIFIER)('a')
|
VALUE_PARAMETER
|
||||||
PsiWhiteSpace(' ')
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiErrorElement:To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...}
|
|
||||||
PsiElement(COLON)(':')
|
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('b')
|
PsiErrorElement:To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...}
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(DOUBLE_ARROW)('=>')
|
PsiElement(DOUBLE_ARROW)('=>')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
|
|||||||
@@ -600,8 +600,9 @@ JetFile: FunctionsAndTypes.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
FUNCTION_LITERAL
|
FUNCTION_LITERAL
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
VALUE_PARAMETER
|
VALUE_PARAMETER_LIST
|
||||||
PsiElement(IDENTIFIER)('t')
|
VALUE_PARAMETER
|
||||||
|
PsiElement(IDENTIFIER)('t')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(DOUBLE_ARROW)('=>')
|
PsiElement(DOUBLE_ARROW)('=>')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
|
|||||||
@@ -944,8 +944,9 @@ JetFile: Graph.jet
|
|||||||
FUNCTION_LITERAL
|
FUNCTION_LITERAL
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
VALUE_PARAMETER
|
VALUE_PARAMETER_LIST
|
||||||
PsiElement(IDENTIFIER)('n')
|
VALUE_PARAMETER
|
||||||
|
PsiElement(IDENTIFIER)('n')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(DOUBLE_ARROW)('=>')
|
PsiElement(DOUBLE_ARROW)('=>')
|
||||||
PsiWhiteSpace('\n ')
|
PsiWhiteSpace('\n ')
|
||||||
|
|||||||
Reference in New Issue
Block a user