Skip to content

Fix implicit search in Inlining phase #11153

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 1 commit into from
Jan 19, 2021
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
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Inlining.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import dotty.tools.dotc.quoted._
import dotty.tools.dotc.transform.TreeMapWithStages._
import dotty.tools.dotc.typer.Inliner
import dotty.tools.dotc.typer.ImportInfo.withRootImports
import dotty.tools.dotc.ast.TreeMapWithImplicits

import scala.annotation.constructorOnly

Expand Down Expand Up @@ -57,6 +58,11 @@ class Inlining extends MacroTransform {

protected def newTransformer(using Context): Transformer = new Transformer {
override def transform(tree: tpd.Tree)(using Context): tpd.Tree =
new InliningTreeMap().transform(tree)
}

private class InliningTreeMap extends TreeMapWithImplicits {
override def transform(tree: Tree)(using Context): Tree = {
tree match
case tree: DefTree =>
if tree.symbol.is(Inline) then tree
Expand All @@ -75,7 +81,7 @@ class Inlining extends MacroTransform {
super.transform(tree)(using StagingContext.spliceContext)
case _ =>
super.transform(tree)

}
}
}

Expand Down
16 changes: 16 additions & 0 deletions tests/run-staging/i11152.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

import scala.quoted._
import scala.quoted.staging._

object Test {

given Toolbox = Toolbox.make(getClass.getClassLoader)

def main(args: Array[String]): Unit = run {
'{
given Int = 10
compiletime.summonInline[Int]
()
}
}
}