Skip to content

Fix #9252: Refine test for conflicting package objects #9256

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
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ class Namer { typer: Typer =>
val preExisting = owner.unforcedDecls.lookup(name)
if (preExisting.isDefinedInCurrentRun || preExisting.lastKnownDenotation.is(Package))
&& (!preExisting.lastKnownDenotation.is(Private) || preExisting.owner.is(Package))
&& (!preExisting.lastKnownDenotation.isPackageObject
|| preExisting.associatedFile != ctx.source.file)
// isDefinedInCurrentRun does not work correctly for package objects, because
// package objects are updated to the new run earlier than normal classes, everytime
// some member of the enclosing package is accessed. Therefore, we use another
// test: conflict if package objects have the same name but come from different
// sources. See i9252.
then conflict(preExisting)

def pkgObjs(pkg: Symbol) =
Expand Down
3 changes: 3 additions & 0 deletions compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ i7757.scala

# splice type tag dealiased in this reference
i8651b.scala

# suspended macros need multiple runs
i9252
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro tests should be under tests/pos-macros and this should not be needed in the blacklist. Otherwise LGTM.

3 changes: 3 additions & 0 deletions tests/pos/i9252/Clazz.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Clazz {
def foo = Macro.expand()
}
4 changes: 4 additions & 0 deletions tests/pos/i9252/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Macro {
inline def expand(): Unit = ${impl}
def impl(using scala.quoted.QuoteContext) = '{???}
}
1 change: 1 addition & 0 deletions tests/pos/i9252/toplevel.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def fct: Unit = Macro.expand()