@@ -255,17 +255,20 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
255255
256256 object DefDef extends DefDefModule :
257257 def apply (symbol : Symbol , rhsFn : List [TypeRepr ] => List [List [Term ]] => Option [Term ]): DefDef =
258- withDefaultPos(tpd.polyDefDef(symbol.asTerm, tparams => vparamss => yCheckedOwners(rhsFn(tparams)(vparamss), symbol).getOrElse(tpd.EmptyTree )))
258+ withDefaultPos(tpd.DefDef (symbol.asTerm, prefss => {
259+ val (tparams, vparamss) = tpd.splitArgs(prefss)
260+ yCheckedOwners(rhsFn(tparams.map(_.tpe))(vparamss), symbol).getOrElse(tpd.EmptyTree )
261+ }))
259262 def copy (original : Tree )(name : String , typeParams : List [TypeDef ], paramss : List [List [ValDef ]], tpt : TypeTree , rhs : Option [Term ]): DefDef =
260- tpd.cpy.DefDef (original)(name.toTermName, typeParams, paramss, tpt, yCheckedOwners(rhs, original.symbol).getOrElse(tpd.EmptyTree ))
263+ tpd.cpy.DefDef (original)(name.toTermName, tpd.joinParams( typeParams, paramss) , tpt, yCheckedOwners(rhs, original.symbol).getOrElse(tpd.EmptyTree ))
261264 def unapply (ddef : DefDef ): (String , List [TypeDef ], List [List [ValDef ]], TypeTree , Option [Term ]) =
262- (ddef.name.toString, ddef.typeParams, ddef.paramss , ddef.tpt, optional(ddef.rhs))
265+ (ddef.name.toString, ddef.typeParams, ddef.termParamss , ddef.tpt, optional(ddef.rhs))
263266 end DefDef
264267
265268 given DefDefMethods : DefDefMethods with
266269 extension (self : DefDef )
267- def typeParams : List [TypeDef ] = self.tparams
268- def paramss : List [List [ValDef ]] = self.vparamss
270+ def typeParams : List [TypeDef ] = self.leadingTypeParams // TODO: adapt to multiple type parameter clauses
271+ def paramss : List [List [ValDef ]] = self.termParamss
269272 def returnTpt : TypeTree = self.tpt
270273 def rhs : Option [Term ] = optional(self.rhs)
271274 end extension
@@ -378,7 +381,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
378381 }
379382 val closureTpe = Types .MethodType (mtpe.paramNames, mtpe.paramInfos, closureResType)
380383 val closureMethod = dotc.core.Symbols .newSymbol(owner, nme.ANON_FUN , Synthetic | Method , closureTpe)
381- tpd.Closure (closureMethod, tss => new tpd.TreeOps (self).appliedToArgs (tss.head).etaExpand(closureMethod))
384+ tpd.Closure (closureMethod, tss => new tpd.TreeOps (self).appliedToTermArgs (tss.head).etaExpand(closureMethod))
382385 case _ => self
383386 }
384387
@@ -2653,6 +2656,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26532656 def startColumn : Int = self.startColumn
26542657 def endColumn : Int = self.endColumn
26552658 def sourceCode : Option [String ] =
2659+ // TODO detect when we do not have a source and return None
26562660 Some (new String (self.source.content(), self.start, self.end - self.start))
26572661 end extension
26582662 end PositionMethods
@@ -2667,6 +2671,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26672671 extension (self : SourceFile )
26682672 def jpath : java.nio.file.Path = self.file.jpath
26692673 def content : Option [String ] =
2674+ // TODO detect when we do not have a source and return None
26702675 Some (new String (self.content()))
26712676 end extension
26722677 end SourceFileMethods
@@ -2863,8 +2868,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
28632868 if pat1.isType then matcher.termMatch(scrutinee.asInstanceOf [matcher.qctx.reflect.Term ], pat1.asInstanceOf [matcher.qctx.reflect.Term ])
28642869 else matcher.termMatch(scrutinee.asInstanceOf [matcher.qctx.reflect.Term ], pat1.asInstanceOf [matcher.qctx.reflect.Term ])
28652870
2871+ // val matchings = matcher.termMatch(scrutinee, pattern)
28662872 if typeHoles.isEmpty then matchings
28672873 else {
2874+ // After matching and doing all subtype checks, we have to approximate all the type bindings
2875+ // that we have found, seal them in a quoted.Type and add them to the result
28682876 def typeHoleApproximation (sym : Symbol ) =
28692877 ctx1.gadt.approximation(sym, ! sym.hasAnnotation(dotc.core.Symbols .defn.QuotedRuntimePatterns_fromAboveAnnot )).asInstanceOf [qctx1.reflect.TypeRepr ].asType
28702878 matchings.map { tup =>
0 commit comments