Skip to content

TupledFunction discards dependent types #21808

Open
@TheDrawingCoder-Gamer

Description

@TheDrawingCoder-Gamer

Compiler version

3.5.1

Minimized code

https://scastie.scala-lang.org/qu0ee9VpT3SQ6YbiBzf0DA

import scala.annotation.experimental

type X = (x: Seq[Nothing], y: Seq[Nothing]) => x.type

@experimental @main def main(): Unit = {
  val tf = summon[util.TupledFunction[X, ((Seq[Nothing], Seq[Nothing])) => Seq[Nothing]]]
  val res1 = tf.untupled((x, y) => y)
  val res2: Vector[Nothing] = Vector()
  val res3: res2.type = res1(res2, List())
}

Output

Exception in thread "main" java.lang.ClassCastException: class scala.collection.immutable.Nil$ cannot be cast to class scala.collection.immutable.Vector (scala.collection.immutable.Nil$ and scala.collection.immutable.Vector are in unnamed module of loader 'app')
	at main$package$.main(main.scala:10)
	at main.main(main.scala:6)

Expectation

Compiler should deny the summon here and require a summon of summon[TupledFunction[X, (t: (Seq[Nothing], Seq[Nothing])) => t._1.type]. It should not allow discarding of dependent types.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions