@@ -1345,7 +1345,7 @@ object desugar {
1345
1345
)).withSpan(tree.span)
1346
1346
end makePolyFunctionType
1347
1347
1348
- /** Invent a name for an anonympus given of type or template `impl`. */
1348
+ /** Invent a name for an anonymous given of type or template `impl`. */
1349
1349
def inventGivenName (impl : Tree )(using Context ): SimpleName =
1350
1350
val str = impl match
1351
1351
case impl : Template =>
@@ -2067,18 +2067,19 @@ object desugar {
2067
2067
* that refers to the bound variable for the pattern. Wildcard Binds are
2068
2068
* also replaced by Binds with fresh names.
2069
2069
*/
2070
- def makeIdPat (pat : Tree ): (Tree , Ident ) = pat match {
2071
- case bind @ Bind (name, pat1) =>
2072
- if name == nme.WILDCARD then
2073
- val name = UniqueName .fresh()
2074
- (cpy.Bind (pat)(name, pat1).withMods(bind.mods), Ident (name))
2075
- else (pat, Ident (name))
2070
+ def makeIdPat (pat : Tree ): (Tree , Ident ) = pat match
2071
+ case pat @ Bind (nme.WILDCARD , body) =>
2072
+ val name =
2073
+ body match
2074
+ case Typed (Ident (nme.WILDCARD ), tpt) if pat.mods.is(Given ) => inventGivenName(tpt)
2075
+ case _ => UniqueName .fresh()
2076
+ (cpy.Bind (pat)(name, body).withMods(pat.mods), Ident (name))
2077
+ case Bind (name, _) => (pat, Ident (name))
2076
2078
case id : Ident if isVarPattern(id) && id.name != nme.WILDCARD => (id, id)
2077
2079
case Typed (id : Ident , _) if isVarPattern(id) && id.name != nme.WILDCARD => (pat, id)
2078
2080
case _ =>
2079
2081
val name = UniqueName .fresh()
2080
2082
(Bind (name, pat), Ident (name))
2081
- }
2082
2083
2083
2084
/** Make a pattern filter:
2084
2085
* rhs.withFilter { case pat => true case _ => false }
0 commit comments