@@ -432,6 +432,13 @@ object Parsers {
432
432
433
433
def commaSeparated [T ](part : () => T ): List [T ] = tokenSeparated(COMMA , part)
434
434
435
+ /** Is the token following the current one in `tokens`? */
436
+ def lookaheadIn (tokens : Token * ): Boolean = {
437
+ val lookahead = in.lookaheadScanner
438
+ lookahead.nextToken()
439
+ tokens.contains(lookahead.token)
440
+ }
441
+
435
442
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
436
443
437
444
var opStack : List [OpInfo ] = Nil
@@ -799,11 +806,7 @@ object Parsers {
799
806
800
807
/** Is current ident a `*`, and is it followed by a `)` or `,`? */
801
808
def isPostfixStar : Boolean =
802
- in.name == nme.raw.STAR && {
803
- val lookahead = in.lookaheadScanner
804
- lookahead.nextToken()
805
- (lookahead.token == RPAREN || lookahead.token == COMMA )
806
- }
809
+ in.name == nme.raw.STAR && lookaheadIn(RPAREN , COMMA )
807
810
808
811
def infixTypeRest (t : Tree ): Tree =
809
812
infixOps(t, canStartTypeTokens, refinedType, isType = true , isOperator = ! isPostfixStar)
@@ -842,7 +845,7 @@ object Parsers {
842
845
/** SimpleType ::= SimpleType TypeArgs
843
846
* | SimpleType `#' id
844
847
* | StableId
845
- * | [‘-’ | ‘+’ | ‘~’ | ‘!’ ] StableId
848
+ * | ['~' ] StableId
846
849
* | Path `.' type
847
850
* | `(' ArgTypes `)'
848
851
* | `_' TypeBounds
@@ -861,7 +864,7 @@ object Parsers {
861
864
val start = in.skipToken()
862
865
typeBounds().withPos(Position (start, in.lastOffset, start))
863
866
}
864
- else if (isIdent && nme.raw.isUnary(in.name ))
867
+ else if (isIdent( nme.raw.TILDE ) && lookaheadIn( IDENTIFIER , BACKQUOTED_IDENT ))
865
868
atPos(in.offset) { PrefixOp (typeIdent(), path(thisOK = true )) }
866
869
else path(thisOK = false , handleSingletonType) match {
867
870
case r @ SingletonTypeTree (_) => r
0 commit comments