Skip to content
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

TASTy Reader: support Scala 3.4 [ci: last-only] #10670

Merged
merged 19 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
prepare for syntax changes in Scala 3.4.0
  • Loading branch information
bishabosha committed Jan 22, 2024
commit f0a484b865af6a37ad418623d20d89362d41bb81
6 changes: 3 additions & 3 deletions test/tasty/neg/src-3/HelloWorld.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package helloworld
object HelloWorld {
inline val msg1 = "Hello, World!"
def acceptsOnlyMsg1(m: msg1.type): String = m + m
def higherBounded2[T <: List[_ <: Int]](f: T): T = f
def higherBounded3[T <: List[List[_ <: Int]]](f: T): T = f
def higherBounded4[T <: Either[_ <: Int, String]](f: T): T = f
def higherBounded2[T <: List[? <: Int]](f: T): T = f
def higherBounded3[T <: List[List[? <: Int]]](f: T): T = f
def higherBounded4[T <: Either[? <: Int, String]](f: T): T = f
def higherBounded5[F[+_]] = ???
def higherBounded6[F[-_]] = ???
inline def inlineMethod(inline i: Int): Int = i
Expand Down
10 changes: 5 additions & 5 deletions test/tasty/neg/src-3/printing/printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ trait Env[+I] { self =>
}

object Env {
type JVMEnv = AnyHash with AnyClassName
type JVMEnv = AnyHash & AnyClassName
def runPrinter[I,O](printer: => Printer[I, O])(env: Env[I]): O = printer.println(env.env)
}

trait JVMEnvLive extends Env[AnyClassName with AnyHash] {
final val env: AnyClassName with AnyHash = new AnyClassName with AnyHash
trait JVMEnvLive extends Env[AnyClassName & AnyHash] {
final val env: AnyClassName & AnyHash = new AnyClassName with AnyHash
}

trait AnyHashLive extends Env[AnyHash] {
Expand All @@ -23,8 +23,8 @@ trait Printer[-I, +O] {
}

object Printer {
object ObjectToString extends Printer[AnyClassName with AnyHash, Any => String] {
def println(in: AnyClassName with AnyHash): Any => String = x =>
object ObjectToString extends Printer[AnyClassName & AnyHash, Any => String] {
def println(in: AnyClassName & AnyHash): Any => String = x =>
s"${in.anyClassName(x)}@${in.anyHash(x)}"
}
object HashToString extends Printer[AnyHash, Any => String] {
Expand Down
2 changes: 1 addition & 1 deletion test/tasty/run/src-2/tastytest/TestBiFunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object TestBiFunctor extends Suite("TestBiFunctor") {
def toStringOnBiFunctor[F[_,_]: BiFunctor, A,B](fab: F[A,B]): F[String, String] =
implicitly[BiFunctor[F]].bimap(fab)(_.toString, _.toString)

def toStringOnBiFunctorT2[F[_,_] <: Tuple2[_,_]: BiFunctorT2, A,B](fab: F[A,B]): F[String, String] =
def toStringOnBiFunctorT2[F[X,Y] <: Tuple2[X,Y]: BiFunctorT2, A,B](fab: F[A,B]): F[String, String] =
implicitly[BiFunctorT2[F]].bimap(fab)(_.toString, _.toString)

test(assert(toStringOnBiFunctor((true,1)) === ("true","1")))
Expand Down
2 changes: 1 addition & 1 deletion test/tasty/run/src-3/tastytest/BiFunctorT2.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package tastytest

trait BiFunctorT2[F[_,_] <: Tuple2[_,_]] {
trait BiFunctorT2[F[X,Y] <: Tuple2[X,Y]] {
def bimap[A,B,C,D](fab: F[A,B])(f: A => C, g: B => D): F[C,D]
}
2 changes: 1 addition & 1 deletion test/tasty/run/src-3/tastytest/FunctorL.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package tastytest

trait FunctorL[F[_] <: List[_]] {
trait FunctorL[F[X] <: List[X]] {
extension [A,B](fa: F[A]) def map(f: A => B): F[B]
}
10 changes: 5 additions & 5 deletions test/tasty/run/src-3/tastytest/HelloWorld.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ object HelloWorld {
def the[T](implicit x: T): x.type = x
def bounded[T >: Null <: String](a: T): String = a + a
def higher[F[_], G[_]](fInt: F[Int])(implicit ev: F[Int] <:< G[Int]): G[Int] = ev(fInt)
def higherBounded[F[_] >: Null <: List[_], A](f: F[A]): F[A] = f
def higherBounded2[T <: List[_ <: Int]](f: T): T = f
def higherBounded3[T <: List[List[_ <: Int]]](f: T): T = f
def higherBounded4[T <: Either[_ <: Int, String]](f: T): T = f
def higherBounded[F[_] >: Null <: List[?], A](f: F[A]): F[A] = f
def higherBounded2[T <: List[? <: Int]](f: T): T = f
def higherBounded3[T <: List[List[? <: Int]]](f: T): T = f
def higherBounded4[T <: Either[? <: Int, String]](f: T): T = f
def higherBounded5[F[+_], A](fa: F[A]): F[A] = fa
def higherBounded6[F[-_], A](fa: F[A]): F[A] = fa
def higherBounded7[F[_] <: Either[_ <: Int, _], A](f: F[A]): f.type = f
def higherBounded7[F[_] <: Either[? <: Int, ?], A](f: F[A]): f.type = f
def repeated(s: String*): String = s.mkString(",")
val func: Int => String = _.toString
def func1[A]: A => A = x => x
Expand Down
8 changes: 4 additions & 4 deletions test/tasty/run/src-3/tastytest/IntersectionErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ object IntersectionErasure {

@FunctionalInterface
abstract class IntersectionSAM {
def apply(arg: B with A): B with A
def apply(arg: B & A): B & A
}

final class IntersectionVC(val unwrapped: B with A) extends AnyVal {
def matchesInternal(that: B with A): Boolean = that == unwrapped
final class IntersectionVC(val unwrapped: B & A) extends AnyVal {
def matchesInternal(that: B & A): Boolean = that == unwrapped
def matches(that: IntersectionVC): Boolean = this == that
}

final class IntersectionVCParametric[T <: B with A](val unwrapped: T) extends AnyVal {
final class IntersectionVCParametric[T <: B & A](val unwrapped: T) extends AnyVal {
def matchesInternal(that: T): Boolean = that == unwrapped
def matches(that: IntersectionVCParametric[T]): Boolean = this == that
}
Expand Down
2 changes: 1 addition & 1 deletion test/tasty/run/src-3/tastytest/Intersections.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Intersections {
trait C
trait D

type AwithB = A with B
type AwithB = A & B // used to be A with B (now a syntax error)
type AandB = A & B
type AandBandCandD = A & B & C & D

Expand Down
2 changes: 1 addition & 1 deletion test/tasty/run/src-3/tastytest/Mutable.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tastytest

class Mutable {
private[this] var _foo = 33
private var _foo = 33
def foo_=(foo: Int): Unit = { _foo = foo }
def foo: Int = _foo

Expand Down
14 changes: 7 additions & 7 deletions test/tasty/run/src-3/tastytest/Refinements.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ object Refinements {
}
}

class Qux[A, B, F <: FooT with FooU { type T = A; type U = B }] {
class Qux[A, B, F <: FooT & FooU { type T = A; type U = B }] {
def qux(member: F): (member.T, member.U) = {
(member.fooT, member.fooU)
}
}

class Zot[A, B] {
def zot[F <: FooT with FooU { type T = A; type U = B } ](member: F): (member.T, member.U) = {
def zot[F <: FooT & FooU { type T = A; type U = B } ](member: F): (member.T, member.U) = {
(member.fooT, member.fooU)
}
}
Expand Down Expand Up @@ -151,12 +151,12 @@ object Refinements {
}

class PickOneRefinement_1[S <: SpecialRefinement { def pickOne(as: String*): Option[String] }] {
def run(s: S, as: String*): Option[String] = s.pickOne(as:_*)
def run(s: S, as: String*): Option[String] = s.pickOne(as*)
}

class PickOneRefinement_2 {
def run[S <: SpecialRefinement { def pickOne(as: String*): Option[String] }](s: S, as: String*): Option[String] =
s.pickOne(as:_*)
s.pickOne(as*)
}

class Structural1[M <: { val output: Int } ] {
Expand All @@ -178,15 +178,15 @@ object Refinements {
extends scala.Selectable {
private val map = methods.toMap

def applyDynamic(name: String, paramClasses: Class[_]*)(args: Any*): Any =
def applyDynamic(name: String, paramClasses: Class[?]*)(args: Any*): Any =
map.get(name, paramClasses) match
case Some(f) => f(args)
case None => throw NoSuchMethodException(s"$name(${paramClasses.mkString(",")})")

}
object MethodSelectable {
type Method = ((String, Seq[Class[_]]), Seq[Any] => Any)
def method(name: String, paramClasses: Class[_]*)(impl: Seq[Any] => Any): Method =
type Method = ((String, Seq[Class[?]]), Seq[Any] => Any)
def method(name: String, paramClasses: Class[?]*)(impl: Seq[Any] => Any): Method =
((name, paramClasses), impl)
}

Expand Down
4 changes: 2 additions & 2 deletions test/tasty/run/src-3/tastytest/Reflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ object Reflection {

def reflectionInvokerIdentity(ctx: reflectshims.Context)(tree: ctx.TreeShim): ctx.TreeShim = tree

class Invoker[C <: reflectshims.Context with Singleton](val ctx: C)(root: ctx.TreeShim) {
class Invoker[C <: reflectshims.Context & Singleton](val ctx: C)(root: ctx.TreeShim) {
def tree: ctx.TreeShim = root
}

class InvokerSAM[C <: reflectshims.Context with Singleton](val ctx: C) {
class InvokerSAM[C <: reflectshims.Context & Singleton](val ctx: C) {

@FunctionalInterface
trait TreeFn {
Expand Down
2 changes: 1 addition & 1 deletion test/tasty/run/src-3/tastytest/SAMErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object SAMErasure {

trait TreeShimSAMApi extends Product

type TreeShimSAM >: Null <: AnyRef with TreeShimSAMApi
type TreeShimSAM >: Null <: AnyRef & TreeShimSAMApi

implicit val TreeShimSAMTag: reflect.ClassTag[TreeShimSAM] =
reflect.classTag[TreeShimSAMApi].asInstanceOf[reflect.ClassTag[TreeShimSAM]]
Expand Down
2 changes: 1 addition & 1 deletion test/tasty/run/src-3/tastytest/TypeRefIns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package tastytest

object TypeRefIns {
type Id[A] >: A
val a: Array[_ >: Id[Int]] = Array(1, 2)
val a: Array[? >: Id[Int]] = Array(1, 2)
val b = a(0) // inferred TYPEREFin
}
Loading