@@ -559,7 +559,7 @@ object desugar {
559
559
* ValDef or DefDef.
560
560
*/
561
561
def makePatDef (original : Tree , mods : Modifiers , pat : Tree , rhs : Tree )(implicit ctx : Context ): Tree = pat match {
562
- case VarPattern (named, tpt) =>
562
+ case IdPattern (named, tpt) =>
563
563
derivedValDef(original, named, tpt, rhs, mods)
564
564
case _ =>
565
565
val rhsUnchecked = makeAnnotated(" scala.unchecked" , rhs)
@@ -816,7 +816,7 @@ object desugar {
816
816
* Otherwise this gives { case pat => body }
817
817
*/
818
818
def makeLambda (pat : Tree , body : Tree ): Tree = pat match {
819
- case VarPattern (named, tpt) =>
819
+ case IdPattern (named, tpt) =>
820
820
Function (derivedValDef(pat, named, tpt, EmptyTree , Modifiers (Param )) :: Nil , body)
821
821
case _ =>
822
822
makeCaseLambda(CaseDef (pat, EmptyTree , body) :: Nil , unchecked = false )
@@ -898,7 +898,9 @@ object desugar {
898
898
}
899
899
900
900
def isIrrefutableGenFrom (gen : GenFrom ): Boolean =
901
- gen.isInstanceOf [IrrefutableGenFrom ] || isIrrefutable(gen.pat, gen.expr)
901
+ gen.isInstanceOf [IrrefutableGenFrom ] ||
902
+ IdPattern .unapply(gen.pat).isDefined ||
903
+ isIrrefutable(gen.pat, gen.expr)
902
904
903
905
/** rhs.name with a pattern filter on rhs unless `pat` is irrefutable when
904
906
* matched against `rhs`.
@@ -1062,9 +1064,9 @@ object desugar {
1062
1064
TypeDef (tpnme.REFINE_CLASS , impl).withFlags(Trait )
1063
1065
}
1064
1066
1065
- /** If tree is a variable pattern , return its name and type, otherwise return None.
1067
+ /** If tree is of the form `id` or `id: T` , return its name and type, otherwise return None.
1066
1068
*/
1067
- private object VarPattern {
1069
+ private object IdPattern {
1068
1070
def unapply (tree : Tree )(implicit ctx : Context ): Option [VarInfo ] = tree match {
1069
1071
case id : Ident => Some (id, TypeTree ())
1070
1072
case Typed (id : Ident , tpt) => Some ((id, tpt))
0 commit comments