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
The current encoding allows for some unsafe type ascriptions. While this would basically never happen in a real world scenario, we should still look into improving the encoding.
Here's an example of the problem. I've abridged the debug output for simplicity.
scala>@newtype(debug =true) caseclassFoo(x: String)
Expanded@newtype Foo:
{
typeFoo=Foo.Type;
abstracttraitFoo$Typesextends scala.AnyRef {
typeRepr=String;
typeBase= _root_.scala.Any { typeFoo$newtype };
abstracttraitTagextends _root_.scala.Any;
typeType<:BasewithTag
};
objectFooextends scala.AnyRefwithFoo$Types { .. }
}
defined typealiasFoo
defined traitFoo$Types
defined objectFoo
scala>Foo("a"):Foo.Tag
java.lang.ClassCastException: java.lang.String cannot be cast to Foo$Types$Tag
The main reason for the Tag trait is to anchor the companion so it's in the implicit search path. I've been experimenting with refinements to see if that could help but so far I've been unable to get implicit resolution working without it.
The text was updated successfully, but these errors were encountered:
The current encoding allows for some unsafe type ascriptions. While this would basically never happen in a real world scenario, we should still look into improving the encoding.
Here's an example of the problem. I've abridged the debug output for simplicity.
The main reason for the
Tag
trait is to anchor the companion so it's in the implicit search path. I've been experimenting with refinements to see if that could help but so far I've been unable to get implicit resolution working without it.The text was updated successfully, but these errors were encountered: