Skip to content

Commit 0eb0423

Browse files
authored
Merge pull request #4146 from dotty-staging/fix/forwarders
Fix #4138: Do not emit forwarders for methods with expanded names
2 parents c52c8ab + 12e6ae3 commit 0eb0423

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import tpd._
3333
import scala.tools.asm
3434
import StdNames.{nme, str}
3535
import NameOps._
36-
import NameKinds.DefaultGetterName
36+
import NameKinds.{DefaultGetterName, ExpandedName}
3737
import dotty.tools.dotc.core
3838
import dotty.tools.dotc.core.Names.TypeName
3939

@@ -677,6 +677,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
677677
def isType: Boolean = sym.isType
678678
def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass
679679
def isConstructor: Boolean = toDenot(sym).isConstructor
680+
def isExpanded: Boolean = sym.name.is(ExpandedName)
680681
def isAnonymousFunction: Boolean = toDenot(sym).isAnonymousFunction
681682
def isMethod: Boolean = sym is Flags.Method
682683
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, Flags.Private | Flags.Protected)

tests/run/forwarder.check

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public static int Foo.hi()

tests/run/forwarder.scala

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Foo
2+
object Foo extends Bar
3+
4+
trait Bar {
5+
def hi: Int = 1
6+
private def foo: Int = 1
7+
8+
class Inner {
9+
val a = foo // Force foo to be expanded by ExpandPrivate
10+
}
11+
}
12+
13+
object Test {
14+
def main(args: Array[String]): Unit = {
15+
println(
16+
classOf[Foo].getMethods
17+
.filter(m => (m.getModifiers & java.lang.reflect.Modifier.STATIC) != 0)
18+
.mkString("\n"))
19+
}
20+
}

0 commit comments

Comments
 (0)