compiler: allow default as a variable name
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5a6e32e0 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5a6e32e0 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5a6e32e0 Branch: refs/heads/develop Commit: 5a6e32e095dbdb5ceb82bf74d2086ba61fd923db Parents: b1bfa69 Author: Josh Tynjala <[email protected]> Authored: Wed Apr 20 11:11:43 2016 -0700 Committer: Josh Tynjala <[email protected]> Committed: Wed Apr 20 11:11:43 2016 -0700 ---------------------------------------------------------------------- .../feature-tests/as/ASKeywordTests.java | 21 ++++++++++++++++++++ .../parsing/as/StreamingASTokenizer.java | 13 ++++++++++++ 2 files changed, 34 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5a6e32e0/compiler.tests/feature-tests/as/ASKeywordTests.java ---------------------------------------------------------------------- diff --git a/compiler.tests/feature-tests/as/ASKeywordTests.java b/compiler.tests/feature-tests/as/ASKeywordTests.java index 1602b3c..8223620 100644 --- a/compiler.tests/feature-tests/as/ASKeywordTests.java +++ b/compiler.tests/feature-tests/as/ASKeywordTests.java @@ -292,6 +292,27 @@ public class ASKeywordTests extends ASFeatureTestsBase } @Test + public void ASKeyword_default_as_variable_name() + { + // all tests can assume that flash.display.Sprite + // flash.system.System and flash.events.Event have been imported + String[] imports = new String[] + { + }; + String[] declarations = new String[] + { + "public var default:String;", + }; + String[] testCode = new String[] + { + "default = 'bar';", + "assertEqual('variable named default', default, 'bar');", + }; + String source = getAS(imports, declarations, testCode, new String[0]); + compileAndRun(source); + } + + @Test public void ASKeyword_as_member_expression() { // all tests can assume that flash.display.Sprite http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5a6e32e0/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java b/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java index 61b6e26..1c90e94 100644 --- a/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java +++ b/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java @@ -1025,6 +1025,19 @@ public class StreamingASTokenizer implements ASTokenTypes, IASTokenizer, Closeab else if (maybeXML != null && maybeXML.getType() != TOKEN_COLON) retVal.setType(TOKEN_IDENTIFIER); + else if (lastToken != null) + { + int lastTokenType = lastToken.getType(); + switch (lastTokenType) + { + case TOKEN_KEYWORD_VAR: + case TOKEN_KEYWORD_FUNCTION: + case TOKEN_RESERVED_WORD_GET: + case TOKEN_RESERVED_WORD_SET: + case TOKEN_OPERATOR_MEMBER_ACCESS: + retVal.setType(TOKEN_IDENTIFIER); + } + } return retVal; } case TOKEN_KEYWORD_VOID:
