File tree Expand file tree Collapse file tree 4 files changed +42
-6
lines changed
compiler/src/dotty/tools/dotc/typer
src-bootstrapped/scala/quoted/matching
src-non-bootstrapped/scala/quoted/matching Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -1979,8 +1979,11 @@ class Typer extends Namer
19791979 if (ddef.symbol.annotations.exists(_.symbol == defn.InternalQuoted_patternBindHoleAnnot )) {
19801980 val tpe = ddef.symbol.info match {
19811981 case t : ExprType => t.resType
1982- case t : PolyType => t.resultType.toFunctionType()
19831982 case t : MethodType => t.toFunctionType()
1983+ case t : PolyType =>
1984+ HKTypeLambda (t.paramNames)(
1985+ x => t.paramInfos.mapConserve(_.subst(t, x).asInstanceOf [TypeBounds ]),
1986+ x => t.resType.subst(t, x).toFunctionType())
19841987 case t => t
19851988 }
19861989 val exprTpe = AppliedType (defn.QuotedMatchingBindingType , tpe :: Nil )
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import scala.tasty.Reflection // TODO do not depend on reflection directly
88 * @param name string name of this binding
99 * @param id unique id used for equality
1010 */
11- class Binding [+ T ] private [scala](val name : String , private [Binding ] val id : Object ) { self =>
11+ class Binding [T <: AnyKind ] private [scala](val name : String , private [Binding ] val id : Object ) { self =>
1212
1313 override def equals (obj : Any ): Boolean = obj match {
1414 case obj : Binding [_] => obj.id == id
Original file line number Diff line number Diff line change 1+ package scala .quoted
2+ package matching
3+
4+ import scala .tasty .Reflection // TODO do not depend on reflection directly
5+
6+ /** Binding of an Expr[T] used to know if some Expr[T] is a reference to the binding
7+ *
8+ * @param name string name of this binding
9+ * @param id unique id used for equality
10+ */
11+ class Binding [T /* <: AnyKind*/ ] private [scala](val name : String , private [Binding ] val id : Object ) { self =>
12+
13+ override def equals (obj : Any ): Boolean = obj match {
14+ case obj : Binding [_] => obj.id == id
15+ case _ => false
16+ }
17+
18+ override def hashCode (): Int = id.hashCode()
19+
20+ }
21+
22+ object Binding {
23+
24+ def unapply [T ](expr : Expr [T ])(implicit reflect : Reflection ): Option [Binding [T ]] = {
25+ import reflect ._
26+ expr.unseal match {
27+ case IsIdent (ref) =>
28+ val sym = ref.symbol
29+ Some (new Binding [T ](sym.name, sym))
30+ case _ => None
31+ }
32+ }
33+
34+ }
Original file line number Diff line number Diff line change @@ -31,10 +31,9 @@ object Test {
3131 case ' { def $ff (i : Int )(j : Int ): Int = $z; 2 } =>
3232 val a : quoted.matching.Binding [Int => Int => Int ] = ff
3333 z
34- // FIXME
35- // case '{ def `$ff`[T](i: T): Int = $z; 2 } =>
36- // val a: quoted.matching.Binding[[T] => T => Int] = ff // TODO make Binding any-kinded
37- // z
34+ case ' { def $ff [T ](i : T ): Int = $z; 2 } =>
35+ val a : quoted.matching.Binding [[T ] => T => Int ] = ff
36+ z
3837 case _ => ' {1 }
3938 }
4039}
You can’t perform that action at this time.
0 commit comments