Skip to content

Commit 740bd42

Browse files
committed
Drop Override flag for non-overriding direct methods
Also, integrate Jason's test case with the conditional.
1 parent a6ae1a7 commit 740bd42

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,14 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
8989
}
9090

9191
/** A new `m$direct` method to accompany the given method `m` */
92-
private def newDirectMethod(sym: Symbol)(implicit ctx: Context): Symbol =
93-
sym.copy(
92+
private def newDirectMethod(sym: Symbol)(implicit ctx: Context): Symbol = {
93+
val direct = sym.copy(
9494
name = sym.name.directName,
9595
flags = sym.flags | Synthetic,
9696
info = directInfo(sym.info))
97+
if (direct.allOverriddenSymbols.isEmpty) direct.resetFlag(Override)
98+
direct
99+
}
97100

98101
/** The direct method `m$direct` that accompanies the given method `m`.
99102
* Create one if it does not exist already.

tests/run/implicitFuns.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Test {
2-
def main(args: Array[String]) = {
2+
def main(args: Array[String]): Unit = {
33

44
implicit val world: String = "world!"
55

@@ -53,6 +53,10 @@ object Test {
5353
val c1: Int = c
5454

5555
Contextual.main(args)
56+
57+
def foo(s: String): Stringly[Int] = 42
58+
59+
(if ("".isEmpty) foo("") else foo("")).apply("")
5660
}
5761
}
5862

0 commit comments

Comments
 (0)