Skip to content

Commit 542ca19

Browse files
committed
Simplify expressions per review
1 parent f7faa9c commit 542ca19

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import scala.annotation.tailrec
3838
import scala.util.control.NonFatal
3939
import dotty.tools.dotc.cc.isRetains
4040
import dotty.tools.dotc.inlines.Inlines
41-
import dotty.tools.dotc.util.chaining.*
4241

4342
object Applications {
4443
import tpd.*
@@ -767,11 +766,12 @@ trait Applications extends Compatibility {
767766
else defaultArgument(normalizedFun, n, testOnly)
768767

769768
// a bug allowed empty parens to expand to implicit args: fail empty args for rewrite on migration
770-
def canSupplyImplicits = methodType.isImplicitMethod
771-
&& (applyKind == ApplyKind.Using || false.tap: _ =>
769+
def canSupplyImplicits =
770+
inline def failEmptyArgs: false =
772771
if Application.this.args.isEmpty then
773772
fail(MissingImplicitParameterInEmptyArguments(methodType.paramNames(n), methString))
774-
)
773+
false
774+
methodType.isImplicitMethod && (applyKind == ApplyKind.Using || failEmptyArgs)
775775

776776
if !defaultArg.isEmpty then
777777
defaultArg.tpe.widen match
@@ -1183,8 +1183,7 @@ trait Applications extends Compatibility {
11831183
if fun1.symbol.name == nme.apply && fun1.span.isSynthetic then
11841184
fun1 match
11851185
case Select(qualifier, _) =>
1186-
def mapMessage(dia: Diagnostic): Diagnostic =
1187-
dia match
1186+
failedState.reporter.mapBufferedMessages:
11881187
case dia: Diagnostic.Error =>
11891188
dia.msg match
11901189
case msg: TypeMismatch =>
@@ -1197,8 +1196,8 @@ trait Applications extends Compatibility {
11971196
case _ => dia
11981197
case msg => dia
11991198
case dia => dia
1200-
failedState.reporter.mapBufferedMessages(mapMessage)
12011199
case _ => ()
1200+
end if
12021201

12031202
def maybePatchBadParensForImplicit(failedState: TyperState)(using Context): Boolean =
12041203
def rewrite(): Unit =
@@ -1207,8 +1206,7 @@ trait Applications extends Compatibility {
12071206
else "" // f() -> f where fun1.span.end == tree.span.point
12081207
rewrites.Rewrites.patch(tree.span.withStart(fun1.span.end), replace)
12091208
var retry = false
1210-
failedState.reporter.mapBufferedMessages: dia =>
1211-
dia match
1209+
failedState.reporter.mapBufferedMessages:
12121210
case err: Diagnostic.Error =>
12131211
err.msg match
12141212
case msg: MissingImplicitParameterInEmptyArguments =>

0 commit comments

Comments
 (0)