Skip to content
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
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 tests/pos-macros/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-macros/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-macros/i9252/toplevel.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def fct: Unit = Macro.expand()