diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 50b940ec9211..c23c4df40e64 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -2122,11 +2122,20 @@ object SymDenotations { case pcls :: pobjs1 => if (pcls.isCompleting) recur(pobjs1, acc) else { - // A package object inherits members from `Any` and `Object` which - // should not be accessible from the package prefix. val pmembers = pcls.computeNPMembersNamed(name).filterWithPredicate { d => + // Drop members of `Any` and `Object`, as well as top-level definitions + // in the empty package that are not defined in the current run. val owner = d.symbol.maybeOwner - (owner ne defn.AnyClass) && (owner ne defn.ObjectClass) + (owner ne defn.AnyClass) + && (owner ne defn.ObjectClass) + && ( + (symbol ne defn.EmptyPackageClass) + || d.symbol.isDefinedInCurrentRun + || d.symbol.associatedFile == null + // if a symbol does not have an associated file, assume it is defined + // in the current run anyway. This typically happens for pickling and from + // tasty tests that generate a fresh symbol and then re-use it in the next run. + ) } recur(pobjs1, acc.union(pmembers)) } diff --git a/compiler/test/dotc/run-test-pickling.blacklist b/compiler/test/dotc/run-test-pickling.blacklist index f3e4c7ec847c..31036f89e6dc 100644 --- a/compiler/test/dotc/run-test-pickling.blacklist +++ b/compiler/test/dotc/run-test-pickling.blacklist @@ -14,6 +14,7 @@ typeclass-derivation2d.scala typeclass-derivation3.scala derive-generic.scala mixin-forwarder-overload +toplevel-defs t8905 t10889 macros-in-same-project1 diff --git a/tests/pos/i7650/Test_1.scala b/tests/pos/i7650/Test_1.scala new file mode 100644 index 000000000000..01bc62e8e357 --- /dev/null +++ b/tests/pos/i7650/Test_1.scala @@ -0,0 +1 @@ +@main def Test() = println("hi") \ No newline at end of file diff --git a/tests/pos/i7650/Test_2.scala b/tests/pos/i7650/Test_2.scala new file mode 100644 index 000000000000..00174769a0f0 --- /dev/null +++ b/tests/pos/i7650/Test_2.scala @@ -0,0 +1 @@ +object Test diff --git a/tests/run/toplevel-defs/Test_2.scala b/tests/run/toplevel-defs/Test.scala similarity index 100% rename from tests/run/toplevel-defs/Test_2.scala rename to tests/run/toplevel-defs/Test.scala diff --git a/tests/run/toplevel-defs/defs_1.scala b/tests/run/toplevel-defs/defs.scala similarity index 100% rename from tests/run/toplevel-defs/defs_1.scala rename to tests/run/toplevel-defs/defs.scala diff --git a/tests/run/toplevel-mixed/A_1.scala b/tests/run/toplevel-mixed/A.scala similarity index 100% rename from tests/run/toplevel-mixed/A_1.scala rename to tests/run/toplevel-mixed/A.scala diff --git a/tests/run/toplevel-mixed/B_1.scala b/tests/run/toplevel-mixed/B.scala similarity index 100% rename from tests/run/toplevel-mixed/B_1.scala rename to tests/run/toplevel-mixed/B.scala diff --git a/tests/run/toplevel-mixed/Test_2.scala b/tests/run/toplevel-mixed/Test.scala similarity index 100% rename from tests/run/toplevel-mixed/Test_2.scala rename to tests/run/toplevel-mixed/Test.scala