private bool IsPossibleNewExpression() { Debug.Assert(this.CurrentToken.Kind == SyntaxKind.NewKeyword); // skip new SyntaxToken nextToken = PeekToken(1); // new { } // new [ ] switch (nextToken.Kind) { case SyntaxKind.OpenBraceToken: case SyntaxKind.OpenBracketToken: return(true); } // // Declaration with new modifier vs. new expression // Parse it as an expression if the type is not followed by an identifier or this keyword. // // Member declarations: // new T Idf ... // new T this ... // new partial Idf ("partial" as a type name) // new partial this ("partial" as a type name) // new partial T Idf // new partial T this // new <modifier> // new <class|interface|struct|enum> // new partial <class|interface|struct|enum> // // New expressions: // new T [] // new T { } // new <non-type> // if (SyntaxKindFacts.GetBaseTypeDeclarationKind(nextToken.Kind) != SyntaxKind.None) { return(false); } SyntaxModifier modifier = GetModifier(nextToken); if (modifier != SyntaxModifier.None) { return(false); } bool?typedIdentifier = IsPossibleTypedIdentifierStart(nextToken, PeekToken(2), allowThisKeyword: true); if (typedIdentifier != null) { // new Idf Idf // new Idf . // new partial T // new partial . return(!typedIdentifier.Value); } var resetPoint = this.GetResetPoint(); try { // skips new keyword EatToken(); ScanTypeFlags st = this.ScanType(); return(!IsPossibleMemberName() || st == ScanTypeFlags.NotType); } finally { this.Reset(ref resetPoint); this.Release(ref resetPoint); } }