Skip to content

Use canonical Type constructor #10105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-1/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }

private def fImpl(using qctx: QuoteContext): Expr[Unit] = {
import qctx.reflect._
Implicits.search(('[A]).unseal.tpe) match {
Implicits.search((Type[A]).unseal.tpe) match {
case x: ImplicitSearchSuccess =>
'{}
case x: DivergingImplicit => '{}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-2/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }

private def fImpl (using qctx: QuoteContext) : Expr[Unit] = {
import qctx.reflect._
Implicits.search(('[A]).unseal.tpe) match {
Implicits.search((Type[A]).unseal.tpe) match {
case x: ImplicitSearchSuccess =>
'{}
case x: DivergingImplicit => '{}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-3/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }

private def fImpl(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.reflect._
Implicits.search(('[A]).unseal.tpe) match {
Implicits.search((Type[A]).unseal.tpe) match {
case x: ImplicitSearchSuccess =>
'{}
case x: DivergingImplicit => '{}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i4493-b.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Index[K]
object Index {
inline def succ[K](x: K): Unit = ${
implicit val t: quoted.Type[K] = '[K] // error
implicit val t: quoted.Type[K] = Type[K] // error
'{new Index[K]}
}
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i4493.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Index[K]
object Index {
inline def succ[K]: Unit = ${
implicit val t: quoted.Type[K] = '[K] // error
implicit val t: quoted.Type[K] = Type[K] // error
'{new Index[K]}
}
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i6530.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object Macros {
inline def q : Int = ${ '[ Int ] } // error
inline def q : Int = ${ Type[ Int ] } // error
val x : Int = 1 + q
}
4 changes: 2 additions & 2 deletions tests/neg-macros/i6530b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object Foo {
val tpe: quoted.Type[Int] = ???
val expr: quoted.Expr[Int] = ???

val a: quoted.Expr[Int] = ${ '[Int] } // error
val a: quoted.Expr[Int] = ${ Type[Int] } // error
val b: quoted.Expr[Int] = '{ $tpe } // error
val c: ${ '{ 43 } } = ??? // error
val d: quoted.Type[Int] = '[ $expr ] // error
val d: quoted.Type[Int] = Type[ $expr ] // error
}
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i7013.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import quoted._

def foo()(using QuoteContext) = {
class C
'[C] // error
Type[C] // error
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i7013b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import quoted._
class Foo {
class Bar
def foo()(using QuoteContext) = {
'[Bar] // error
Type[Bar] // error
}
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i7013c.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import quoted._

def foo()(using QuoteContext) = {
type C
'[C] // error
Type[C] // error
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i7121.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Test()(implicit qtx: QuoteContext) {
@annot1('{4}) // error
def foo(str: String) = ()

@annot2(4)(using '[Int]) // error
@annot2(4)(using Type[Int]) // error
def foo2(str: String) = ()

}
2 changes: 1 addition & 1 deletion tests/pos-macros/i4023c/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import scala.quoted._
object Macro {
inline def ff[T](x: T): T = ${ impl('x)('[T], summon[QuoteContext]) }
inline def ff[T](x: T): T = ${ impl('x)(Type[T], summon[QuoteContext]) }
def impl[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ $x: $t }
}
4 changes: 2 additions & 2 deletions tests/pos-macros/i4539.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import scala.quoted._
def test(using QuoteContext) = {
val q = '[String]
'[String]
val q = Type[String]
Type[String]
}
18 changes: 9 additions & 9 deletions tests/pos-macros/i4539b.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import scala.quoted._
def test(using QuoteContext) = {
def test(using QuoteContext): Unit = {
def f = {
{
'[String]
'[String]
Type[String]
Type[String]
}

'[String] match { case _ => }
try '[String] catch { case _ => }
Type[String] match { case _ => }
try Type[String] catch { case _ => }

'[String]
'[String]
Type[String]
Type[String]
}

def bar[T](t: Type[T]) = ???
bar('[String])
bar(Type[String])

class Baz[T](t: Type[T])
new Baz('[String])
new Baz(Type[String])

}
2 changes: 1 addition & 1 deletion tests/pos-macros/i6140.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ sealed trait Trait[T] {
}

object O {
def fn[T:Type](t : Trait[T])(using QuoteContext): Type[T] = '[t.t]
def fn[T:Type](t : Trait[T])(using QuoteContext): Type[T] = Type[t.t]
}
2 changes: 1 addition & 1 deletion tests/pos-macros/i6142.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object O {
def foo(using QuoteContext) = {
type T
implicit val _: scala.quoted.Type[T] = ???
'[List[T]]
Type[List[T]]
()
}
}
2 changes: 1 addition & 1 deletion tests/pos-macros/i6210/Macros_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Macro {
${ impl[A, B] }

def impl[A : Type, B : Type](using QuoteContext): Expr[Any] = {
val t = '[Map[A, B]]
val t = Type[Map[A, B]]
'{
new Object().asInstanceOf[$t]
???.asInstanceOf[$t]
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/i7048b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ trait IsExpr {
val foo: IsExpr = ???

def g()(using QuoteContext): Unit = {
val a = '[foo.Underlying]
val a = Type[foo.Underlying]
()
}
2 changes: 1 addition & 1 deletion tests/pos-macros/i7264.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import scala.quoted._
class Foo {
def f[T2](t: Type[T2])(using QuoteContext) = t match {
case '[ *:[Int, $T] ] =>
'[ *:[Int, T] ]
Type[ *:[Int, T] ]
}
}
2 changes: 1 addition & 1 deletion tests/pos-macros/i7264b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import scala.quoted._
class Foo {
def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match {
case '{ $x: *:[Int, $t] } =>
'[ *:[Int, t] ]
Type[ *:[Int, t] ]
}
}
2 changes: 1 addition & 1 deletion tests/pos-macros/i7264c.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class Foo {
case '{ $x: $T0 } =>
Type[T0] match
case '[ *:[Int, $T] ] =>
'[ *:[Int, T] ]
Type[ *:[Int, T] ]
}
}
2 changes: 1 addition & 1 deletion tests/pos-macros/i7405.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Foo {
type X = Int // Level 1
val x: X = ???
${
val t: Type[X] = '[X] // Level 0
val t: Type[X] = Type[X] // Level 0
'{ val y: $t = x }
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/i7405b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Foo {
val x: X = ???
type Z = x.Y
${
val t: Type[Z] = '[Z]
val t: Type[Z] = Type[Z]
'{ val y: $t = x.y }
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/pos-macros/i8100.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def f[T: Type](using QuoteContext) =
'{
val m = $mm
type ME = m.E
${ g[ME](using '[ME]) }
${ g[m.E](using '[ME]) }
${ g[ME](using '[m.E]) }
${ g[m.E](using '[m.E]) }
${ g[ME](using Type[ME]) }
${ g[m.E](using Type[ME]) }
${ g[ME](using Type[m.E]) }
${ g[m.E](using Type[m.E]) }
// ${ g[ME] } // FIXME: issue seems to be in ReifyQuotes
// ${ g[m.E] } // FIXME: issue seems to be in ReifyQuotes
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/i8302.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted._
def foo[T](using qctx: QuoteContext, tpe: Type[T]): Expr[Any] =
'{ (using qctx: QuoteContext) =>
type TT = T
val t = '[TT]
val t = Type[TT]
???
}

10 changes: 5 additions & 5 deletions tests/pos-macros/i9518/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ inline def shift : Unit = ${ shiftTerm }
def shiftTerm(using QuoteContext): Expr[Unit] = {
import qctx.reflect._
val nTree = '{ ??? : CB[Int] }.unseal
val tp1 = '[CB[Int]].unseal.tpe
val tp2 = '[([X] =>> CB[X])[Int]].unseal.tpe
val ta = '[[X] =>> CB[X]]
val tp3 = '[ta.Underlying[Int]].unseal.tpe
val tp4 = '[CB].unseal.tpe.appliedTo(TypeRepr.of[Int])
val tp1 = Type[CB[Int]].unseal.tpe
val tp2 = Type[([X] =>> CB[X])[Int]].unseal.tpe
val ta = Type[[X] =>> CB[X]]
val tp3 = Type[ta.Underlying[Int]].unseal.tpe
val tp4 = Type[CB].unseal.tpe.appliedTo(TypeRepr.of[Int])
assert(nTree.tpe <:< tp1)
assert(nTree.tpe <:< tp2)
assert(nTree.tpe <:< tp3)
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/macro-with-type/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import scala.quoted._
object Macro {
inline def ff: Unit = ${impl('[Int])}
inline def ff: Unit = ${impl(Type[Int])}
def impl(t: Type[Int])(using QuoteContext): Expr[Unit] = '{}
}
6 changes: 3 additions & 3 deletions tests/pos-macros/quote-1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Test(using QuoteContext) {
val z = $x
}

f('{2})('[Int])
f('{ true })('[Boolean])
f('{2})(Type[Int])
f('{ true })(Type[Boolean])

def g(es: Expr[String], t: Type[String]) =
f('{ ($es + "!") :: Nil })('[List[$t]])
f('{ ($es + "!") :: Nil })(Type[List[t.Underlying]])
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import scala.quoted._


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

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


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

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


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

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

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

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