Skip to content

Commit

Permalink
Prepare test sources for Scala 3.4.0.
Browse files Browse the repository at this point in the history
Avoid deprecated features, except for places where we specifically
test the shape of those deprecated features, in which case we use
`@nowarn`.
  • Loading branch information
sjrd committed Feb 20, 2024
1 parent c82b1bd commit 1a61e54
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class PositionSuite extends RestrictedUnpicklingSuite {
| case _ => -x
| }""".stripMargin,
"""xs match
| case List(elems: _*) => 0
| case _ => 1""".stripMargin
| case List(elems*) => 0
| case _ => 1""".stripMargin
)
)

Expand All @@ -132,8 +132,8 @@ class PositionSuite extends RestrictedUnpicklingSuite {
"case 3 | 4 | 5 if x < 5 => 0",
"case _ if (x % 2 == 0) => x / 2",
"case _ => -x",
"case List(elems: _*) => 0",
"case _ => 1"
"case List(elems*) => 0",
"case _ => 1"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package simple_trees

import scala.annotation.nowarn

@nowarn("msg=The \\[this\\] qualifier will be deprecated")
class AccessModifiers(
localParam: Int,
private[this] val privateThisParam: Int,
Expand Down
2 changes: 1 addition & 1 deletion test-sources/src/main/scala/simple_trees/AnyMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class AnyMethods:
def testTypeCast(bag: Bag { val m: Int }): Any = bag.m // bag.selectDynamic("m").$asInstanceOf$[Int]

def testGetClassAny(x: Any): Any = x.getClass()
def testGetClassProduct(x: Product): Class[_ <: Product] = x.getClass()
def testGetClassProduct(x: Product): Class[? <: Product] = x.getClass()
def testGetClassInt(x: Int): Class[Int] = x.getClass() // nonsensical, but what can we do?
end AnyMethods
4 changes: 2 additions & 2 deletions test-sources/src/main/scala/simple_trees/Match.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class Match {
}

def g(xs: Seq[Int]): Int = xs match
case List(elems: _*) => 0
case _ => 1
case List(elems*) => 0
case _ => 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ type RecursiveMatchType[A <: Tuple] <: Tuple = A match
object RecursiveMatchType:
inline def rec[A <: Tuple](a: A): RecursiveMatchType[A] =
inline a match
case b: (hd *: tl) => b.head *: rec(b.tail)
case b: (hd *: tl) => headOf(b) *: rec(tailOf(b))
case _: EmptyTuple => EmptyTuple

def headOf[H, T <: Tuple](t: H *: T): H = t.head
def tailOf[H, T <: Tuple](t: H *: T): T = t.tail
end RecursiveMatchType

// must be in a separate TASTy file to trigger issue #401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class RefinedTypeTree {

def polyTypeRefinement(c: C { type Poly[X] = List[(X, X)] }) = c

// With an additional 'with'
// With an additional '&'

trait AndTypeA
trait AndTypeB extends AndTypeA

def andType(): AndTypeA with AndTypeB { def foo: String } =
def andType(): (AndTypeA & AndTypeB) { def foo: String } =
new AndTypeA with AndTypeB { def foo: String = toString }
}
10 changes: 5 additions & 5 deletions test-sources/src/main/scala/simple_trees/TypeRefIn.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package simple_trees
class TypeRefIn {
def withArray[U](arr: Array[U]): Unit = ()

def withArrayOfSubtype[T](arr: Array[_ <: T]): Unit = withArray(arr)
def withArrayOfSubtype[T](arr: Array[? <: T]): Unit = withArray(arr)

def withArrayAnyRef[U <: AnyRef](arr: Array[U]): Unit = ()

def withArrayOfSubtypeAnyRef[T <: AnyRef](arr: Array[_ <: T]): Unit = withArrayAnyRef(arr)
def withArrayOfSubtypeAnyRef[T <: AnyRef](arr: Array[? <: T]): Unit = withArrayAnyRef(arr)

def withArrayAnyVal[U <: AnyVal](arr: Array[U]): Unit = ()

def withArrayOfSubtypeAnyVal[T <: AnyVal](arr: Array[_ <: T]): Unit = withArrayAnyVal(arr)
def withArrayOfSubtypeAnyVal[T <: AnyVal](arr: Array[? <: T]): Unit = withArrayAnyVal(arr)

def withArrayList[U <: List[?]](arr: Array[U]): Unit = ()

def withArrayOfSubtypeList[T <: List[?]](arr: Array[_ <: T]): Unit = withArrayList(arr)
def withArrayOfSubtypeList[T <: List[?]](arr: Array[? <: T]): Unit = withArrayList(arr)

def withArrayExactAny(array: Array[Any]): Unit = ()

Expand All @@ -25,5 +25,5 @@ class TypeRefIn {

def withListOfSubtypeOfInt[T <: Int](x: List[T]): Unit = ()

def withListOfSubtypeOfSubtypeOfInt[T <: Int](x: List[_ <: T]): Unit = withListOfSubtypeOfInt(x)
def withListOfSubtypeOfSubtypeOfInt[T <: Int](x: List[? <: T]): Unit = withListOfSubtypeOfInt(x)
}
4 changes: 4 additions & 0 deletions test-sources/src/main/scala/simple_trees/Uninitialized.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package simple_trees

import scala.annotation.nowarn

import scala.compiletime.uninitialized as renamedUninitialized

abstract class Uninitialized:
var uninitializedRHS: Product = scala.compiletime.uninitialized
var renamedUninitializedRHS: String = renamedUninitialized

@nowarn("msg=uninitialized")
var wildcardRHS: Int = _

var abstractVar: Int // confidence check: an abstract var is marked Deferred
Expand Down
2 changes: 1 addition & 1 deletion test-sources/src/main/scala/simple_trees/ValueClass.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package simple_trees

final class ValueClass(val it: List[_]) extends AnyVal {
final class ValueClass(val it: List[?]) extends AnyVal {
def myLength: Int = it.size
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package simple_trees

class GenericWithTypeBound[T <: AnyKind]

class WildcardTypeApplication(anyList: List[_]) extends GenericWithTypeBound[_]
class WildcardTypeApplication(anyList: List[?]) extends GenericWithTypeBound[?]

0 comments on commit 1a61e54

Please sign in to comment.