Skip to content

Commit da154fc

Browse files
committed
Simplify expressions per review
1 parent 6733771 commit da154fc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import annotation.threadUnsafe
3636

3737
import scala.util.control.NonFatal
3838
import dotty.tools.dotc.inlines.Inlines
39-
import dotty.tools.dotc.util.chaining.*
4039

4140
object Applications {
4241
import tpd.*
@@ -759,11 +758,12 @@ trait Applications extends Compatibility {
759758
else defaultArgument(normalizedFun, n, testOnly)
760759

761760
// a bug allowed empty parens to expand to implicit args: fail empty args for rewrite on migration
762-
def canSupplyImplicits = methodType.isImplicitMethod
763-
&& (applyKind == ApplyKind.Using || false.tap: _ =>
761+
def canSupplyImplicits =
762+
inline def failEmptyArgs: false =
764763
if Application.this.args.isEmpty then
765764
fail(MissingImplicitParameterInEmptyArguments(methodType.paramNames(n), methString))
766-
)
765+
false
766+
methodType.isImplicitMethod && (applyKind == ApplyKind.Using || failEmptyArgs)
767767

768768
if !defaultArg.isEmpty then
769769
defaultArg.tpe.widen match
@@ -1175,8 +1175,7 @@ trait Applications extends Compatibility {
11751175
if fun1.symbol.name == nme.apply && fun1.span.isSynthetic then
11761176
fun1 match
11771177
case Select(qualifier, _) =>
1178-
def mapMessage(dia: Diagnostic): Diagnostic =
1179-
dia match
1178+
failedState.reporter.mapBufferedMessages:
11801179
case dia: Diagnostic.Error =>
11811180
dia.msg match
11821181
case msg: TypeMismatch =>
@@ -1189,8 +1188,8 @@ trait Applications extends Compatibility {
11891188
case _ => dia
11901189
case msg => dia
11911190
case dia => dia
1192-
failedState.reporter.mapBufferedMessages(mapMessage)
11931191
case _ => ()
1192+
end if
11941193

11951194
def maybePatchBadParensForImplicit(failedState: TyperState)(using Context): Boolean =
11961195
def rewrite(): Unit =
@@ -1199,8 +1198,7 @@ trait Applications extends Compatibility {
11991198
else "" // f() -> f where fun1.span.end == tree.span.point
12001199
rewrites.Rewrites.patch(tree.span.withStart(fun1.span.end), replace)
12011200
var retry = false
1202-
failedState.reporter.mapBufferedMessages: dia =>
1203-
dia match
1201+
failedState.reporter.mapBufferedMessages:
12041202
case err: Diagnostic.Error =>
12051203
err.msg match
12061204
case msg: MissingImplicitParameterInEmptyArguments =>

0 commit comments

Comments
 (0)