Skip to content

Remove contents of inline methods #16345

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
Dec 12, 2022
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
4 changes: 1 addition & 3 deletions compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ class PickleQuotes extends MacroTransform {
case _ =>
val (contents, tptWithHoles) = makeHoles(tpt)
PickleQuotes(quotes, tptWithHoles, contents, tpt.tpe, true)
case tree: DefDef if tree.symbol.is(Macro) =>
case tree: DefDef if tree.symbol.is(Macro) || tree.symbol.isInlineMethod =>
// Shrink size of the tree. The methods have already been inlined.
// TODO move to FirstTransform to trigger even without quotes
cpy.DefDef(tree)(rhs = defaultValue(tree.rhs.tpe))
case _: DefDef if tree.symbol.isInlineMethod =>
tree
case _ =>
super.transform(tree)
}
Expand Down
28 changes: 28 additions & 0 deletions tests/pos-macros/i15985.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package anorm.macros
sealed trait Row
sealed trait SqlResult[A]

import scala.quoted.{ Expr, Quotes, Type }

private[anorm] object RowParserImpl {
def apply[A](using q:Quotes)(using a: Type[A]): Expr[Row => SqlResult[A]] = {
import q.reflect.*

inline def f1: Expr[SqlResult[A]] =
Match(???, ???).asExprOf[SqlResult[A]] // (using Type.of[anorm.macros.SqlResult[A]] })

inline def f2: Expr[SqlResult[A]] =
Match(???, ???).asExprOf[SqlResult[A]](using Type.of[SqlResult[A]])
// In Staging phase it becomes
// ..asExprOf[..](using Type.of[{ @SplicedType type a$_$3 = a.Underlying; anorm.macros.SqlResult[a$_$3] }])

inline def f3(using Type[SqlResult[A]]): Expr[SqlResult[A]] =
Match(???, ???).asExprOf[SqlResult[A]]

f1
f2
f3

???
}
}