diff --git a/grammar/src/types.grm b/grammar/src/types.grm index 91e18e42a87..35b16fa0aaf 100644 --- a/grammar/src/types.grm +++ b/grammar/src/types.grm @@ -30,7 +30,7 @@ functionType ; functionTypeContents - : "(" (parameter | type){","} ")" ":" type + : "(" (parameter | modifiers /*lazy out ref*/ type){","} ")" ":" type ; tupleType diff --git a/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java index 62199f949af..38b4b711d88 100644 --- a/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -772,6 +772,7 @@ public class JetParsing { if (!at(RPAR)) { while (true) { if (!parseValueParameter()) { + parseModifierList(); // lazy, out, ref parseTypeRef(); } if (!at(COMMA)) break; diff --git a/idea/testData/psi/FunctionTypes.jet b/idea/testData/psi/FunctionTypes.jet index ae37a029419..83c5bea43fa 100644 --- a/idea/testData/psi/FunctionTypes.jet +++ b/idea/testData/psi/FunctionTypes.jet @@ -12,3 +12,5 @@ type f = {(a : [a] a, foo, x : bar) : b} type f = {(foo, a : a) : b} type f = {(foo, a : {(a) : b}) : b} type f = {(foo, a : {(a) : b}) : {() : ()}} + +type f = {(lazy foo, out a : {(ref a) : b}) : {() : ()}} \ No newline at end of file diff --git a/idea/testData/psi/FunctionTypes.txt b/idea/testData/psi/FunctionTypes.txt index 0426efe3d23..65bbd693b27 100644 --- a/idea/testData/psi/FunctionTypes.txt +++ b/idea/testData/psi/FunctionTypes.txt @@ -13,7 +13,7 @@ JetFile: FunctionTypes.jet PsiElement(LBRACE)('{') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') - TYPE_REFERENCE + MODIFIER_LIST ATTRIBUTE_ANNOTATION PsiElement(LBRACKET)('[') ATTRIBUTE @@ -21,7 +21,8 @@ JetFile: FunctionTypes.jet USER_TYPE PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') + TYPE_REFERENCE USER_TYPE PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') @@ -401,6 +402,72 @@ JetFile: FunctionTypes.jet PsiWhiteSpace(' ') PsiElement(COLON)(':') PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + TUPLE_TYPE + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + MODIFIER_LIST + PsiElement(lazy)('lazy') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('foo') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + MODIFIER_LIST + PsiElement(ref)('ref') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('b') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') TYPE_REFERENCE PsiElement(LBRACE)('{') VALUE_PARAMETER_LIST diff --git a/idea/testData/psi/FunctionTypes_ERR.txt b/idea/testData/psi/FunctionTypes_ERR.txt index 9a7fffd7b32..c742264d19f 100644 --- a/idea/testData/psi/FunctionTypes_ERR.txt +++ b/idea/testData/psi/FunctionTypes_ERR.txt @@ -13,7 +13,7 @@ JetFile: FunctionTypes_ERR.jet PsiElement(LBRACE)('{') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') - TYPE_REFERENCE + MODIFIER_LIST ATTRIBUTE_ANNOTATION PsiElement(LBRACKET)('[') ATTRIBUTE @@ -21,7 +21,8 @@ JetFile: FunctionTypes_ERR.jet USER_TYPE PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') + TYPE_REFERENCE USER_TYPE PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')')