@@ -3114,12 +3114,9 @@ class Typer extends Namer
3114
3114
def readapt (tree : Tree , shouldTryGadtHealing : Boolean = tryGadtHealing)(using Context ) = adapt(tree, pt, locked, shouldTryGadtHealing)
3115
3115
def readaptSimplified (tree : Tree )(using Context ) = readapt(simplify(tree, pt, locked))
3116
3116
3117
- def missingArgs (mt : MethodType ) = {
3118
- val meth = err.exprStr(methPart(tree))
3119
- if (mt.paramNames.length == 0 ) report.error(MissingEmptyArgumentList (meth), tree.srcPos)
3120
- else report.error(em " missing arguments for $meth" , tree.srcPos)
3117
+ def missingArgs (mt : MethodType ) =
3118
+ ErrorReporting .missingArgs(tree, mt)
3121
3119
tree.withType(mt.resultType)
3122
- }
3123
3120
3124
3121
def adaptOverloaded (ref : TermRef ) = {
3125
3122
val altDenots =
@@ -3413,19 +3410,19 @@ class Typer extends Namer
3413
3410
// - we reference a typelevel method
3414
3411
// - we are in a pattern
3415
3412
// - the current tree is a synthetic apply which is not expandable (eta-expasion would simply undo that)
3416
- if (arity >= 0 &&
3417
- ! tree.symbol.isConstructor &&
3418
- ! tree.symbol.isAllOf(InlineMethod ) &&
3419
- ! ctx.mode.is(Mode .Pattern ) &&
3420
- ! (isSyntheticApply(tree) && ! functionExpected)) {
3413
+ if arity >= 0
3414
+ && ! tree.symbol.isConstructor
3415
+ && ! tree.symbol.isAllOf(InlineMethod )
3416
+ && ! ctx.mode.is(Mode .Pattern )
3417
+ && ! (isSyntheticApply(tree) && ! functionExpected)
3418
+ then
3421
3419
if (! defn.isFunctionType(pt))
3422
3420
pt match {
3423
3421
case SAMType (_) if ! pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot ) =>
3424
3422
report.warning(ex " ${tree.symbol} is eta-expanded even though $pt does not have the @FunctionalInterface annotation. " , tree.srcPos)
3425
3423
case _ =>
3426
3424
}
3427
3425
simplify(typed(etaExpand(tree, wtp, arity), pt), pt, locked)
3428
- }
3429
3426
else if (wtp.paramInfos.isEmpty && isAutoApplied(tree.symbol))
3430
3427
readaptSimplified(tpd.Apply (tree, Nil ))
3431
3428
else if (wtp.isImplicitMethod)
@@ -3832,8 +3829,9 @@ class Typer extends Namer
3832
3829
&& ! tree.isInstanceOf [Inlined ]
3833
3830
&& isPureExpr(tree)
3834
3831
&& ! isSelfOrSuperConstrCall(tree)
3835
- then
3836
- report.warning(PureExpressionInStatementPosition (original, exprOwner), original.srcPos)
3832
+ then tree match
3833
+ case closureDef(_) => missingArgs(tree, tree.tpe.widen)
3834
+ case _ => report.warning(PureExpressionInStatementPosition (original, exprOwner), original.srcPos)
3837
3835
3838
3836
/** Types the body Scala 2 macro declaration `def f = macro <body>` */
3839
3837
private def typedScala2MacroBody (call : untpd.Tree )(using Context ): Tree =
0 commit comments