Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-8563

pattern matching over covariant GADT unsound

    Details

      Description

      The following code produces a ClassCastException at runtime:

      object Test extends App {
        sealed trait Node[+A]
        case class L[C,D](f: C => D) extends Node[C => D]
       
        def test[A,B](n: Node[A => B]): A => B = n match {
          case l: L[c,d] => l.f
        }
       
        println {
          test(new L[Int,Int](identity) with Node[Nothing]: Node[Int => String])(3): String
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ellbur Owen Healy
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: