@@ -3114,12 +3114,9 @@ class Typer extends Namer
31143114 def readapt (tree : Tree , shouldTryGadtHealing : Boolean = tryGadtHealing)(using Context ) = adapt(tree, pt, locked, shouldTryGadtHealing)
31153115 def readaptSimplified (tree : Tree )(using Context ) = readapt(simplify(tree, pt, locked))
31163116
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)
31213119 tree.withType(mt.resultType)
3122- }
31233120
31243121 def adaptOverloaded (ref : TermRef ) = {
31253122 val altDenots =
@@ -3413,19 +3410,19 @@ class Typer extends Namer
34133410 // - we reference a typelevel method
34143411 // - we are in a pattern
34153412 // - 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
34213419 if (! defn.isFunctionType(pt))
34223420 pt match {
34233421 case SAMType (_) if ! pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot ) =>
34243422 report.warning(ex " ${tree.symbol} is eta-expanded even though $pt does not have the @FunctionalInterface annotation. " , tree.srcPos)
34253423 case _ =>
34263424 }
34273425 simplify(typed(etaExpand(tree, wtp, arity), pt), pt, locked)
3428- }
34293426 else if (wtp.paramInfos.isEmpty && isAutoApplied(tree.symbol))
34303427 readaptSimplified(tpd.Apply (tree, Nil ))
34313428 else if (wtp.isImplicitMethod)
@@ -3832,8 +3829,9 @@ class Typer extends Namer
38323829 && ! tree.isInstanceOf [Inlined ]
38333830 && isPureExpr(tree)
38343831 && ! 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)
38373835
38383836 /** Types the body Scala 2 macro declaration `def f = macro <body>` */
38393837 private def typedScala2MacroBody (call : untpd.Tree )(using Context ): Tree =
0 commit comments