@@ -1574,20 +1574,15 @@ object Parsers {
1574
1574
1575
1575
/** SimpleType ::= SimpleType TypeArgs
1576
1576
* | SimpleType `#' id
1577
- * | Singleton `.' id
1577
+ * | SimpleClassType
1578
1578
* | Singleton `.' type
1579
- * | `(' ArgTypes `)'
1580
1579
* | `_' TypeBounds
1581
1580
* | Refinement
1582
1581
* | Literal
1583
1582
* | ‘$’ ‘{’ Block ‘}’
1584
1583
*/
1585
1584
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 )
1585
+ if in.token == LBRACE then
1591
1586
atSpan(in.offset) { RefinedTypeTree (EmptyTree , refinement()) }
1592
1587
else if (isSimpleLiteral) { SingletonTypeTree (literal(inType = true )) }
1593
1588
else if isIdent(nme.raw.MINUS ) && numericLitTokens.contains(in.lookahead.token) then
@@ -1611,21 +1606,30 @@ object Parsers {
1611
1606
else if (isSplice)
1612
1607
splice(isType = true )
1613
1608
else
1614
- singletonCompletion(simpleRef() )
1609
+ simpleClassType( )
1615
1610
}
1616
1611
1617
- /** Singleton ::= SimpleRef
1618
- * | Singleton ‘.’ id
1612
+ /** SimpleClassType ::= [Singleton ‘.’] id
1613
+ * | ‘(’ ArgTypes ‘)’
1614
+ * Singleton ::= SimpleRef
1615
+ * | Singleton ‘.’ id
1619
1616
*/
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)
1617
+ def simpleClassType (): Tree =
1618
+ if in.token == LPAREN then
1619
+ atSpan(in.offset) {
1620
+ makeTupleOrParens(inParens(argTypes(namedOK = false , wildOK = true )))
1621
+ }
1622
+ else
1623
+ def singletonCompletion (t : Tree ): Tree =
1624
+ if in.token == DOT then
1625
+ in.nextToken()
1626
+ if in.token == TYPE then
1627
+ in.nextToken()
1628
+ atSpan(startOffset(t)) { SingletonTypeTree (t) }
1629
+ else
1630
+ singletonCompletion(idSelector(t))
1631
+ else convertToTypeId(t)
1632
+ singletonCompletion(simpleRef())
1629
1633
1630
1634
private def simpleTypeRest (t : Tree ): Tree = in.token match {
1631
1635
case HASH => simpleTypeRest(typeProjection(t))
@@ -3145,13 +3149,15 @@ object Parsers {
3145
3149
mkTree(qual, ImportSelector (wildcardSelectorId()) :: Nil )
3146
3150
case LBRACE =>
3147
3151
mkTree(qual, inBraces(importSelectors(idOK = true )))
3148
- case _ =>
3152
+ case IDENTIFIER | BACKQUOTED_IDENT =>
3149
3153
val start = in.offset
3150
3154
val name = ident()
3151
3155
if in.token == DOT then
3152
3156
importSelection(atSpan(startOffset(qual), start) { Select (qual, name) })
3153
3157
else
3154
3158
mkTree(qual, ImportSelector (atSpan(start) { Ident (name) }) :: Nil )
3159
+ case _ =>
3160
+ idSelector(qual) // this will produce an error, which can lead to a completion in the repl
3155
3161
3156
3162
() => importSelection(simpleRef())
3157
3163
}
0 commit comments