Skip to content

WIP: Fix #11251 #11335

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
Feb 24, 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
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import collection.mutable
import reporting.trace
import util.Spans.Span
import dotty.tools.dotc.transform.{Splicer, TreeMapWithStages}
import quoted.QuoteUtils

object Inliner {
import tpd._
Expand Down Expand Up @@ -520,7 +521,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
ref(rhsClsSym.sourceModule)
else
inlineCallPrefix
val binding = ValDef(selfSym.asTerm, rhs).withSpan(selfSym.span).setDefTree
val binding = ValDef(selfSym.asTerm, QuoteUtils.changeOwnerOfTree(rhs, selfSym)).withSpan(selfSym.span).setDefTree
bindingsBuf += binding
inlining.println(i"proxy at $level: $selfSym = ${bindingsBuf.last}")
lastSelf = selfSym
Expand Down
29 changes: 29 additions & 0 deletions tests/pos-macros/i11251/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package i11251

import scala.quoted._

class SL:

inline def foo(inline step: Int => Int): SL =
val f = step
this

def run1(): Unit = ???

inline def run(): Unit =
run1()

// works
//object SL

object X:

inline def process[T](inline f:T) = ${
processImpl[T]('f)
}

def processImpl[T:Type](t:Expr[T])(using Quotes):Expr[T] =
import quotes.reflect._
val checker = new TreeMap() {}
checker.transformTerm(t.asTerm)(Symbol.spliceOwner)
t
12 changes: 12 additions & 0 deletions tests/pos-macros/i11251/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package i11251


object Main {

def main(args:Array[String]):Unit =
val sl = new SL()
X.process(
sl.foo(x=>x+1).run()
)

}