@@ -1347,7 +1347,7 @@ object desugar {
1347
1347
)).withSpan(tree.span)
1348
1348
end makePolyFunctionType
1349
1349
1350
- /** Invent a name for an anonympus given of type or template `impl`. */
1350
+ /** Invent a name for an anonymous given of type or template `impl`. */
1351
1351
def inventGivenName (impl : Tree )(using Context ): SimpleName =
1352
1352
val str = impl match
1353
1353
case impl : Template =>
@@ -2136,18 +2136,19 @@ object desugar {
2136
2136
* that refers to the bound variable for the pattern. Wildcard Binds are
2137
2137
* also replaced by Binds with fresh names.
2138
2138
*/
2139
- def makeIdPat (pat : Tree ): (Tree , Ident ) = pat match {
2140
- case bind @ Bind (name, pat1) =>
2141
- if name == nme.WILDCARD then
2142
- val name = UniqueName .fresh()
2143
- (cpy.Bind (pat)(name, pat1).withMods(bind.mods), Ident (name))
2144
- else (pat, Ident (name))
2139
+ def makeIdPat (pat : Tree ): (Tree , Ident ) = pat match
2140
+ case pat @ Bind (nme.WILDCARD , body) =>
2141
+ val name =
2142
+ body match
2143
+ case Typed (Ident (nme.WILDCARD ), tpt) if pat.mods.is(Given ) => inventGivenName(tpt)
2144
+ case _ => UniqueName .fresh()
2145
+ (cpy.Bind (pat)(name, body).withMods(pat.mods), Ident (name))
2146
+ case Bind (name, _) => (pat, Ident (name))
2145
2147
case id : Ident if isVarPattern(id) && id.name != nme.WILDCARD => (id, id)
2146
2148
case Typed (id : Ident , _) if isVarPattern(id) && id.name != nme.WILDCARD => (pat, id)
2147
2149
case _ =>
2148
2150
val name = UniqueName .fresh()
2149
2151
(Bind (name, pat), Ident (name))
2150
- }
2151
2152
2152
2153
/** Make a pattern filter:
2153
2154
* rhs.withFilter { case pat => true case _ => false }
0 commit comments