Skip to content

Commit 755abf7

Browse files
committed
Partially fix Java interop for emitted inner classes
The backend uses `rawname` to define the "inner name" of an InnerClass entry in a classfile, this should be the simple name of the class before any mangling takes place but before this commit, we put the mangled name after flatten there. Fixing this allows Java code to reference dotty inner classes, except if they're defined in objects which is still broken until lampepfl/scala#4 is merged and a new backend is published.
1 parent be64643 commit 755abf7

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
560560
def javaBinaryName: Name = toDenot(sym).fullNameSeparated("/") // addModuleSuffix(fullNameInternal('/'))
561561
def javaClassName: String = toDenot(sym).fullName.toString// addModuleSuffix(fullNameInternal('.')).toString
562562
def name: Name = sym.name
563-
def rawname: Name = sym.name // todo ????
563+
def rawname: Name = sym.name(ctx.withPhase(ctx.flattenPhase))
564564

565565
// types
566566
def info: Type = toDenot(sym).info
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Outer {
2+
class InnerInClass
3+
4+
def inner() = new InnerInClass
5+
}
6+
object Outer {
7+
class InnerInObject
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Test {
2+
public static void test() {
3+
Outer outer = new Outer();
4+
Outer.InnerInClass innerInClass = outer.inner();
5+
6+
// Does not work yet, requires https://github.com/DarkDimius/scala/pull/4
7+
// Outer.InnerInObject innerInObject = new Outer.InnerInObject();
8+
}
9+
}

0 commit comments

Comments
 (0)