Skip to content

Commit 402907f

Browse files
committed
anonymous functions are not macro dependencies
1 parent 4bd3369 commit 402907f

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,8 @@ class Inliner(val call: tpd.Tree)(using Context):
11041104
new TreeAccumulator[List[Symbol]] {
11051105
override def apply(syms: List[Symbol], tree: tpd.Tree)(using Context): List[Symbol] =
11061106
tree match {
1107+
case Closure(env, meth, tpt) if meth.symbol.isAnonymousFunction =>
1108+
this(syms, tpt :: env)
11071109
case tree: RefTree if tree.isTerm && level == -1 && tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal =>
11081110
foldOver(tree.symbol :: syms, tree)
11091111
case _: This if level == -1 && tree.symbol.isDefinedInCurrentRun =>

tests/pos-macros/i20353/Macro_1.scala

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//> using options -experimental -Yno-experimental
2+
3+
import scala.annotation.{experimental, MacroAnnotation}
4+
import scala.quoted.*
5+
6+
class ImplicitValue
7+
8+
object ImplicitValue:
9+
inline given ImplicitValue =
10+
${ makeImplicitValue }
11+
12+
def makeImplicitValue(using Quotes) =
13+
import quotes.reflect.*
14+
'{ ImplicitValue() }
15+
end ImplicitValue
16+
17+
@experimental
18+
class Test extends MacroAnnotation:
19+
def transform(using Quotes)(tree: quotes.reflect.Definition) =
20+
import quotes.reflect.*
21+
Implicits.search(TypeRepr.of[ImplicitValue])
22+
List(tree)

tests/pos-macros/i20353/Test_2.scala

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//> using options -experimental -Yno-experimental
2+
3+
class OuterClass:
4+
@Test
5+
class InnerClass
6+
7+
@Test
8+
object InnerObject
9+
end OuterClass
10+
11+
object OuterObject:
12+
@Test
13+
class InnerClass
14+
15+
@Test
16+
object InnerObject
17+
end OuterObject

0 commit comments

Comments
 (0)