@@ -783,7 +783,9 @@ object Parsers {
783783 */
784784 def simpleType (): Tree = simpleTypeRest {
785785 if (in.token == LPAREN )
786- atPos(in.offset) { makeTupleOrParens(inParens(argTypes())) }
786+ atPos(in.offset) {
787+ makeTupleOrParens(inParens(argTypes(namedOK = false , wildOK = true )))
788+ }
787789 else if (in.token == LBRACE )
788790 atPos(in.offset) { RefinedTypeTree (EmptyTree , refinement()) }
789791 else if (isSimpleLiteral) { SingletonTypeTree (literal()) }
@@ -805,7 +807,8 @@ object Parsers {
805807
806808 private def simpleTypeRest (t : Tree ): Tree = in.token match {
807809 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 )) })
809812 case _ => t
810813 }
811814
@@ -826,7 +829,7 @@ object Parsers {
826829 /** ArgTypes ::= Type {`,' Type}
827830 * | NamedTypeArg {`,' NamedTypeArg}
828831 */
829- def argTypes (namedOK : Boolean = false ) = {
832+ def argTypes (namedOK : Boolean , wildOK : Boolean ) = {
830833 def otherArgs (first : Tree , arg : () => Tree ): List [Tree ] = {
831834 val rest =
832835 if (in.token == COMMA ) {
@@ -836,16 +839,17 @@ object Parsers {
836839 else Nil
837840 first :: rest
838841 }
842+ def typParser () = if (wildOK) typ() else toplevelTyp()
839843 if (namedOK && in.token == IDENTIFIER )
840- typ () match {
844+ typParser () match {
841845 case Ident (name) if in.token == EQUALS =>
842846 in.nextToken()
843847 otherArgs(NamedArg (name, typ()), namedTypeArg)
844848 case firstArg =>
845849 if (in.token == EQUALS ) println(s " ??? $firstArg" )
846850 otherArgs(firstArg, typ)
847851 }
848- else commaSeparated(typ )
852+ else commaSeparated(typParser )
849853 }
850854
851855 /** FunArgType ::= Type | `=>' Type
@@ -873,7 +877,7 @@ object Parsers {
873877 /** TypeArgs ::= `[' Type {`,' Type} `]'
874878 * NamedTypeArgs ::= `[' NamedTypeArg {`,' NamedTypeArg} `]'
875879 */
876- def typeArgs (namedOK : Boolean = false ): List [Tree ] = inBrackets(argTypes(namedOK))
880+ def typeArgs (namedOK : Boolean , wildOK : Boolean ): List [Tree ] = inBrackets(argTypes(namedOK, wildOK ))
877881
878882 /** Refinement ::= `{' RefineStatSeq `}'
879883 */
@@ -1250,7 +1254,7 @@ object Parsers {
12501254 in.nextToken()
12511255 simpleExprRest(selector(t), canApply = true )
12521256 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 )) }
12541258 simpleExprRest(tapp, canApply = true )
12551259 case LPAREN | LBRACE if canApply =>
12561260 val app = atPos(startOffset(t), in.offset) { Apply (t, argumentExprs()) }
@@ -1501,7 +1505,7 @@ object Parsers {
15011505 def simplePatternRest (t : Tree ): Tree = {
15021506 var p = t
15031507 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 )) }
15051509 if (in.token == LPAREN )
15061510 p = atPos(startOffset(t), in.offset) { Apply (p, argumentPatterns()) }
15071511 p
0 commit comments