Skip to content

Commit

Permalink
Partial comversion to using clauses
Browse files Browse the repository at this point in the history
Convert all files that had a conflict in the last commit, which reverted
`with` clauses to `given` parameters.
  • Loading branch information
odersky committed Jan 31, 2020
1 parent ad66401 commit 9e86124
Show file tree
Hide file tree
Showing 132 changed files with 260 additions and 261 deletions.
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-1/Macro_1.scala
Expand Up @@ -3,7 +3,7 @@ import scala.quoted.matching._

inline def f: Any = ${ fImpl }

private def fImpl with (qctx: QuoteContext) : Expr[Unit] = {
private def fImpl (using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
searchImplicit(('[A]).unseal.tpe) match {
case x: ImplicitSearchSuccess =>
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-2/Macro_1.scala
Expand Up @@ -3,7 +3,7 @@ import scala.quoted.matching._

inline def f: Any = ${ fImpl }

private def fImpl with (qctx: QuoteContext) : Expr[Unit] = {
private def fImpl (using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
searchImplicit(('[A]).unseal.tpe) match {
case x: ImplicitSearchSuccess =>
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/delegate-match-3/Macro_1.scala
Expand Up @@ -3,7 +3,7 @@ import scala.quoted.matching._

inline def f: Any = ${ fImpl }

private def fImpl with (qctx: QuoteContext) : Expr[Unit] = {
private def fImpl(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
searchImplicit(('[A]).unseal.tpe) match {
case x: ImplicitSearchSuccess =>
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6432/Macro_1.scala
Expand Up @@ -6,7 +6,7 @@ import scala.quoted.matching._
object Macro {
inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) }

def impl(sc: Expr[StringContext]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
sc match {
case '{ StringContext(${ExprSeq(parts)}: _*) } =>
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6432b/Macro_1.scala
Expand Up @@ -6,7 +6,7 @@ import scala.quoted.matching._
object Macro {
inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) }

def impl(sc: Expr[StringContext]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
sc match {
case '{ StringContext(${ExprSeq(parts)}: _*) } =>
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6976/Macro_1.scala
Expand Up @@ -7,7 +7,7 @@ import scala.tasty._
object macros {
inline def mcr(x: => Any) = ${mcrImpl('x)}

def mcrImpl(body: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = {
def mcrImpl(body: Expr[Any])(using ctx: QuoteContext) : Expr[Any] = {
import ctx.tasty.{_, given _}
body.unseal match { case Block(_, _) => '{2} }
}
Expand Down
14 changes: 7 additions & 7 deletions tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala
Expand Up @@ -7,10 +7,10 @@ object E {

inline def eval[T](inline x: E[T]): T = ${ impl('x) }

def impl[T: Type](x: Expr[E[T]]) with QuoteContext : Expr[T] = x.value.lift
def impl[T: Type](x: Expr[E[T]]) (using QuoteContext): Expr[T] = x.value.lift

implicit def ev1[T: Type]: ValueOfExpr[E[T]] = new ValueOfExpr {
def apply(x: Expr[E[T]]) with QuoteContext : Option[E[T]] = x match {
def apply(x: Expr[E[T]]) (using QuoteContext): Option[E[T]] = x match {
case '{ I(${Const(n)}) } => Some(I(n).asInstanceOf[E[T]])
case '{ Plus[T](${Value(x)}, ${Value(y)})(given $op) } if op.matches('{Plus2.IPlus}) => Some(Plus(x, y)(given Plus2.IPlus.asInstanceOf[Plus2[T]]).asInstanceOf[E[T]])
case _ => None
Expand All @@ -23,24 +23,24 @@ object E {
}

trait E[T] {
def lift with QuoteContext : Expr[T]
def lift (using QuoteContext): Expr[T]
}

case class I(n: Int) extends E[Int] {
def lift with QuoteContext : Expr[Int] = n
def lift (using QuoteContext): Expr[Int] = n
}

case class Plus[T](x: E[T], y: E[T])(implicit op: Plus2[T]) extends E[T] {
def lift with QuoteContext : Expr[T] = op(x.lift, y.lift)
def lift (using QuoteContext): Expr[T] = op(x.lift, y.lift)
}

trait Op2[T] {
def apply(x: Expr[T], y: Expr[T]) with QuoteContext : Expr[T]
def apply(x: Expr[T], y: Expr[T]) (using QuoteContext): Expr[T]
}

trait Plus2[T] extends Op2[T]
object Plus2 {
implicit case object IPlus extends Plus2[Int] {
def apply(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{$x + $y}
def apply(x: Expr[Int], y: Expr[Int]) (using QuoteContext): Expr[Int] = '{$x + $y}
}
}
2 changes: 1 addition & 1 deletion tests/neg-macros/inline-option/Macro_1.scala
Expand Up @@ -2,7 +2,7 @@
import scala.quoted._

object Macro {
def impl(opt: Expr[Option[Int]]) with QuoteContext : Expr[Int] = opt.value match {
def impl(opt: Expr[Option[Int]]) (using QuoteContext): Expr[Int] = opt.value match {
case Some(i) => Expr(i)
case None => '{-1}
}
Expand Down
44 changes: 22 additions & 22 deletions tests/neg-macros/inline-tuples-1/Macro_1.scala
Expand Up @@ -3,26 +3,26 @@ import scala.quoted._
import scala.quoted.autolift.{given _}

object Macros {
def tup1(tup: Expr[Tuple1[Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup2(tup: Expr[Tuple2[Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup1(tup: Expr[Tuple1[Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup2(tup: Expr[Tuple2[Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum
}
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-6/Foo.scala
Expand Up @@ -4,7 +4,7 @@ object Foo {

inline def myMacro(): Unit = ${ aMacroImplementation }

def aMacroImplementation with (qctx: QuoteContext) : Expr[Unit] = {
def aMacroImplementation(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{given, _}
error("some error", rootPosition)
throw new NoClassDefFoundError("Bar$")
Expand Down
4 changes: 2 additions & 2 deletions tests/neg-macros/quote-error-2/Macro_1.scala
Expand Up @@ -2,10 +2,10 @@ import quoted._

object Macro_1 {
inline def foo(inline b: Boolean): Unit = ${ fooImpl('b) }
def fooImpl(b: Expr[Boolean]) with QuoteContext: Expr[Unit] =
def fooImpl(b: Expr[Boolean])(using QuoteContext): Expr[Unit] =
'{println(${msg(b.value)})}

def msg(b: Boolean) with (qctx: QuoteContext) : Expr[String] =
def msg(b: Boolean)(using qctx: QuoteContext): Expr[String] =
if (b) '{"foo(true)"}
else { qctx.error("foo cannot be called with false"); '{ ??? } }

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-error/Macro_1.scala
Expand Up @@ -2,7 +2,7 @@ import quoted._

object Macro_1 {
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
def fooImpl(b: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] =
def fooImpl(b: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] =
if (b.value) '{println("foo(true)")}
else { qctx.error("foo cannot be called with false"); '{ ??? } }
}
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-exception/Macro_1.scala
Expand Up @@ -2,7 +2,7 @@ import quoted._

object Macro_1 {
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
def fooImpl(b: Expr[Boolean]) with QuoteContext : Expr[Unit] =
def fooImpl(b: Expr[Boolean]) (using QuoteContext): Expr[Unit] =
if (b.value) '{println("foo(true)")}
else ???
}
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-whitebox/Macro_1.scala
Expand Up @@ -2,7 +2,7 @@ import scala.quoted._

object Macros {
inline def defaultOf(inline str: String) <: Any = ${ defaultOfImpl('str) }
def defaultOfImpl(str: Expr[String]) with QuoteContext : Expr[Any] = str.value match {
def defaultOfImpl(str: Expr[String]) (using QuoteContext): Expr[Any] = str.value match {
case "int" => '{1}
case "string" => '{"a"}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-assert-1/quoted_1.scala
Expand Up @@ -12,7 +12,7 @@ object Asserts {
inline def macroAssert(inline cond: Boolean): Unit =
${impl('cond)}

def impl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}

val tree = cond.unseal
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-assert-2/quoted_1.scala
Expand Up @@ -12,7 +12,7 @@ object Asserts {
inline def macroAssert(inline cond: Boolean): Unit =
${ impl('cond) }

def impl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}

val tree = cond.unseal
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-error/quoted_1.scala
Expand Up @@ -4,7 +4,7 @@ object Macros {

inline def fun(x: Any): Unit = ${ impl('x) }

def impl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
error("here is the the argument is " + x.unseal.underlyingArgument.show, x.unseal.underlyingArgument.pos)
'{}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/tasty-macro-positions/quoted_1.scala
Expand Up @@ -4,7 +4,7 @@ object Macros {

inline def fun(x: Any): Unit = ${ impl('x) }

def impl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
val pos = x.unseal.underlyingArgument.pos
error("here is the the argument is " + x.unseal.underlyingArgument.show, pos)
Expand Down
Expand Up @@ -9,7 +9,7 @@ object Macro {

object FIntepolator {

def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = {
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = {
import qctx.tasty.{_, given _}
error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos)
'{ ($strCtxExpr).s($argsExpr: _*) }
Expand Down
Expand Up @@ -8,7 +8,7 @@ object Macro {
}

object FIntepolator {
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = {
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = {
import qctx.tasty.{_, given _}
error("there are no args", argsExpr.unseal.underlyingArgument.pos)
'{ ($strCtxExpr).s($argsExpr: _*) }
Expand Down
5 changes: 2 additions & 3 deletions tests/neg/given-eta.scala
Expand Up @@ -3,9 +3,8 @@ trait D
type T
def trans(other: T): T

def h(d: D) with (x: d.T) (y: d.T) = (d.trans(x), d.trans(y))
def h(d: D)(using x: d.T)(y: d.T) = (d.trans(x), d.trans(y))

val z = h // error: no implicit argument of type d.T was found for parameter x of method h

def f with (D) (x: Int) = x // OK
def g with D (x: Int) = x // error // error
def f(using D)(x: Int) = x // OK
2 changes: 1 addition & 1 deletion tests/neg/i7048e.scala
Expand Up @@ -7,7 +7,7 @@ abstract class Test {
val getT: Type[T] = T // need this to avoid getting `null`
given Type[T] = getT

def foo with QuoteContext: Expr[Any] = {
def foo(using QuoteContext): Expr[Any] = {

val r = '{Option.empty[T]} // error

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i7425.scala
Expand Up @@ -2,7 +2,7 @@ class C { def f: Int = 0 }

trait D { def f(): Int = 0 }

def foo1(x: C & D) = x.f // error: method f must be called with () argument
def foo1(x: C & D) = x.f // error: method f must be called(using ) argument
def foo2(x: C | D) = x.f // error: value f is not a member of C | D
def foo3(x: D & C) = x.f // ok
def foo4(x: D | C) = x.f // error: value f is not a member of D | C
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i7919.scala
@@ -1,7 +1,7 @@
import scala.quoted._

object Test {
def staged[T] with (qctx: QuoteContext) = {
def staged[T](using qctx: QuoteContext) = {
import qctx.tasty.{_, given _}
given typeT as quoted.Type[T] // error
val tTypeTree = typeT.unseal
Expand Down
16 changes: 8 additions & 8 deletions tests/neg/implicit-params.scala
Expand Up @@ -3,26 +3,26 @@ object Test {
case class C(x: Int)
case class D(x: Int)

def f(x: Int) with (c: C) = x + c.x
def f(x: Int)(using c: C) = x + c.x

def g0(x: Int) with (c: C) (y: Int) = x + c.x + y
def g0(x: Int)(using c: C) (y: Int) = x + c.x + y

def g(x: Int) with (c: C) with D = x + c.x + summon[D].x // OK
def g(x: Int)(using c: C)(using D) = x + c.x + summon[D].x // OK

def h(x: Int) given () = x // error: missing return type

given C as C(11)
given D as D(11)

f(1)
f(1).with(C)
f.with(2) // error
f(1)(using C)
f(using 2) // error
f(1)(C) // error

g(1) // OK
g(1).with(C) // OK
g(1).with(C).with(D(0)) // OK
g(1).with(D) // error
g(1)(using C) // OK
g(1)(using C)(using D(0)) // OK
g(1)(using D) // error
g(1)(D) // error
g(1)(C)(D) // error
}
2 changes: 1 addition & 1 deletion tests/pending/run/tasty-comments/quoted_1.scala
Expand Up @@ -7,7 +7,7 @@ object Macros {
inline def printComment[T](t: => T): Unit =
${ impl('t) }

def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = {
def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}

val tree = x.unseal
Expand Down
10 changes: 5 additions & 5 deletions tests/pos-custom-args/erased/i7868.scala
Expand Up @@ -15,17 +15,17 @@ object Coproduct {
def cast: Head <:< Head +: Tail = summon[Head <:< Head +: Tail]
}

given atTail[Head, Tail, Value, NextIndex <: Int] with (atNext: At[Tail, Value, NextIndex]) : At[Head +: Tail, Value, S[NextIndex]] {
given atTail[Head, Tail, Value, NextIndex <: Int](using atNext: At[Tail, Value, NextIndex]) as At[Head +: Tail, Value, S[NextIndex]] {
val cast: Value <:< Head +: Tail = atNext.cast
}

given [A] with A as (() => A)= { () => summon[A]}
given [A](using A) as (() => A)= { () => summon[A]}
}

def upCast[A, B](a: A) with (erased evidence: (A <:< B) ): B = a.asInstanceOf[B]
def upCast[A, B](a: A)(using erased evidence: (A <:< B) ): B = a.asInstanceOf[B]

def from[Set, Value, Index <: Int](value: Value) with (erased at: At[Set, Value, Index]) : ValueOf[Index] ?=> Coproduct[Set, Value, Index] = {
Coproduct[Set, Value, Index](upCast(value: Value).with(at.cast.liftCo[[X] =>> Value & X]), valueOf[Index])
def from[Set, Value, Index <: Int](value: Value)(using erased at: At[Set, Value, Index]) : ValueOf[Index] ?=> Coproduct[Set, Value, Index] = {
Coproduct[Set, Value, Index](upCast(value: Value)(using at.cast.liftCo[[X] =>> Value & X]), valueOf[Index])
}

}
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/i6171/Macro_1.scala
Expand Up @@ -4,7 +4,7 @@ object scalatest {

inline def assert(x: => Any): Unit = ${ assertImpl('x) }

def assertImpl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = {
def assertImpl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty.{_, given _}
x.unseal.underlyingArgument
'{ () }
Expand Down

0 comments on commit 9e86124

Please sign in to comment.