@@ -1572,61 +1572,62 @@ object Parsers {
15721572 if (isType) TypSplice (expr) else Splice (expr)
15731573 }
15741574
1575- /** SimpleType ::= SimpleType TypeArgs
1576- * | SimpleType `#' id
1577- * | Singleton `.' id
1578- * | Singleton `.' type
1579- * | `(' ArgTypes `)'
1580- * | `_' TypeBounds
1581- * | Refinement
1582- * | Literal
1583- * | ‘$’ ‘{’ Block ‘}’
1575+ /** SimpleType ::= SimpleLiteral
1576+ * | ‘?’ SubtypeBounds
1577+ * | SimpleType1
15841578 */
1585- def simpleType (): Tree = simpleTypeRest {
1586- if (in.token == LPAREN )
1587- atSpan(in.offset) {
1588- makeTupleOrParens(inParens(argTypes(namedOK = false , wildOK = true )))
1589- }
1590- else if (in.token == LBRACE )
1591- atSpan(in.offset) { RefinedTypeTree (EmptyTree , refinement()) }
1592- else if (isSimpleLiteral) { SingletonTypeTree (literal(inType = true )) }
1579+ def simpleType (): Tree =
1580+ if isSimpleLiteral then
1581+ SingletonTypeTree (literal(inType = true ))
15931582 else if isIdent(nme.raw.MINUS ) && numericLitTokens.contains(in.lookahead.token) then
15941583 val start = in.offset
15951584 in.nextToken()
15961585 SingletonTypeTree (literal(negOffset = start, inType = true ))
1597- else if ( in.token == USCORE ) {
1586+ else if in.token == USCORE then
15981587 if sourceVersion.isAtLeast(`3.1`) then
15991588 deprecationWarning(em " `_` is deprecated for wildcard arguments of types: use `?` instead " )
16001589 patch(source, Span (in.offset, in.offset + 1 ), " ?" )
16011590 val start = in.skipToken()
16021591 typeBounds().withSpan(Span (start, in.lastOffset, start))
1603- }
1604- else if (isIdent(nme.? )) {
1592+ else if isIdent(nme.? ) then
16051593 val start = in.skipToken()
16061594 typeBounds().withSpan(Span (start, in.lastOffset, start))
1607- }
1608- else if (isIdent(nme.* ) && ctx.settings.YkindProjector .value) {
1595+ else if isIdent(nme.* ) && ctx.settings.YkindProjector .value then
16091596 typeIdent()
1610- }
1597+ else
1598+ simpleType1()
1599+
1600+ /** SimpleType1 ::= id
1601+ * | Singleton `.' id
1602+ * | Singleton `.' type
1603+ * | ‘(’ ArgTypes ‘)’
1604+ * | Refinement
1605+ * | ‘$’ ‘{’ Block ‘}’
1606+ * | SimpleType1 TypeArgs
1607+ * | SimpleType1 `#' id
1608+ */
1609+ def simpleType1 () = simpleTypeRest {
1610+ if in.token == LPAREN then
1611+ atSpan(in.offset) {
1612+ makeTupleOrParens(inParens(argTypes(namedOK = false , wildOK = true )))
1613+ }
1614+ else if in.token == LBRACE then
1615+ atSpan(in.offset) { RefinedTypeTree (EmptyTree , refinement()) }
16111616 else if (isSplice)
16121617 splice(isType = true )
16131618 else
1619+ def singletonCompletion (t : Tree ): Tree =
1620+ if in.token == DOT then
1621+ in.nextToken()
1622+ if in.token == TYPE then
1623+ in.nextToken()
1624+ atSpan(startOffset(t)) { SingletonTypeTree (t) }
1625+ else
1626+ singletonCompletion(idSelector(t))
1627+ else convertToTypeId(t)
16141628 singletonCompletion(simpleRef())
16151629 }
16161630
1617- /** Singleton ::= SimpleRef
1618- * | Singleton ‘.’ id
1619- */
1620- def singletonCompletion (t : Tree ): Tree =
1621- if in.token == DOT then
1622- in.nextToken()
1623- if in.token == TYPE then
1624- in.nextToken()
1625- atSpan(startOffset(t)) { SingletonTypeTree (t) }
1626- else
1627- singletonCompletion(idSelector(t))
1628- else convertToTypeId(t)
1629-
16301631 private def simpleTypeRest (t : Tree ): Tree = in.token match {
16311632 case HASH => simpleTypeRest(typeProjection(t))
16321633 case LBRACKET => simpleTypeRest(atSpan(startOffset(t)) {
@@ -3630,13 +3631,13 @@ object Parsers {
36303631
36313632/* -------- TEMPLATES ------------------------------------------- */
36323633
3633- /** SimpleConstrApp ::= AnnotType {ParArgumentExprs}
3634+ /** ConstrApp ::= SimpleType1 {Annotation} {ParArgumentExprs}
36343635 */
3635- val constrApp : () => Tree = () => {
3636- val t = rejectWildcardType(annotType(), fallbackTree = Ident (nme.ERROR ))
3637- // Using Ident(nme.ERROR) to avoid causing cascade errors on non-user-written code
3636+ val constrApp : () => Tree = () =>
3637+ val t = rejectWildcardType(annotTypeRest(simpleType1()),
3638+ fallbackTree = Ident (tpnme.ERROR ))
3639+ // Using Ident(tpnme.ERROR) to avoid causing cascade errors on non-user-written code
36383640 if in.token == LPAREN then parArgumentExprss(wrapNew(t)) else t
3639- }
36403641
36413642 /** ConstrApps ::= ConstrApp {(‘,’ | ‘with’) ConstrApp}
36423643 */
0 commit comments