You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
oops1 & oops2 below should not compile; they throw as commented at runtime.
This seems specific to the extra structural type & projection; see how up[Stringer] fails to compile, but a trivial wrapper around Stringer causes it to pass.
// coinv.scalaobjectcoinv {
defup[F[+_]](fa: F[String]):F[Object] = fa
defdown[F[-_]](fa: F[Object]):F[String] = fa
up(List("hi"))
// [error] type A is covariant, but type _ is declared contravariant// down(List('whatever: Object))// should not compile; `l' is unsounddefoops1= down[({typel[-a] =List[a]})#l](List('whatever:Object)).head +"oops"// scala> oops1// java.lang.ClassCastException: scala.Symbol cannot be cast to java.lang.String// at com.nocandysw.coinv$.oops1(coinv.scala:12)typeStringer[-A] =A=>String
down[Stringer](_.toString)
// [error] type A is contravariant, but type _ is declared covariant// up[Stringer]("printed: " + _)// should not compile; `l' is unsounddefoops2= up[({typel[+a] =Stringer[a]})#l]("printed: "+ _)
// scala> oops2(Some(33))// java.lang.ClassCastException: scala.Some cannot be cast to java.lang.String// at com.nocandysw.coinv$$anonfun$oops2$1.apply(coinv.scala:20)
}
The text was updated successfully, but these errors were encountered:
Seems vaguely related to #1364.
oops1 & oops2 below should not compile; they throw as commented at runtime.
This seems specific to the extra structural type & projection; see how up[Stringer] fails to compile, but a trivial wrapper around Stringer causes it to pass.
The text was updated successfully, but these errors were encountered: