@@ -1665,7 +1665,7 @@ object Parsers {
1665
1665
if in.token == LPAREN then funParamClause() :: funParamClauses() else Nil
1666
1666
1667
1667
/** InfixType ::= RefinedType {id [nl] RefinedType}
1668
- * | RefinedType `^`
1668
+ * | RefinedType `^` // under capture checking
1669
1669
*/
1670
1670
def infixType (): Tree = infixTypeRest(refinedType())
1671
1671
@@ -2855,13 +2855,13 @@ object Parsers {
2855
2855
if (isIdent(nme.raw.BAR )) { in.nextToken(); pattern1(location) :: patternAlts(location) }
2856
2856
else Nil
2857
2857
2858
- /** Pattern1 ::= PatVar Ascription
2859
- * | [‘-’] integerLiteral Ascription
2860
- * | [‘-’] floatingPointLiteral Ascription
2858
+ /** Pattern1 ::= PatVar `:` RefinedType
2859
+ * | [‘-’] integerLiteral `:` RefinedType
2860
+ * | [‘-’] floatingPointLiteral `:` RefinedType
2861
2861
* | Pattern2
2862
2862
*/
2863
2863
def pattern1 (location : Location = Location .InPattern ): Tree =
2864
- val p = pattern2()
2864
+ val p = pattern2(location )
2865
2865
if in.isColon then
2866
2866
val isVariableOrNumber = isVarPattern(p) || p.isInstanceOf [Number ]
2867
2867
if ! isVariableOrNumber then
@@ -2879,11 +2879,10 @@ object Parsers {
2879
2879
else p
2880
2880
2881
2881
/** Pattern3 ::= InfixPattern
2882
- * | PatVar ‘*’
2883
2882
*/
2884
- def pattern3 (): Tree =
2883
+ def pattern3 (location : Location ): Tree =
2885
2884
val p = infixPattern()
2886
- if followingIsVararg() then
2885
+ if location.inArgs && followingIsVararg() then
2887
2886
val start = in.skipToken()
2888
2887
p match
2889
2888
case p @ Ident (name) if name.isVarPattern =>
@@ -2895,10 +2894,10 @@ object Parsers {
2895
2894
2896
2895
/** Pattern2 ::= [id `@'] Pattern3
2897
2896
*/
2898
- val pattern2 : () => Tree = () => pattern3() match
2897
+ val pattern2 : Location => Tree = location => pattern3(location ) match
2899
2898
case p @ Ident (name) if in.token == AT =>
2900
2899
val offset = in.skipToken()
2901
- pattern3() match {
2900
+ pattern3(location ) match {
2902
2901
case pt @ Bind (nme.WILDCARD , pt1 : Typed ) if pt.mods.is(Given ) =>
2903
2902
atSpan(startOffset(p), 0 ) { Bind (name, pt1).withMods(pt.mods) }
2904
2903
case Typed (Ident (nme.WILDCARD ), pt @ Ident (tpnme.WILDCARD_STAR )) =>
@@ -2928,6 +2927,7 @@ object Parsers {
2928
2927
* | XmlPattern
2929
2928
* | `(' [Patterns] `)'
2930
2929
* | SimplePattern1 [TypeArgs] [ArgumentPatterns]
2930
+ * | ‘given’ RefinedType
2931
2931
* SimplePattern1 ::= SimpleRef
2932
2932
* | SimplePattern1 `.' id
2933
2933
* PatVar ::= id
@@ -3569,7 +3569,7 @@ object Parsers {
3569
3569
* VarDcl ::= id {`,' id} `:' Type
3570
3570
*/
3571
3571
def patDefOrDcl (start : Offset , mods : Modifiers ): Tree = atSpan(start, nameStart) {
3572
- val first = pattern2()
3572
+ val first = pattern2(Location . InPattern )
3573
3573
var lhs = first match {
3574
3574
case id : Ident if in.token == COMMA =>
3575
3575
in.nextToken()
0 commit comments