@@ -1653,18 +1653,19 @@ object desugar {
16531653 * that refers to the bound variable for the pattern. Wildcard Binds are
16541654 * also replaced by Binds with fresh names.
16551655 */
1656- def makeIdPat (pat : Tree ): (Tree , Ident ) = pat match {
1657- case bind @ Bind (name, pat1) =>
1658- if name == nme.WILDCARD then
1659- val name = UniqueName .fresh()
1660- (cpy.Bind (pat)(name, pat1).withMods(bind.mods), Ident (name))
1661- else (pat, Ident (name))
1656+ def makeIdPat (pat : Tree ): (Tree , Ident ) = pat match
1657+ case pat @ Bind (nme.WILDCARD , body) =>
1658+ val name =
1659+ body match
1660+ case Typed (Ident (nme.WILDCARD ), tpt) if pat.mods.is(Given ) => inventGivenName(tpt)
1661+ case _ => UniqueName .fresh()
1662+ (cpy.Bind (pat)(name, body).withMods(pat.mods), Ident (name))
1663+ case Bind (name, _) => (pat, Ident (name))
16621664 case id : Ident if isVarPattern(id) && id.name != nme.WILDCARD => (id, id)
16631665 case Typed (id : Ident , _) if isVarPattern(id) && id.name != nme.WILDCARD => (pat, id)
16641666 case _ =>
16651667 val name = UniqueName .fresh()
16661668 (Bind (name, pat), Ident (name))
1667- }
16681669
16691670 /** Make a pattern filter:
16701671 * rhs.withFilter { case pat => true case _ => false }
0 commit comments