@@ -2676,9 +2676,6 @@ class Typer extends Namer
2676
2676
* Examples for these cases are found in run/implicitFuns.scala and neg/i2006.scala.
2677
2677
*/
2678
2678
def adaptNoArgsUnappliedMethod (wtp : MethodType , functionExpected : Boolean , arity : Int ): Tree = {
2679
- def isExpandableApply =
2680
- defn.isImplicitFunctionClass(tree.symbol.maybeOwner) && functionExpected
2681
-
2682
2679
/** Is reference to this symbol `f` automatically expanded to `f()`? */
2683
2680
def isAutoApplied (sym : Symbol ): Boolean =
2684
2681
sym.isConstructor ||
@@ -2695,7 +2692,7 @@ class Typer extends Namer
2695
2692
! tree.symbol.isConstructor &&
2696
2693
! tree.symbol.isAllOf(InlineMethod ) &&
2697
2694
! ctx.mode.is(Mode .Pattern ) &&
2698
- ! (isSyntheticApply(tree) && ! isExpandableApply )) {
2695
+ ! (isSyntheticApply(tree) && ! functionExpected )) {
2699
2696
if (! defn.isFunctionType(pt))
2700
2697
pt match {
2701
2698
case SAMType (_) if ! pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot ) =>
@@ -2720,10 +2717,11 @@ class Typer extends Namer
2720
2717
defn.isImplicitFunctionClass(underlying.classSymbol)
2721
2718
}
2722
2719
2723
- def adaptNoArgsOther (wtp : Type ): Tree = {
2720
+ def adaptNoArgsOther (wtp : Type , functionExpected : Boolean ): Tree = {
2724
2721
ctx.typeComparer.GADTused = false
2725
- if (isImplicitFunctionRef(wtp) &&
2726
- ! untpd.isContextualClosure(tree) &&
2722
+ val implicitFun = isImplicitFunctionRef(wtp) && ! untpd.isContextualClosure(tree)
2723
+ def caseCompanion = functionExpected && tree.symbol.is(Module ) && tree.symbol.companionClass.is(Case )
2724
+ if ((implicitFun || caseCompanion) &&
2727
2725
! isApplyProto(pt) &&
2728
2726
pt != AssignProto &&
2729
2727
! ctx.mode.is(Mode .Pattern ) &&
@@ -2839,7 +2837,7 @@ class Typer extends Namer
2839
2837
}
2840
2838
adaptNoArgsUnappliedMethod(wtp, funExpected, arity)
2841
2839
case _ =>
2842
- adaptNoArgsOther(wtp)
2840
+ adaptNoArgsOther(wtp, functionExpected )
2843
2841
}
2844
2842
}
2845
2843
0 commit comments