Skip to content

Fix #4138: Do not emit forwarders for methods with expanded names #4146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import tpd._
import scala.tools.asm
import StdNames.{nme, str}
import NameOps._
import NameKinds.DefaultGetterName
import NameKinds.{DefaultGetterName, ExpandedName}
import dotty.tools.dotc.core
import dotty.tools.dotc.core.Names.TypeName

Expand Down Expand Up @@ -677,6 +677,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def isType: Boolean = sym.isType
def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass
def isConstructor: Boolean = toDenot(sym).isConstructor
def isExpanded: Boolean = sym.name.is(ExpandedName)
def isAnonymousFunction: Boolean = toDenot(sym).isAnonymousFunction
def isMethod: Boolean = sym is Flags.Method
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, Flags.Private | Flags.Protected)
Expand Down
1 change: 1 addition & 0 deletions tests/run/forwarder.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public static int Foo.hi()
20 changes: 20 additions & 0 deletions tests/run/forwarder.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Foo
object Foo extends Bar

trait Bar {
def hi: Int = 1
private def foo: Int = 1

class Inner {
val a = foo // Force foo to be expanded by ExpandPrivate
}
}

object Test {
def main(args: Array[String]): Unit = {
println(
classOf[Foo].getMethods
.filter(m => (m.getModifiers & java.lang.reflect.Modifier.STATIC) != 0)
.mkString("\n"))
}
}