Skip to content

Commit 4ad3ffb

Browse files
Merge pull request #10105 from dotty-staging/use-canonical-quoted-type-representation
Use canonical Type constructor
2 parents af70c5f + b28f4b0 commit 4ad3ffb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+121
-121
lines changed

tests/neg-macros/delegate-match-1/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }
55

66
private def fImpl(using qctx: QuoteContext): Expr[Unit] = {
77
import qctx.reflect._
8-
Implicits.search(('[A]).unseal.tpe) match {
8+
Implicits.search((Type[A]).unseal.tpe) match {
99
case x: ImplicitSearchSuccess =>
1010
'{}
1111
case x: DivergingImplicit => '{}

tests/neg-macros/delegate-match-2/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }
55

66
private def fImpl (using qctx: QuoteContext) : Expr[Unit] = {
77
import qctx.reflect._
8-
Implicits.search(('[A]).unseal.tpe) match {
8+
Implicits.search((Type[A]).unseal.tpe) match {
99
case x: ImplicitSearchSuccess =>
1010
'{}
1111
case x: DivergingImplicit => '{}

tests/neg-macros/delegate-match-3/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }
55

66
private def fImpl(using qctx: QuoteContext) : Expr[Unit] = {
77
import qctx.reflect._
8-
Implicits.search(('[A]).unseal.tpe) match {
8+
Implicits.search((Type[A]).unseal.tpe) match {
99
case x: ImplicitSearchSuccess =>
1010
'{}
1111
case x: DivergingImplicit => '{}

tests/neg-macros/i4493-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Index[K]
22
object Index {
33
inline def succ[K](x: K): Unit = ${
4-
implicit val t: quoted.Type[K] = '[K] // error
4+
implicit val t: quoted.Type[K] = Type[K] // error
55
'{new Index[K]}
66
}
77
}

tests/neg-macros/i4493.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Index[K]
22
object Index {
33
inline def succ[K]: Unit = ${
4-
implicit val t: quoted.Type[K] = '[K] // error
4+
implicit val t: quoted.Type[K] = Type[K] // error
55
'{new Index[K]}
66
}
77
}

tests/neg-macros/i6530.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
object Macros {
2-
inline def q : Int = ${ '[ Int ] } // error
2+
inline def q : Int = ${ Type[ Int ] } // error
33
val x : Int = 1 + q
44
}

tests/neg-macros/i6530b.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ object Foo {
44
val tpe: quoted.Type[Int] = ???
55
val expr: quoted.Expr[Int] = ???
66

7-
val a: quoted.Expr[Int] = ${ '[Int] } // error
7+
val a: quoted.Expr[Int] = ${ Type[Int] } // error
88
val b: quoted.Expr[Int] = '{ $tpe } // error
99
val c: ${ '{ 43 } } = ??? // error
10-
val d: quoted.Type[Int] = '[ $expr ] // error
10+
val d: quoted.Type[Int] = Type[ $expr ] // error
1111
}
1212
}

tests/neg-macros/i7013.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import quoted._
22

33
def foo()(using QuoteContext) = {
44
class C
5-
'[C] // error
5+
Type[C] // error
66
}

tests/neg-macros/i7013b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import quoted._
33
class Foo {
44
class Bar
55
def foo()(using QuoteContext) = {
6-
'[Bar] // error
6+
Type[Bar] // error
77
}
88
}

tests/neg-macros/i7013c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import quoted._
22

33
def foo()(using QuoteContext) = {
44
type C
5-
'[C] // error
5+
Type[C] // error
66
}

tests/neg-macros/i7121.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Test()(implicit qtx: QuoteContext) {
77
@annot1('{4}) // error
88
def foo(str: String) = ()
99

10-
@annot2(4)(using '[Int]) // error
10+
@annot2(4)(using Type[Int]) // error
1111
def foo2(str: String) = ()
1212

1313
}

tests/pos-macros/i4023c/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.quoted._
22
object Macro {
3-
inline def ff[T](x: T): T = ${ impl('x)('[T], summon[QuoteContext]) }
3+
inline def ff[T](x: T): T = ${ impl('x)(Type[T], summon[QuoteContext]) }
44
def impl[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ $x: $t }
55
}

tests/pos-macros/i4539.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.quoted._
22
def test(using QuoteContext) = {
3-
val q = '[String]
4-
'[String]
3+
val q = Type[String]
4+
Type[String]
55
}

tests/pos-macros/i4539b.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import scala.quoted._
2-
def test(using QuoteContext) = {
2+
def test(using QuoteContext): Unit = {
33
def f = {
44
{
5-
'[String]
6-
'[String]
5+
Type[String]
6+
Type[String]
77
}
88

9-
'[String] match { case _ => }
10-
try '[String] catch { case _ => }
9+
Type[String] match { case _ => }
10+
try Type[String] catch { case _ => }
1111

12-
'[String]
13-
'[String]
12+
Type[String]
13+
Type[String]
1414
}
1515

1616
def bar[T](t: Type[T]) = ???
17-
bar('[String])
17+
bar(Type[String])
1818

1919
class Baz[T](t: Type[T])
20-
new Baz('[String])
20+
new Baz(Type[String])
2121

2222
}

tests/pos-macros/i6140.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ sealed trait Trait[T] {
44
}
55

66
object O {
7-
def fn[T:Type](t : Trait[T])(using QuoteContext): Type[T] = '[t.t]
7+
def fn[T:Type](t : Trait[T])(using QuoteContext): Type[T] = Type[t.t]
88
}

tests/pos-macros/i6142.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ object O {
44
def foo(using QuoteContext) = {
55
type T
66
implicit val _: scala.quoted.Type[T] = ???
7-
'[List[T]]
7+
Type[List[T]]
88
()
99
}
1010
}

tests/pos-macros/i6210/Macros_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Macro {
55
${ impl[A, B] }
66

77
def impl[A : Type, B : Type](using QuoteContext): Expr[Any] = {
8-
val t = '[Map[A, B]]
8+
val t = Type[Map[A, B]]
99
'{
1010
new Object().asInstanceOf[$t]
1111
???.asInstanceOf[$t]

tests/pos-macros/i7048b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ trait IsExpr {
77
val foo: IsExpr = ???
88

99
def g()(using QuoteContext): Unit = {
10-
val a = '[foo.Underlying]
10+
val a = Type[foo.Underlying]
1111
()
1212
}

tests/pos-macros/i7264.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import scala.quoted._
22
class Foo {
33
def f[T2](t: Type[T2])(using QuoteContext) = t match {
44
case '[ *:[Int, $T] ] =>
5-
'[ *:[Int, T] ]
5+
Type[ *:[Int, T] ]
66
}
77
}

tests/pos-macros/i7264b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import scala.quoted._
22
class Foo {
33
def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match {
44
case '{ $x: *:[Int, $t] } =>
5-
'[ *:[Int, t] ]
5+
Type[ *:[Int, t] ]
66
}
77
}

tests/pos-macros/i7264c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ class Foo {
44
case '{ $x: $T0 } =>
55
Type[T0] match
66
case '[ *:[Int, $T] ] =>
7-
'[ *:[Int, T] ]
7+
Type[ *:[Int, T] ]
88
}
99
}

tests/pos-macros/i7405.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Foo {
55
type X = Int // Level 1
66
val x: X = ???
77
${
8-
val t: Type[X] = '[X] // Level 0
8+
val t: Type[X] = Type[X] // Level 0
99
'{ val y: $t = x }
1010
}
1111
}

tests/pos-macros/i7405b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Foo {
1010
val x: X = ???
1111
type Z = x.Y
1212
${
13-
val t: Type[Z] = '[Z]
13+
val t: Type[Z] = Type[Z]
1414
'{ val y: $t = x.y }
1515
}
1616
}

tests/pos-macros/i8100.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ def f[T: Type](using QuoteContext) =
1010
'{
1111
val m = $mm
1212
type ME = m.E
13-
${ g[ME](using '[ME]) }
14-
${ g[m.E](using '[ME]) }
15-
${ g[ME](using '[m.E]) }
16-
${ g[m.E](using '[m.E]) }
13+
${ g[ME](using Type[ME]) }
14+
${ g[m.E](using Type[ME]) }
15+
${ g[ME](using Type[m.E]) }
16+
${ g[m.E](using Type[m.E]) }
1717
// ${ g[ME] } // FIXME: issue seems to be in ReifyQuotes
1818
// ${ g[m.E] } // FIXME: issue seems to be in ReifyQuotes
1919
}

tests/pos-macros/i8302.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22
def foo[T](using qctx: QuoteContext, tpe: Type[T]): Expr[Any] =
33
'{ (using qctx: QuoteContext) =>
44
type TT = T
5-
val t = '[TT]
5+
val t = Type[TT]
66
???
77
}
88

tests/pos-macros/i9518/Macro_1.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ inline def shift : Unit = ${ shiftTerm }
88
def shiftTerm(using QuoteContext): Expr[Unit] = {
99
import qctx.reflect._
1010
val nTree = '{ ??? : CB[Int] }.unseal
11-
val tp1 = '[CB[Int]].unseal.tpe
12-
val tp2 = '[([X] =>> CB[X])[Int]].unseal.tpe
13-
val ta = '[[X] =>> CB[X]]
14-
val tp3 = '[ta.Underlying[Int]].unseal.tpe
15-
val tp4 = '[CB].unseal.tpe.appliedTo(TypeRepr.of[Int])
11+
val tp1 = Type[CB[Int]].unseal.tpe
12+
val tp2 = Type[([X] =>> CB[X])[Int]].unseal.tpe
13+
val ta = Type[[X] =>> CB[X]]
14+
val tp3 = Type[ta.Underlying[Int]].unseal.tpe
15+
val tp4 = Type[CB].unseal.tpe.appliedTo(TypeRepr.of[Int])
1616
assert(nTree.tpe <:< tp1)
1717
assert(nTree.tpe <:< tp2)
1818
assert(nTree.tpe <:< tp3)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.quoted._
22
object Macro {
3-
inline def ff: Unit = ${impl('[Int])}
3+
inline def ff: Unit = ${impl(Type[Int])}
44
def impl(t: Type[Int])(using QuoteContext): Expr[Unit] = '{}
55
}

tests/pos-macros/quote-1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class Test(using QuoteContext) {
77
val z = $x
88
}
99

10-
f('{2})('[Int])
11-
f('{ true })('[Boolean])
10+
f('{2})(Type[Int])
11+
f('{ true })(Type[Boolean])
1212

1313
def g(es: Expr[String], t: Type[String]) =
14-
f('{ ($es + "!") :: Nil })('[List[$t]])
14+
f('{ ($es + "!") :: Nil })(Type[List[t.Underlying]])
1515
}

tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import scala.quoted._
22

33

4-
inline def isFunctionType[T]: Boolean = ${ isFunctionTypeImpl('[T]) }
4+
inline def isFunctionType[T]: Boolean = ${ isFunctionTypeImpl(Type[T]) }
55

66
def isFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = {
77
import qctx.reflect._
88
Expr(tp.unseal.tpe.isFunctionType)
99
}
1010

1111

12-
inline def isContextFunctionType[T]: Boolean = ${ isContextFunctionTypeImpl('[T]) }
12+
inline def isContextFunctionType[T]: Boolean = ${ isContextFunctionTypeImpl(Type[T]) }
1313

1414
def isContextFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = {
1515
import qctx.reflect._
1616
Expr(tp.unseal.tpe.isContextFunctionType)
1717
}
1818

1919

20-
inline def isErasedFunctionType[T]: Boolean = ${ isErasedFunctionTypeImpl('[T]) }
20+
inline def isErasedFunctionType[T]: Boolean = ${ isErasedFunctionTypeImpl(Type[T]) }
2121

2222
def isErasedFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = {
2323
import qctx.reflect._
2424
Expr(tp.unseal.tpe.isErasedFunctionType)
2525
}
2626

27-
inline def isDependentFunctionType[T]: Boolean = ${ isDependentFunctionTypeImpl('[T]) }
27+
inline def isDependentFunctionType[T]: Boolean = ${ isDependentFunctionTypeImpl(Type[T]) }
2828

2929
def isDependentFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = {
3030
import qctx.reflect._

0 commit comments

Comments
 (0)