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
Prev Previous commit
Next Next commit
test parameterised types and bounds
  • Loading branch information
bishabosha committed Feb 12, 2024
commit a18de297340efec10eb5d0beccb12a3f0d9219ee
33 changes: 33 additions & 0 deletions test/tasty/neg-pipelined/src-2/tastytest/TestBounds.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
TestBounds_fail.scala:6: error: inferred type arguments [Int] do not conform to method m_ARRAY's type parameter bounds [T <: lib.Bounds.C with lib.Bounds.I]
Bounds.m_ARRAY(Array(23)) // error
^
TestBounds_fail.scala:6: error: type mismatch;
found : Array[Int]
required: Array[T]
Bounds.m_ARRAY(Array(23)) // error
^
TestBounds_fail.scala:7: error: inferred type arguments [String] do not conform to method m_ARRAY's type parameter bounds [T <: lib.Bounds.C with lib.Bounds.I]
Bounds.m_ARRAY(Array("abc")) // error
^
TestBounds_fail.scala:7: error: type mismatch;
found : Array[String]
required: Array[T]
Bounds.m_ARRAY(Array("abc")) // error
^
TestBounds_fail.scala:8: error: inferred type arguments [Int] do not conform to method m's type parameter bounds [T <: lib.Bounds.C with lib.Bounds.I]
Bounds.m(23) // error
^
TestBounds_fail.scala:8: error: type mismatch;
found : Int(23)
required: T
Bounds.m(23) // error
^
TestBounds_fail.scala:9: error: inferred type arguments [String] do not conform to method m's type parameter bounds [T <: lib.Bounds.C with lib.Bounds.I]
Bounds.m("abc") // error
^
TestBounds_fail.scala:9: error: type mismatch;
found : String("abc")
required: T
Bounds.m("abc") // error
^
8 errors
10 changes: 10 additions & 0 deletions test/tasty/neg-pipelined/src-2/tastytest/TestBounds_fail.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package tastytest

import lib.Bounds

object TestBounds extends scala.App {
Bounds.m_ARRAY(Array(23)) // error
Bounds.m_ARRAY(Array("abc")) // error
Bounds.m(23) // error
Bounds.m("abc") // error
}
14 changes: 14 additions & 0 deletions test/tasty/neg-pipelined/src-3/lib/Bounds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package lib;

public class Bounds {

public static class C {}

public static interface I {}

public static class A extends C implements I {}

public static <T extends C & I> void m(T t) {}
public static <T extends C & I> void m_ARRAY(T[] t) {}

}
32 changes: 32 additions & 0 deletions test/tasty/run-pipelined/src-2/tastytest/TestBounds.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package tastytest

import lib.Bounds
import lib.Bounds.{A, C, I, G, F, FExtra}

object TestBounds extends scala.App {
class A1 extends C with I
class G1 extends F[G1] with FExtra[G1]

val a: A = new A
val a1: A1 = new A1
val g: G = new G
val g1: G1 = new G1

Bounds.m(a) // Testing A <: C with I when reading from Java TASTy.
Bounds.m_ARRAY(Array(a)) // Testing A <: C with I when reading from Java TASTy.
Bounds.m_WILDCARD_SUB(a.getClass) // Testing A <: C when reading from Java TASTy.
Bounds.m_WILDCARD_SUP(classOf[C]) // Testing C >: A when reading from Java TASTy.

Bounds.m(a1) // Testing A1 <: C with I when reading from Java TASTy.
Bounds.m_ARRAY(Array(a1)) // Testing A1 <: C with I when reading from Java TASTy.
Bounds.m_WILDCARD_SUB(a1.getClass) // Testing A1 <: C when reading from Java TASTy.

Bounds.f(g) // Testing G <: F[G] with FExtra[G] when reading from Java TASTy.
Bounds.f_ARRAY(Array(g)) // Testing G <: F[G] with FExtra[G] when reading from Java TASTy.
Bounds.f_WILDCARD_SUB(g.getClass) // Testing G <: F[_] when reading from Java TASTy.
Bounds.f_WILDCARD_SUP(classOf[F[_]]) // Testing F[_] >: G when reading from Java TASTy.

Bounds.f(g1) // Testing G1 <: F[G] with FExtra[G] when reading from Java TASTy.
Bounds.f_ARRAY(Array(g1)) // Testing G1 <: F[G] with FExtra[G] when reading from Java TASTy.
Bounds.f_WILDCARD_SUB(g1.getClass) // Testing G1 <: F[_] when reading from Java TASTy.
}
28 changes: 28 additions & 0 deletions test/tasty/run-pipelined/src-3/lib/Bounds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package lib;

public class Bounds {

public static class C {}

public static interface I {}

public static class A extends C implements I {}

public static <T extends C & I> void m(T t) {}
public static <T extends C & I> void m_ARRAY(T[] t) {}
public static void m_WILDCARD_SUB(Class<? extends C> c) {}
public static void m_WILDCARD_SUP(Class<? super A> c) {}


public static class F<T extends F<T>> {}

public static interface FExtra<T extends F<T>> {}

public static class G extends F<G> implements FExtra<G> {}

public static <T extends F<T> & FExtra<T>> void f(T t) {}
public static <T extends F<T> & FExtra<T>> void f_ARRAY(T[] t) {}
public static void f_WILDCARD_SUB(Class<? extends F<?>> c) {}
public static void f_WILDCARD_SUP(Class<? super G> c) {}

}