Skip to content

Commit

Permalink
anonymous functions are not macro dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pweisenburger committed May 7, 2024
1 parent 99c19a7 commit 705f9d2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/inlines/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@ class Inliner(val call: tpd.Tree)(using Context):
new TreeAccumulator[List[Symbol]] {
override def apply(syms: List[Symbol], tree: tpd.Tree)(using Context): List[Symbol] =
tree match {
case Closure(env, meth, tpt) if meth.symbol.isAnonymousFunction =>
this(syms, tpt :: env)
case tree: RefTree if tree.isTerm && level == -1 && tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal =>
foldOver(tree.symbol :: syms, tree)
case _: This if level == -1 && tree.symbol.isDefinedInCurrentRun =>
Expand Down
22 changes: 22 additions & 0 deletions tests/pos-macros/i20353/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//> using options -experimental -Yno-experimental

import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted.*

class ImplicitValue

object ImplicitValue:
inline given ImplicitValue =
${ makeImplicitValue }

def makeImplicitValue(using Quotes) =
import quotes.reflect.*
'{ ImplicitValue() }
end ImplicitValue

@experimental
class Test extends MacroAnnotation:
def transform(using Quotes)(tree: quotes.reflect.Definition) =
import quotes.reflect.*
Implicits.search(TypeRepr.of[ImplicitValue])
List(tree)
17 changes: 17 additions & 0 deletions tests/pos-macros/i20353/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//> using options -experimental -Yno-experimental

class OuterClass:
@Test
class InnerClass

@Test
object InnerObject
end OuterClass

object OuterObject:
@Test
class InnerClass

@Test
object InnerObject
end OuterObject

0 comments on commit 705f9d2

Please sign in to comment.