@@ -1666,7 +1666,7 @@ object Parsers {
1666
1666
if in.token == LPAREN then funParamClause() :: funParamClauses() else Nil
1667
1667
1668
1668
/** InfixType ::= RefinedType {id [nl] RefinedType}
1669
- * | RefinedType `^`
1669
+ * | RefinedType `^` // under capture checking
1670
1670
*/
1671
1671
def infixType (): Tree = infixTypeRest(refinedType())
1672
1672
@@ -2881,13 +2881,13 @@ object Parsers {
2881
2881
if (isIdent(nme.raw.BAR )) { in.nextToken(); pattern1(location) :: patternAlts(location) }
2882
2882
else Nil
2883
2883
2884
- /** Pattern1 ::= PatVar Ascription
2885
- * | [‘-’] integerLiteral Ascription
2886
- * | [‘-’] floatingPointLiteral Ascription
2884
+ /** Pattern1 ::= PatVar `:` RefinedType
2885
+ * | [‘-’] integerLiteral `:` RefinedType
2886
+ * | [‘-’] floatingPointLiteral `:` RefinedType
2887
2887
* | Pattern2
2888
2888
*/
2889
2889
def pattern1 (location : Location = Location .InPattern ): Tree =
2890
- val p = pattern2()
2890
+ val p = pattern2(location )
2891
2891
if in.isColon then
2892
2892
val isVariableOrNumber = isVarPattern(p) || p.isInstanceOf [Number ]
2893
2893
if ! isVariableOrNumber then
@@ -2905,11 +2905,10 @@ object Parsers {
2905
2905
else p
2906
2906
2907
2907
/** Pattern3 ::= InfixPattern
2908
- * | PatVar ‘*’
2909
2908
*/
2910
- def pattern3 (): Tree =
2909
+ def pattern3 (location : Location ): Tree =
2911
2910
val p = infixPattern()
2912
- if followingIsVararg() then
2911
+ if location.inArgs && followingIsVararg() then
2913
2912
val start = in.skipToken()
2914
2913
p match
2915
2914
case p @ Ident (name) if name.isVarPattern =>
@@ -2921,10 +2920,10 @@ object Parsers {
2921
2920
2922
2921
/** Pattern2 ::= [id `@'] Pattern3
2923
2922
*/
2924
- val pattern2 : () => Tree = () => pattern3() match
2923
+ val pattern2 : Location => Tree = location => pattern3(location ) match
2925
2924
case p @ Ident (name) if in.token == AT =>
2926
2925
val offset = in.skipToken()
2927
- pattern3() match {
2926
+ pattern3(location ) match {
2928
2927
case pt @ Bind (nme.WILDCARD , pt1 : Typed ) if pt.mods.is(Given ) =>
2929
2928
atSpan(startOffset(p), 0 ) { Bind (name, pt1).withMods(pt.mods) }
2930
2929
case Typed (Ident (nme.WILDCARD ), pt @ Ident (tpnme.WILDCARD_STAR )) =>
@@ -2954,6 +2953,7 @@ object Parsers {
2954
2953
* | XmlPattern
2955
2954
* | `(' [Patterns] `)'
2956
2955
* | SimplePattern1 [TypeArgs] [ArgumentPatterns]
2956
+ * | ‘given’ RefinedType
2957
2957
* SimplePattern1 ::= SimpleRef
2958
2958
* | SimplePattern1 `.' id
2959
2959
* PatVar ::= id
@@ -3597,7 +3597,7 @@ object Parsers {
3597
3597
* VarDcl ::= id {`,' id} `:' Type
3598
3598
*/
3599
3599
def patDefOrDcl (start : Offset , mods : Modifiers ): Tree = atSpan(start, nameStart) {
3600
- val first = pattern2()
3600
+ val first = pattern2(Location . InPattern )
3601
3601
var lhs = first match {
3602
3602
case id : Ident if in.token == COMMA =>
3603
3603
in.nextToken()
0 commit comments