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