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