@@ -783,7 +783,9 @@ object Parsers {
783
783
*/
784
784
def simpleType (): Tree = simpleTypeRest {
785
785
if (in.token == LPAREN )
786
- atPos(in.offset) { makeTupleOrParens(inParens(argTypes())) }
786
+ atPos(in.offset) {
787
+ makeTupleOrParens(inParens(argTypes(namedOK = false , wildOK = true )))
788
+ }
787
789
else if (in.token == LBRACE )
788
790
atPos(in.offset) { RefinedTypeTree (EmptyTree , refinement()) }
789
791
else if (isSimpleLiteral) { SingletonTypeTree (literal()) }
@@ -805,7 +807,8 @@ object Parsers {
805
807
806
808
private def simpleTypeRest (t : Tree ): Tree = in.token match {
807
809
case HASH => simpleTypeRest(typeProjection(t))
808
- case LBRACKET => simpleTypeRest(atPos(startOffset(t)) { AppliedTypeTree (t, typeArgs(namedOK = true )) })
810
+ case LBRACKET => simpleTypeRest(atPos(startOffset(t)) {
811
+ AppliedTypeTree (t, typeArgs(namedOK = true , wildOK = true )) })
809
812
case _ => t
810
813
}
811
814
@@ -826,7 +829,7 @@ object Parsers {
826
829
/** ArgTypes ::= Type {`,' Type}
827
830
* | NamedTypeArg {`,' NamedTypeArg}
828
831
*/
829
- def argTypes (namedOK : Boolean = false ) = {
832
+ def argTypes (namedOK : Boolean , wildOK : Boolean ) = {
830
833
def otherArgs (first : Tree , arg : () => Tree ): List [Tree ] = {
831
834
val rest =
832
835
if (in.token == COMMA ) {
@@ -836,16 +839,17 @@ object Parsers {
836
839
else Nil
837
840
first :: rest
838
841
}
842
+ def typParser () = if (wildOK) typ() else toplevelTyp()
839
843
if (namedOK && in.token == IDENTIFIER )
840
- typ () match {
844
+ typParser () match {
841
845
case Ident (name) if in.token == EQUALS =>
842
846
in.nextToken()
843
847
otherArgs(NamedArg (name, typ()), namedTypeArg)
844
848
case firstArg =>
845
849
if (in.token == EQUALS ) println(s " ??? $firstArg" )
846
850
otherArgs(firstArg, typ)
847
851
}
848
- else commaSeparated(typ )
852
+ else commaSeparated(typParser )
849
853
}
850
854
851
855
/** FunArgType ::= Type | `=>' Type
@@ -873,7 +877,7 @@ object Parsers {
873
877
/** TypeArgs ::= `[' Type {`,' Type} `]'
874
878
* NamedTypeArgs ::= `[' NamedTypeArg {`,' NamedTypeArg} `]'
875
879
*/
876
- def typeArgs (namedOK : Boolean = false ): List [Tree ] = inBrackets(argTypes(namedOK))
880
+ def typeArgs (namedOK : Boolean , wildOK : Boolean ): List [Tree ] = inBrackets(argTypes(namedOK, wildOK ))
877
881
878
882
/** Refinement ::= `{' RefineStatSeq `}'
879
883
*/
@@ -1250,7 +1254,7 @@ object Parsers {
1250
1254
in.nextToken()
1251
1255
simpleExprRest(selector(t), canApply = true )
1252
1256
case LBRACKET =>
1253
- val tapp = atPos(startOffset(t), in.offset) { TypeApply (t, typeArgs(namedOK = true )) }
1257
+ val tapp = atPos(startOffset(t), in.offset) { TypeApply (t, typeArgs(namedOK = true , wildOK = false )) }
1254
1258
simpleExprRest(tapp, canApply = true )
1255
1259
case LPAREN | LBRACE if canApply =>
1256
1260
val app = atPos(startOffset(t), in.offset) { Apply (t, argumentExprs()) }
@@ -1501,7 +1505,7 @@ object Parsers {
1501
1505
def simplePatternRest (t : Tree ): Tree = {
1502
1506
var p = t
1503
1507
if (in.token == LBRACKET )
1504
- p = atPos(startOffset(t), in.offset) { TypeApply (p, typeArgs()) }
1508
+ p = atPos(startOffset(t), in.offset) { TypeApply (p, typeArgs(namedOK = false , wildOK = false )) }
1505
1509
if (in.token == LPAREN )
1506
1510
p = atPos(startOffset(t), in.offset) { Apply (p, argumentPatterns()) }
1507
1511
p
0 commit comments