Parenthesis are mandatory after a constructor call (due to problems with 'new Foo?isValid()')

This commit is contained in:
Andrey Breslav
2011-03-17 11:51:28 +03:00
parent b46543b872
commit 28e16cc214
7 changed files with 22 additions and 12 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ expressions
; ;
constructorInvocation constructorInvocation
: userType valueArguments? : userType valueArguments
; ;
arrayAccess arrayAccess
@@ -1361,7 +1361,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
* "new" constructorInvocation // identical to new nunctionCall * "new" constructorInvocation // identical to new nunctionCall
* *
* constructorInvocation * constructorInvocation
* : userType valueArguments? * : userType valueArguments
*/ */
private void parseNew() { private void parseNew() {
assert _at(NEW_KEYWORD); assert _at(NEW_KEYWORD);
@@ -1370,10 +1370,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance(); // NEW_KEYWORD advance(); // NEW_KEYWORD
myJetParsing.parseTypeRef(); myJetParsing.parseTypeRef();
parseValueArgumentList();
if (!eol() && at(LPAR)) {
parseValueArgumentList();
}
creation.done(NEW); creation.done(NEW);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
fun a( fun a(
a : foo = throw new Foo, a : foo = throw new Foo(),
a : foo = return 10, a : foo = return 10,
a : foo = break, a : foo = break,
a : foo = break @la, a : foo = break @la,
+3
View File
@@ -31,6 +31,9 @@ JetFile: ControlStructures.jet
USER_TYPE USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo') PsiElement(IDENTIFIER)('Foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',') PsiElement(COMMA)(',')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
VALUE_PARAMETER VALUE_PARAMETER
+3 -3
View File
@@ -21,10 +21,10 @@ fun a(
a : foo = typeof(10), a : foo = typeof(10),
a : foo = new Foo(bar), a : foo = new Foo(bar),
a : foo = new Foo<A>(bar), a : foo = new Foo<A>(bar),
a : foo = new Foo, a : foo = new Foo(),
a : foo = new Foo<bar>, a : foo = new Foo<bar>(),
a : foo = object Foo{}, a : foo = object Foo{},
a : foo = throw new Foo, a : foo = throw new Foo(),
a : foo = return 10, a : foo = return 10,
a : foo = break, a : foo = break,
a : foo = break @la, a : foo = break @la,
+9
View File
@@ -435,6 +435,9 @@ JetFile: SimpleExpressions.jet
USER_TYPE USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo') PsiElement(IDENTIFIER)('Foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',') PsiElement(COMMA)(',')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
VALUE_PARAMETER VALUE_PARAMETER
@@ -464,6 +467,9 @@ JetFile: SimpleExpressions.jet
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar') PsiElement(IDENTIFIER)('bar')
PsiElement(GT)('>') PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',') PsiElement(COMMA)(',')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
VALUE_PARAMETER VALUE_PARAMETER
@@ -514,6 +520,9 @@ JetFile: SimpleExpressions.jet
USER_TYPE USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo') PsiElement(IDENTIFIER)('Foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',') PsiElement(COMMA)(',')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
VALUE_PARAMETER VALUE_PARAMETER
@@ -22,7 +22,7 @@ import util.*
new X<String>() `plus`+ "1" new X<String>() `plus`+ "1"
new X<String>() `plus`plus "sadfas" new X<String>() `plus`plus "sadfas"
new X<String>().`plus`plus("") new X<String>().`plus`plus("")
val x = new X<String> val x = new X<String>()
x `minus`- "" x `minus`- ""
x `times`* "" x `times`* ""
x `div`/ "" x `div`/ ""
@@ -51,7 +51,7 @@ import util.*
fun <T> tt(t : T) : T { fun <T> tt(t : T) : T {
val x : List = 0 val x : List = 0
x`java::java.util.List.get()`[1] x`java::java.util.List.get()`[1]
val foo = new Bar val foo = new Bar()
foo`!`[null, 1] foo`!`[null, 1]
foo`get2`[1, 1] foo`get2`[1, 1]
foo`get1`[1] foo`get1`[1]
@@ -62,7 +62,7 @@ fun <T> tt(t : T) : T {
x`!`[null] = null x`!`[null] = null
(x`!`[null, 2]) = null (x`!`[null, 2]) = null
(`not`!foo)[1]`:std::Char` (`not`!foo)[1]`:std::Char`
val y = new Bar val y = new Bar()
y`inc`++ y`inc`++
`inc`++y `inc`++y
`dec`--y `dec`--y