Skip to content

Commit 21e3482

Browse files
committed
Show undesired anon apply rewrite
1 parent cfa8e9f commit 21e3482

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,8 @@ trait Applications extends Compatibility {
12501250
}
12511251
else
12521252
tryEither(simpleApply(fun1, proto)): (failedVal, failedState) =>
1253-
// a bug allowed empty parens to expand to implicit args, offer rewrite only on migration, then retry
1253+
// a bug allowed empty parens to expand to implicit args, offer rewrite only on migration,
1254+
// then retry with using to emulate the bug since rewrites are ignored on error.
12541255
if proto.args.isEmpty && maybePatchBadParensForImplicit(failedState) then
12551256
tryWithUsing(fun1, proto).getOrElse:
12561257
failedState.commit()

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ object ProtoTypes {
617617
else new FunProto(args, resType)(typer, applyKind, state)(using newCtx)
618618

619619
def withApplyKind(applyKind: ApplyKind) =
620-
new FunProto(args, resType)(typer, applyKind, state)
620+
if applyKind == this.applyKind then this
621+
else new FunProto(args, resType)(typer, applyKind, state)
621622
}
622623

623624
/** A prototype for expressions that appear in function position

tests/rewrites/i22792.check

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
trait Permit
44
class Foo:
55
def run(implicit ev: Permit): Unit = ???
6+
def apply(implicit ev: Permit): Unit = ???
67

78
given Permit = ???
89
@main def Test = new Foo().run
10+
11+
def otherSyntax = Foo()

tests/rewrites/i22792.scala

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
trait Permit
44
class Foo:
55
def run(implicit ev: Permit): Unit = ???
6+
def apply(implicit ev: Permit): Unit = ???
67

78
given Permit = ???
89
@main def Test = new Foo().run()
10+
11+
def otherSyntax = Foo()()

0 commit comments

Comments
 (0)