@@ -3222,9 +3222,6 @@ class Typer extends Namer
3222
3222
* Examples for these cases are found in run/implicitFuns.scala and neg/i2006.scala.
3223
3223
*/
3224
3224
def adaptNoArgsUnappliedMethod (wtp : MethodType , functionExpected : Boolean , arity : Int ): Tree = {
3225
- def isExpandableApply =
3226
- defn.isContextFunctionClass(tree.symbol.maybeOwner) && functionExpected
3227
-
3228
3225
/** Is reference to this symbol `f` automatically expanded to `f()`? */
3229
3226
def isAutoApplied (sym : Symbol ): Boolean =
3230
3227
sym.isConstructor
@@ -3241,7 +3238,7 @@ class Typer extends Namer
3241
3238
! tree.symbol.isConstructor &&
3242
3239
! tree.symbol.isAllOf(InlineMethod ) &&
3243
3240
! ctx.mode.is(Mode .Pattern ) &&
3244
- ! (isSyntheticApply(tree) && ! isExpandableApply )) {
3241
+ ! (isSyntheticApply(tree) && ! functionExpected )) {
3245
3242
if (! defn.isFunctionType(pt))
3246
3243
pt match {
3247
3244
case SAMType (_) if ! pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot ) =>
@@ -3266,9 +3263,18 @@ class Typer extends Namer
3266
3263
defn.isContextFunctionClass(underlying.classSymbol)
3267
3264
}
3268
3265
3269
- def adaptNoArgsOther (wtp : Type ): Tree = {
3270
- if (isContextFunctionRef(wtp) &&
3271
- ! untpd.isContextualClosure(tree) &&
3266
+ def adaptNoArgsOther (wtp : Type , functionExpected : Boolean ): Tree = {
3267
+ val implicitFun = isContextFunctionRef(wtp) && ! untpd.isContextualClosure(tree)
3268
+ def caseCompanion =
3269
+ functionExpected &&
3270
+ tree.symbol.is(Module ) &&
3271
+ tree.symbol.companionClass.is(Case ) &&
3272
+ ! tree.tpe.widen.classSymbol.asClass.classParents.exists(defn.isFunctionType(_)) && {
3273
+ report.warning(" The method `apply` is inserted. The auto insertion will be deprecated, please write `" + tree.show + " .apply` explicitly." , tree.sourcePos)
3274
+ true
3275
+ }
3276
+
3277
+ if ((implicitFun || caseCompanion) &&
3272
3278
! isApplyProto(pt) &&
3273
3279
pt != AssignProto &&
3274
3280
! ctx.mode.is(Mode .Pattern ) &&
@@ -3390,7 +3396,7 @@ class Typer extends Namer
3390
3396
}
3391
3397
adaptNoArgsUnappliedMethod(wtp, funExpected, arity)
3392
3398
case _ =>
3393
- adaptNoArgsOther(wtp)
3399
+ adaptNoArgsOther(wtp, functionExpected )
3394
3400
}
3395
3401
}
3396
3402
0 commit comments