Skip to content

Commit f1e3714

Browse files
Add regression tests
Closes #19749 Closes #18558 Closes #16208
1 parent fb15fe3 commit f1e3714

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

tests/pos/i16208.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
class Ann(x: Any) extends annotation.Annotation
3+
object Message:
4+
implicit def toNoExplanation(str: String): Message @Ann(str) = ???
5+
class Message
6+
7+
object report:
8+
def error(x: Message): Unit = ???
9+
10+
def test =
11+
report.error("a") // works
12+
report.error("a".stripMargin) // error

tests/pos/i18558.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
trait Food[+A]
3+
trait Animal
4+
object Animal {
5+
extension (animal: Animal) def consume[A](weights: Food[A]): A = ???
6+
}
7+
8+
val animal: Animal = ???
9+
val choices: List[Food[Int]] = ???
10+
val result0: List[Any] = choices.map(animal.consume) // compiles
11+
// val result1: List[Int] = choices.map(animal.consume) // does not compile
12+
val result2: List[Int] = choices.map(food => animal.consume(food))
13+
val result3: List[Int] = choices.map(animal.consume(_))
14+
15+
val result4: List[Int] = choices.map(food => Animal.consume(animal)(food))
16+
val result5: List[Int] = choices.map(Animal.consume(animal))

tests/pos/i19749.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import scala.deriving.Mirror
2+
3+
case class A(x: Int, y: String)
4+
5+
trait SomeTrait[T]
6+
7+
object SomeTrait:
8+
given [T]: SomeTrait[T] with {}
9+
10+
def f1[T](using p: Mirror.ProductOf[T]): Tuple.Elem[p.MirroredElemTypes, 0] = ???
11+
12+
def f2[T, R](f: T => R)(using SomeTrait[R]) = ???
13+
14+
// Scala3.3 is fine, 3.4 has compilation errors, p MirroredElemTypes type is missing and has been changed to Nothing
15+
val x = f2(_ => f1[A])

0 commit comments

Comments
 (0)