@@ -240,17 +240,21 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
240
240
val isDefined = extractorMemberType(prev.tpe, nme.isDefined)
241
241
242
242
if ((isDefined isRef defn.BooleanClass ) && getTp.exists) {
243
- val tmpSym = freshSym(prev.pos, prev.tpe, " o" )
244
- val prevValue = ref(tmpSym).select(" get" .toTermName).ensureApplied
243
+ // isDefined maybe overloaded
244
+ val getDenot = prev.tpe.member(nme.get).suchThat(_.info.isParameterless)
245
+ val isDefinedDenot = prev.tpe.member(nme.isDefined).suchThat(_.info.isParameterless)
245
246
246
- Block (
247
- List (ValDef (tmpSym, prev)),
248
- // must be isEmpty and get as we don't control the target of the call (prev is an extractor call)
249
- ifThenElseZero(
250
- ref(tmpSym).select(nme.isDefined),
251
- Block (List (ValDef (b.asTerm, prevValue)), next)
252
- )
247
+ val tmpSym = freshSym(prev.pos, prev.tpe, " o" )
248
+ val prevValue = ref(tmpSym).select(getDenot.namedType).ensureApplied
249
+
250
+ Block (
251
+ List (ValDef (tmpSym, prev)),
252
+ // must be isEmpty and get as we don't control the target of the call (prev is an extractor call)
253
+ ifThenElseZero(
254
+ ref(tmpSym).select(isDefinedDenot.namedType),
255
+ Block (List (ValDef (b.asTerm, prevValue)), next)
253
256
)
257
+ )
254
258
} else {
255
259
assert(defn.isProductSubType(prev.tpe))
256
260
val nullCheck : Tree = prev.select(defn.Object_ne ).appliedTo(Literal (Constant (null )))
0 commit comments