Skip to content

explicit "PolyFunction" type annotation cause ClassCastException #8299

Closed
@xuwei-k

Description

@xuwei-k

minimized code

dotty version: 0.23.0-bin-20200211-5b006fb-NIGHTLY

package example

object Main {
  def main(a: Array[String]): Unit = {
    val p: PolyFunction = [A] => (xs: List[A]) => xs.headOption
  }
}

sbt run log

[error] (run-main-5) java.lang.ClassCastException: example.Main$$anon$1 cannot be cast to scala.PolyFunction
[error] java.lang.ClassCastException: example.Main$$anon$1 cannot be cast to scala.PolyFunction
[error] 	at example.Main$.main(A.scala:5)
[error] 	at example.Main.main(A.scala)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.lang.reflect.Method.invoke(Method.java:498)

expectation

compile error or no Exception.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions