Skip to content

fix #7721 fix #7723 append moduleName suffix on erasedName of object classes #7725

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 2 commits into from
Dec 12, 2019
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
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,13 @@ object SymDenotations {
case Some(ann) =>
ann.arguments match {
case Literal(Constant(str: String)) :: Nil =>
if (isType) str.toTypeName else str.toTermName
if (isType)
if (is(ModuleClass))
str.toTypeName.moduleClassName
else
str.toTypeName
else
str.toTermName
case _ => name
}
case _ => name
Expand Down
5 changes: 5 additions & 0 deletions tests/run/alpha-modules-1/7721_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package alpha

@scala.annotation.alpha("A") object B {
def foo = 23
}
9 changes: 9 additions & 0 deletions tests/run/alpha-modules-1/Test_2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package alpha;

public class Test_2 {

public static void main(String[] args) {
assert A.foo() == 23;
assert A$.MODULE$.foo() == 23;
}
}
4 changes: 4 additions & 0 deletions tests/run/alpha-modules-1/Test_3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Test {
def main(args: Array[String]): Unit =
alpha.Test_2.main(args)
}
3 changes: 3 additions & 0 deletions tests/run/alpha-modules-2/7723_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package alpha

@scala.annotation.alpha("A") class B(val i: Int = 1)
10 changes: 10 additions & 0 deletions tests/run/alpha-modules-2/Test_2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package alpha;

public class Test_2 {

public static void main(String[] args) {
assert new A(101).i() == 101;
assert new A(A.$lessinit$greater$default$1()).i() == 101;
assert new A(A$.MODULE$.$lessinit$greater$default$1()).i() == 101;
}
}
4 changes: 4 additions & 0 deletions tests/run/alpha-modules-2/Test_3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Test {
def main(args: Array[String]): Unit =
alpha.Test_2.main(args)
}