Skip to content

Commit

Permalink
Regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Nov 5, 2024
1 parent 12f75a9 commit 1d4db7f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
14 changes: 14 additions & 0 deletions tests/pos/i17631.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,17 @@ def `i18388`: Unit =
val _ = pred
()
val _ = func

trait L[T]:
type E

def `i19748` =
type Warn1 = [T] => (l: L[T]) => T => l.E
type Warn2 = [T] => L[T] => T
type Warn3 = [T] => T => T
def use(x: (Warn1, Warn2, Warn3)) = x
use

type NoWarning1 = [T] => (l: L[T]) => T => l.E
type NoWarning2 = [T] => L[T] => T
type NoWarning3 = [T] => T => T
15 changes: 12 additions & 3 deletions tests/pos/i18366.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
//> using options -Xfatal-warnings -Wunused:all
//> using options -Werror -Wunused:all

trait Builder {
def foo(): Unit
}

def repro =
def `i18366` =
val builder: Builder = ???
import builder.{foo => bar}
bar()
bar()

import java.io.DataOutputStream

val buffer: DataOutputStream = ???

import buffer.{write => put}

def `i17315` =
put(0: Byte)
28 changes: 28 additions & 0 deletions tests/warn/i17371.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//> using options -Wunused:all

class A
class B

def Test() =
val ordA: Ordering[A] = ???
val ordB: Ordering[B] = ???
val a: A = ???
val b: B = ???

import ordA.given
val _ = a > a

import ordB.given
val _ = b < b

// unminimized OP
trait Circular[T] extends Ordering[T]
trait Turns[C: Circular, T] extends Ordering[T]:
extension (turns: T) def extract: C

def f[K, T](start: T, end: T)(using circular: Circular[K], turns: Turns[K, T]): Boolean =
import turns.given
if start > end then throw new IllegalArgumentException("start must be <= end")

import circular.given
start.extract < end.extract
14 changes: 14 additions & 0 deletions tests/warn/i18313.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//> using options -Wunused:imports

import scala.deriving.Mirror

case class Test(i: Int, d: Double)
case class Decoder(d: Product => Test)

// OK, no warning returned
//val ok = Decoder(summon[Mirror.Of[Test]].fromProduct)
//
// returns warning:
// [warn] unused import
// [warn] import scala.deriving.Mirror
val d = Decoder(d = summon[Mirror.Of[Test]].fromProduct) // no warn

0 comments on commit 1d4db7f

Please sign in to comment.