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