@@ -570,19 +570,10 @@ class Typer extends Namer
570
570
// try again with more defined qualifier type
571
571
typedSelect(tree, pt, qual)
572
572
else
573
- val tree1 =
574
- if newScheme then
575
- if dia then println(i " tryec $qual . $selName\n , pt = $pt\n , mbrProto = ${IgnoredProto (pt)}\n , compat = ${this .getClass}, locked = ${ctx.typerState.ownedVars.toList}%, %? " )
576
- tryExtensionOrConversion(
577
- tree, pt, IgnoredProto (pt), qual, ctx.typerState.ownedVars, this , privateOK = true )
578
- else EmptyTree
579
- if newScheme && dia then
580
- println(i " tryec $qual . $selName\n , pt = $pt\n , mbrProto = ${IgnoredProto (pt)}\n , compat = ${this .getClass}, locked = ${ctx.typerState.ownedVars.toList}%, % = $tree1" )
573
+ val tree1 = tryExtensionOrConversion(
574
+ tree, pt, IgnoredProto (pt), qual, ctx.typerState.ownedVars, this , privateOK = true )
581
575
if ! tree1.isEmpty then
582
576
tree1
583
- // else if couldInstantiateTypeVar(qual.tpe.widen) then
584
- // // try again with more defined qualifier type
585
- // typedSelect(tree, pt, qual)
586
577
else if qual.tpe.derivesFrom(defn.DynamicClass )
587
578
&& selName.isTermName && ! isDynamicExpansion(tree)
588
579
then
@@ -2967,7 +2958,6 @@ class Typer extends Namer
2967
2958
if ctx.mode.is(Mode .ImplicitsEnabled ) && qual.tpe.isValueType then
2968
2959
trace(i " try insert impl on qualifier $tree $pt" ) {
2969
2960
val selProto = selectionProto
2970
- // println(i"try conv $tree, $qual, ${qual.tpe}, $selProto, ${inferView(qual, selProto)}")
2971
2961
inferView(qual, selProto) match
2972
2962
case SearchSuccess (found : ExtMethodApply , _, _) =>
2973
2963
return found.app // nothing to check or adapt for extension method applications
@@ -3591,50 +3581,14 @@ class Typer extends Namer
3591
3581
case _ => ;
3592
3582
}
3593
3583
3594
- pt match
3595
- case selProto @ SelectionProto (selName : TermName , mbrType, _, _) =>
3596
- if newScheme then return tree
3597
- else if dia then println(i " tryec $tree, $tree . $selName\n , pt = ${mbrType.deepenProto}\n , mbrProto = $mbrType\n , compat = ${selProto.compat.getClass}, locked = ${locked.toList}%, %, privateOK = ${selProto.privateOK}" )
3598
- case _ =>
3599
-
3600
- // try an extension method in scope
3601
- pt match {
3602
- case selProto @ SelectionProto (selName : TermName , mbrType, _, _) =>
3603
-
3604
- def tryExtension (using Context ): Tree =
3605
- findRef(selName, WildcardType , ExtensionMethod , EmptyFlags , tree.srcPos) match
3606
- case ref : TermRef =>
3607
- extMethodApply(untpd.ref(ref).withSpan(tree.span), tree, mbrType)
3608
- case _ =>
3609
- EmptyTree
3610
-
3611
- try
3612
- val nestedCtx = ctx.fresh.setNewTyperState()
3613
- val app = tryExtension(using nestedCtx)
3614
- if ! app.isEmpty && ! nestedCtx.reporter.hasErrors then
3615
- nestedCtx.typerState.commit()
3616
- return ExtMethodApply (app)
3617
- else
3618
- for err <- nestedCtx.reporter.allErrors.take(1 ) do
3619
- rememberSearchFailure(tree,
3620
- SearchFailure (app.withType(FailedExtension (app, pt, err.msg))))
3621
- catch case ex : TypeError =>
3622
- rememberSearchFailure(tree,
3623
- SearchFailure (tree.withType(NestedFailure (ex.toMessage, pt))))
3624
- case _ =>
3625
- }
3626
-
3627
- // try an implicit conversion
3628
3584
def recover (failure : SearchFailureType ) =
3629
3585
if canDefineFurther(wtp) then readapt(tree)
3630
3586
else err.typeMismatch(tree, pt, failure)
3631
3587
3632
- if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.typeOpt.isValueType then
3633
- if pt.isRef(defn.AnyValClass , skipRefined = false )
3634
- || pt.isRef(defn.ObjectClass , skipRefined = false )
3635
- then
3636
- report.error(em " the result of an implicit conversion must be more specific than $pt" , tree.srcPos)
3637
- // println(i"try view $tree, ${tree.tpe}, $pt, ${inferView(tree, pt)}")
3588
+ if pt.isInstanceOf [SelectionProto ] then
3589
+ tree // adaptations for selections are handled in typedSelect
3590
+ else if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.tpe.isValueType then
3591
+ checkConversionsSpecific(wtp, pt, tree.srcPos)
3638
3592
inferView(tree, pt) match {
3639
3593
case SearchSuccess (found : ExtMethodApply , _, _) =>
3640
3594
found // nothing to check or adapt for extension method applications
0 commit comments