Issue 1197. Support for using 'static' as method name
http://code.google.com/p/dart/issues/detail?id=1197 R=brianwilkerson@google.com BUG= TEST= Review URL: https://chromiumcodereview.appspot.com//10557037 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8801 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -974,7 +974,7 @@ public class DartParser extends CompletionHooksParserBase {
|
||||
private DartNode parseFieldOrMethod(boolean allowStatic) {
|
||||
beginClassMember();
|
||||
Modifiers modifiers = Modifiers.NONE;
|
||||
if (optionalPseudoKeyword(STATIC_KEYWORD)) {
|
||||
if (peek(1) != Token.LPAREN && optionalPseudoKeyword(STATIC_KEYWORD)) {
|
||||
if (!allowStatic) {
|
||||
reportError(position(), ParserErrorCode.TOP_LEVEL_CANNOT_BE_STATIC);
|
||||
} else {
|
||||
|
||||
@@ -576,6 +576,24 @@ public class SyntaxTest extends AbstractParserTest {
|
||||
" typedef();",
|
||||
"}"));
|
||||
}
|
||||
|
||||
/**
|
||||
* We should be able to parse "static(abstract) => 42" top-level function.
|
||||
* <p>
|
||||
* http://code.google.com/p/dart/issues/detail?id=1197
|
||||
*/
|
||||
public void test_staticAsFunctionName() {
|
||||
DartUnit unit = parseUnit(
|
||||
getName(),
|
||||
Joiner.on("\n").join(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"static(abstract) => 42;",
|
||||
""));
|
||||
assertEquals(1, unit.getTopLevelNodes().size());
|
||||
DartMethodDefinition method = (DartMethodDefinition) unit.getTopLevelNodes().get(0);
|
||||
assertEquals("static", method.getName().toSource());
|
||||
assertEquals("abstract", method.getFunction().getParameters().get(0).getName().toSource());
|
||||
}
|
||||
|
||||
/**
|
||||
* The token 'super' is valid by itself (not as a qualifier or assignment selector) in only some
|
||||
|
||||
@@ -100,7 +100,6 @@ private_member3_negative_test: Fail # Issue 2383
|
||||
pseudo_kw_illegal_test/08: Fail # Issue 356
|
||||
pseudo_kw_illegal_test/10: Fail # Issue 356
|
||||
pseudo_kw_illegal_test/14: Fail # Issue 356
|
||||
pseudo_kw_test: Fail # Issue 356
|
||||
scope_negative_test: Fail # Runtime only test, rewrite as multitest
|
||||
static_call_wrong_argument_count_negative_test: Fail # Runtime only test, rewrite as multitest
|
||||
switch7_negative_test: Fail # Issue 3658
|
||||
|
||||
Reference in New Issue
Block a user