Skip to content

Commit b0b6f4d

Browse files
committed
Show undesired anon apply rewrite
1 parent 0957925 commit b0b6f4d

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ trait Applications extends Compatibility {
12581258
}
12591259
else
12601260
tryEither(simpleApply(fun1, proto)): (failedVal, failedState) =>
1261-
// a bug allowed empty parens to expand to implicit args, offer rewrite only on migration, then retry
1261+
// a bug allowed empty parens to expand to implicit args, offer rewrite only on migration,
1262+
// then retry with using to emulate the bug since rewrites are ignored on error.
12621263
if proto.args.isEmpty && maybePatchBadParensForImplicit(failedState) then
12631264
tryWithUsing(fun1, proto).getOrElse:
12641265
failedState.commit()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ object ProtoTypes {
625625
else new FunProto(args, resType)(typer, applyKind, state)(using newCtx)
626626

627627
def withApplyKind(applyKind: ApplyKind) =
628-
new FunProto(args, resType)(typer, applyKind, state)
628+
if applyKind == this.applyKind then this
629+
else new FunProto(args, resType)(typer, applyKind, state)
629630
}
630631

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

tests/rewrites/i22792.check

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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)