From f71b8bb07bc7290e3ecc84b651cc31dd60cd9982 Mon Sep 17 00:00:00 2001 From: Anatolii Date: Wed, 10 Jul 2019 18:13:32 +0200 Subject: [PATCH 1/2] Fix #6834: Make module constructors private Get aligned with Scala 2 behavior as seen here: https://github.com/scala/scala/blob/f3b48872ba2bd1a3ef5ad3ff4c7dbfbbf8ca9468/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala#L666 --- .../src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index c3841b8057d7..7688a7ae902f 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -679,7 +679,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma isFinal && !toDenot(sym).isClassConstructor && !(sym.is(Flags.Mutable)) && !(sym.enclosingClass.is(Flags.Trait)) def getsJavaPrivateFlag: Boolean = - isPrivate //|| (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass) + isPrivate || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass) def isFinal: Boolean = sym.is(Flags.Final) def isStaticMember: Boolean = (sym ne NoSymbol) && From d30717775d596d3052332140375acabd36cbb126 Mon Sep 17 00:00:00 2001 From: Anatolii Date: Thu, 11 Jul 2019 15:06:19 +0200 Subject: [PATCH 2/2] Add a test for #6834 --- tests/run/i6834.scala | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/run/i6834.scala diff --git a/tests/run/i6834.scala b/tests/run/i6834.scala new file mode 100644 index 000000000000..b01de4b15b16 --- /dev/null +++ b/tests/run/i6834.scala @@ -0,0 +1,5 @@ +object Foo +object Test { + def main(args: Array[String]) = + assert(Foo.getClass.getConstructors.length == 0) +} \ No newline at end of file