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 @@ -1978,8 +1978,11 @@ class Typer extends Namer
1978
1978
if (ddef.symbol.annotations.exists(_.symbol == defn.InternalQuoted_patternBindHoleAnnot )) {
1979
1979
val tpe = ddef.symbol.info match {
1980
1980
case t : ExprType => t.resType
1981
- case t : PolyType => t.resultType.toFunctionType()
1982
1981
case t : MethodType => t.toFunctionType()
1982
+ case t : PolyType =>
1983
+ HKTypeLambda (t.paramNames)(
1984
+ x => t.paramInfos.mapConserve(_.subst(t, x).asInstanceOf [TypeBounds ]),
1985
+ x => t.resType.subst(t, x).toFunctionType())
1983
1986
case t => t
1984
1987
}
1985
1988
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
8
8
* @param name string name of this binding
9
9
* @param id unique id used for equality
10
10
*/
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 =>
12
12
13
13
override def equals (obj : Any ): Boolean = obj match {
14
14
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 {
31
31
case ' { def $ff (i : Int )(j : Int ): Int = $z; 2 } =>
32
32
val a : quoted.matching.Binding [Int => Int => Int ] = ff
33
33
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
38
37
case _ => ' {1 }
39
38
}
40
39
}
You can’t perform that action at this time.
0 commit comments