File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ object EtaExpansion extends LiftImpure {
223223 */
224224 def etaExpand (tree : Tree , mt : MethodType , xarity : Int )(using Context ): untpd.Tree = {
225225 import untpd ._
226- assert(! ctx.isAfterTyper)
226+ assert(! ctx.isAfterTyper || (ctx.phase eq ctx.base.inliningPhase), ctx.phase )
227227 val defs = new mutable.ListBuffer [tpd.Tree ]
228228 val lifted : Tree = TypedSplice (liftApp(defs, tree))
229229 val isLastApplication = mt.resultType match {
Original file line number Diff line number Diff line change 1+ // assume that this conversion utility is defined in Scala 2
2+ class Scala2Conversion [T , V ](val f : T => V )
3+ object Scala2Conversion {
4+ implicit def create [T , V ](implicit f : T => V ): Scala2Conversion [T , V ] = new Scala2Conversion (f)
5+ }
6+
7+ // assume this utility in Scala 3, to summon a conversion within a macro
8+ import quoted ._
9+ def summonConversionImpl (using qctx : Quotes ): Expr [Any ] = {
10+ import qctx .reflect ._
11+
12+ // hardcoded in this example to look for String to Int
13+ val conversionTpe = TypeRepr .of[Scala2Conversion [String , Int ]]
14+
15+ Implicits .search(conversionTpe) match {
16+ case iss : ImplicitSearchSuccess =>
17+ iss.tree.asExpr
18+ case isf : ImplicitSearchFailure =>
19+ report.error(s " can't find conversion " )
20+ ' {??? }
21+ }
22+ }
23+
24+ inline def summonConversion () = $ {summonConversionImpl}
Original file line number Diff line number Diff line change 1+ implicit def s2i (x : String ): Int = x.toInt
2+
3+ def main () = {
4+ summonConversion()
5+ }
You can’t perform that action at this time.
0 commit comments