@@ -1203,16 +1203,16 @@ object Objects:
1203
1203
// TODO: handle unapplySeq
1204
1204
Bottom
1205
1205
1206
- case UnApply (fun, _ , pats) =>
1206
+ case UnApply (fun, implicits , pats) =>
1207
1207
val fun1 = funPart(fun)
1208
1208
val funRef = fun1.tpe.asInstanceOf [TermRef ]
1209
1209
if fun.symbol.name == nme.unapplySeq then
1210
1210
// TODO: handle unapplySeq
1211
1211
()
1212
1212
else
1213
1213
val receiver = evalType(funRef.prefix, thisV, klass)
1214
- // TODO: apply implicits
1215
- val unapplyRes = call(receiver, funRef.symbol, TraceValue (scrutinee, summon[Trace ]) :: Nil , funRef.prefix, superType = NoType , needResolve = true )
1214
+ val implicitValues = evalArgs( implicits.map( Arg .apply), thisV, klass)
1215
+ val unapplyRes = call(receiver, funRef.symbol, TraceValue (scrutinee, summon[Trace ]) :: implicitValues , funRef.prefix, superType = NoType , needResolve = true )
1216
1216
// distribute unapply to patterns
1217
1217
val unapplyResTp = funRef.widen.finalResultType
1218
1218
if isProductMatch(unapplyResTp, pats.length) then
@@ -1227,14 +1227,16 @@ object Objects:
1227
1227
()
1228
1228
else
1229
1229
// Get match
1230
- val getMember = unapplyResTp.member(nme.get).suchThat(_.info.isParameterless)
1231
- // TODO: call isEmpty as well
1232
- val getRes = call(unapplyRes, getMember.symbol, Nil , unapplyResTp, superType = NoType , needResolve = true )
1230
+ val isEmptyDenot = unapplyResTp.member(nme.isEmpty).suchThat(_.info.isParameterless)
1231
+ call(unapplyRes, isEmptyDenot.symbol, Nil , unapplyResTp, superType = NoType , needResolve = true )
1232
+
1233
+ val getDenot = unapplyResTp.member(nme.get).suchThat(_.info.isParameterless)
1234
+ val getRes = call(unapplyRes, getDenot.symbol, Nil , unapplyResTp, superType = NoType , needResolve = true )
1233
1235
if pats.length == 1 then
1234
1236
// single match
1235
1237
evalPattern(getRes, pats.head)
1236
1238
else
1237
- val getResTp = getMember .info.widen .finalResultType
1239
+ val getResTp = getDenot .info.finalResultType
1238
1240
val selectors = productSelectors(getResTp).take(pats.length)
1239
1241
selectors.zip(pats).map { (sel, pat) =>
1240
1242
val selectRes = call(unapplyRes, sel, Nil , unapplyResTp, superType = NoType , needResolve = true )
@@ -1245,6 +1247,9 @@ object Objects:
1245
1247
end if
1246
1248
scrutinee
1247
1249
1250
+ case Ident (nme.WILDCARD ) =>
1251
+ scrutinee
1252
+
1248
1253
case Typed (pat, _) =>
1249
1254
evalPattern(scrutinee, pat)
1250
1255
0 commit comments