@@ -31,7 +31,7 @@ import TypeComparer.CompareResult
31
31
import util .Spans ._
32
32
import util .common ._
33
33
import util .{Property , SimpleIdentityMap , SrcPos }
34
- import Applications .{ExtMethodApply , productSelectorTypes , wrapDefs }
34
+ import Applications .{productSelectorTypes , wrapDefs }
35
35
36
36
import collection .mutable
37
37
import annotation .tailrec
@@ -551,41 +551,39 @@ class Typer extends Namer
551
551
then
552
552
report.error(StableIdentPattern (tree, pt), tree.srcPos)
553
553
554
- def typedSelect (tree0 : untpd.Select , pt : Type , qual : Tree )(using Context ): Tree = qual match
555
- case qual : ExtMethodApply =>
556
- qual.app
557
- case qual =>
558
- val selName = tree0.name
559
- val tree = cpy.Select (tree0)(qual, selName)
560
- def finalize (tp : Type ) = assignType(tree, tp)
561
- val superAccess = qual.isInstanceOf [Super ]
562
- val rawType = selectionType(tree, qual)
563
- val checkedType = accessibleType(rawType, superAccess)
564
- if checkedType.exists then
565
- val select = toNotNullTermRef(assignType(tree, checkedType), pt)
566
- if selName.isTypeName then checkStable(qual.tpe, qual.srcPos, " type prefix" )
567
- checkStableIdentPattern(select, pt)
568
- ConstFold (select)
569
- else if couldInstantiateTypeVar(qual.tpe.widen) then
570
- // try again with more defined qualifier type
571
- typedSelect(tree, pt, qual)
572
- else
573
- val tree1 = tryExtensionOrConversion(
574
- tree, pt, IgnoredProto (pt), qual, ctx.typerState.ownedVars, this , privateOK = true )
575
- if ! tree1.isEmpty then
576
- tree1
577
- else if qual.tpe.derivesFrom(defn.DynamicClass )
578
- && selName.isTermName && ! isDynamicExpansion(tree)
579
- then
580
- if pt.isInstanceOf [FunOrPolyProto ] || pt == AssignProto then finalize(TryDynamicCallType )
581
- else typedDynamicSelect(tree0, Nil , pt)
554
+ def typedSelect (tree0 : untpd.Select , pt : Type , qual : Tree )(using Context ): Tree =
555
+ val selName = tree0.name
556
+ val tree = cpy.Select (tree0)(qual, selName)
557
+ val superAccess = qual.isInstanceOf [Super ]
558
+ val rawType = selectionType(tree, qual)
559
+ val checkedType = accessibleType(rawType, superAccess)
560
+ if checkedType.exists then
561
+ val select = toNotNullTermRef(assignType(tree, checkedType), pt)
562
+ if selName.isTypeName then checkStable(qual.tpe, qual.srcPos, " type prefix" )
563
+ checkStableIdentPattern(select, pt)
564
+ ConstFold (select)
565
+ else if couldInstantiateTypeVar(qual.tpe.widen) then
566
+ // try again with more defined qualifier type
567
+ typedSelect(tree, pt, qual)
568
+ else
569
+ val tree1 = tryExtensionOrConversion(
570
+ tree, pt, IgnoredProto (pt), qual, ctx.typerState.ownedVars, this , privateOK = true )
571
+ if ! tree1.isEmpty then
572
+ tree1
573
+ else if qual.tpe.derivesFrom(defn.DynamicClass )
574
+ && selName.isTermName && ! isDynamicExpansion(tree)
575
+ then
576
+ if pt.isInstanceOf [FunOrPolyProto ] || pt == AssignProto then
577
+ assignType(tree, TryDynamicCallType )
582
578
else
583
- finalize(
584
- rawType match
585
- case rawType : NamedType =>
586
- inaccessibleErrorType(rawType, superAccess, tree.srcPos)
587
- case _ =>
588
- notAMemberErrorType(tree, qual))
579
+ typedDynamicSelect(tree0, Nil , pt)
580
+ else
581
+ assignType(tree,
582
+ rawType match
583
+ case rawType : NamedType =>
584
+ inaccessibleErrorType(rawType, superAccess, tree.srcPos)
585
+ case _ =>
586
+ notAMemberErrorType(tree, qual))
589
587
end typedSelect
590
588
591
589
def typedSelect (tree : untpd.Select , pt : Type )(using Context ): Tree = {
@@ -681,7 +679,7 @@ class Typer extends Namer
681
679
case Floating => defn.FromDigits_FloatingClass
682
680
}
683
681
inferImplicit(fromDigitsCls.typeRef.appliedTo(target), EmptyTree , tree.span) match {
684
- case SearchSuccess (arg, _, _) =>
682
+ case SearchSuccess (arg, _, _, _ ) =>
685
683
val fromDigits = untpd.Select (untpd.TypedSplice (arg), nme.fromDigits).withSpan(tree.span)
686
684
val firstArg = Literal (Constant (digits))
687
685
val otherArgs = tree.kind match {
@@ -842,7 +840,7 @@ class Typer extends Namer
842
840
withoutMode(Mode .Pattern )(
843
841
inferImplicit(tpe, EmptyTree , tree.tpt.span)
844
842
) match
845
- case SearchSuccess (clsTag, _, _) =>
843
+ case SearchSuccess (clsTag, _, _, _ ) =>
846
844
withMode(Mode .InTypeTest ) {
847
845
Some (typed(untpd.Apply (untpd.TypedSplice (clsTag), untpd.TypedSplice (tree.expr)), pt))
848
846
}
@@ -2627,9 +2625,7 @@ class Typer extends Namer
2627
2625
2628
2626
/** Interpolate and simplify the type of the given tree. */
2629
2627
protected def simplify (tree : Tree , pt : Type , locked : TypeVars )(using Context ): tree.type =
2630
- if ! tree.denot.isOverloaded // for overloaded trees: resolve overloading before simplifying
2631
- && ! tree.isInstanceOf [Applications .AppProxy ] // don't interpolate in the middle of an extension method application
2632
- then
2628
+ if ! tree.denot.isOverloaded then // for overloaded trees: resolve overloading before simplifying
2633
2629
if ! tree.tpe.widen.isInstanceOf [MethodOrPoly ] // wait with simplifying until method is fully applied
2634
2630
|| tree.isDef // ... unless tree is a definition
2635
2631
then
@@ -2959,12 +2955,12 @@ class Typer extends Namer
2959
2955
trace(i " try insert impl on qualifier $tree $pt" ) {
2960
2956
val selProto = selectionProto
2961
2957
inferView(qual, selProto) match
2962
- case SearchSuccess (found : ExtMethodApply , _, _) =>
2963
- return found.app // nothing to check or adapt for extension method applications
2964
- case SearchSuccess (found, _, _) =>
2965
- checkImplicitConversionUseOK(found)
2966
- val qual1 = withoutMode(Mode .ImplicitsEnabled )(adapt(found, selProto, locked))
2967
- return typedSelect(tree, pt, qual1)
2958
+ case SearchSuccess (found, _, _, isExtension ) =>
2959
+ if isExtension then return found
2960
+ else
2961
+ checkImplicitConversionUseOK(found)
2962
+ val qual1 = withoutMode(Mode .ImplicitsEnabled )(adapt(found, selProto, locked))
2963
+ return typedSelect(tree, pt, qual1)
2968
2964
case failure : SearchFailure =>
2969
2965
if failure.isAmbiguous then
2970
2966
return (
@@ -3590,11 +3586,11 @@ class Typer extends Namer
3590
3586
else if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.tpe.isValueType then
3591
3587
checkConversionsSpecific(wtp, pt, tree.srcPos)
3592
3588
inferView(tree, pt) match {
3593
- case SearchSuccess (found : ExtMethodApply , _, _) =>
3594
- found // nothing to check or adapt for extension method applications
3595
- case SearchSuccess (found, _, _) =>
3596
- checkImplicitConversionUseOK(found)
3597
- withoutMode(Mode .ImplicitsEnabled )(readapt(found))
3589
+ case SearchSuccess (found, _, _, isExtension ) =>
3590
+ if isExtension then found
3591
+ else
3592
+ checkImplicitConversionUseOK(found)
3593
+ withoutMode(Mode .ImplicitsEnabled )(readapt(found))
3598
3594
case failure : SearchFailure =>
3599
3595
if (pt.isInstanceOf [ProtoType ] && ! failure.isAmbiguous) then
3600
3596
// don't report the failure but return the tree unchanged. This
@@ -3686,8 +3682,6 @@ class Typer extends Namer
3686
3682
else adaptToArgs(wtp, pt)
3687
3683
case pt : PolyProto =>
3688
3684
tryInsertApplyOrImplicit(tree, pt, locked)(tree) // error will be reported in typedTypeApply
3689
- case pt : SelectionProto if tree.isInstanceOf [ExtMethodApply ] =>
3690
- tree
3691
3685
case _ =>
3692
3686
if (ctx.mode is Mode .Type ) adaptType(tree.tpe)
3693
3687
else adaptNoArgs(wtp)
0 commit comments