From 070b863408cab1b5ce64b65a552a6bb243c74e63 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Wed, 19 May 2021 13:06:00 +0200 Subject: [PATCH] Fix #12249: don't export java defined modules --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 2 ++ tests/neg/12249.scala | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/neg/12249.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 14e4aecd55c9..f421c75f9287 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1000,6 +1000,8 @@ class Namer { typer: Typer => ) match case Some(other) => No(i"overrides ${other.showLocated}, which is already a member of $cls") case None => Yes + else if sym.isAllOf(JavaModule) then + Skip else Yes } diff --git a/tests/neg/12249.scala b/tests/neg/12249.scala new file mode 100644 index 000000000000..81e8ce053584 --- /dev/null +++ b/tests/neg/12249.scala @@ -0,0 +1,9 @@ + +export java.util.UUID + +def bar = println(new UUID(1, 2)) // OK + +def foo = println(UUID.randomUUID()) // error +// ^^^^ +// Not found: UUID +