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
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:99)
at Bar$.out1(Opaque.scala:9)
at Foo.out2(Opaque.scala:4)
at Foo.out2$(Opaque.scala:1)
at Bar$.out2(Opaque.scala:7)
at Opaque$package$.run(Opaque.scala:13)
at run.main(Opaque.scala:12)
Expectation
This should not compile. Instead a compilation error should be reported just like this happens for non-opaque types, e.g.
[error] error overriding typeOut in traitFoo, which equals Int;
[error] typeOut, which equals String has incompatible type
[error] overridetypeOut=String
[error] ^
Alternatively maybe we should consider making opaque types unoverridable? It seems quite strange to me that currently it's possible to override a concrete opaque type although you cannot define an abstract one. Additionally it looks like redefining an opaque type in a subtype works as a hack to leak the opaque type's internals, e.g. the code below compiles successfully unless you comment out the marked line:
traitFoo {
opaquetypeOut=Intdefout1:Outdefout2:Out= out1
}
objectBarextendsFoo {
overrideopaquetypeOut=Int// compilation breaks if this line gets commented outoverridedefout1=1
}
The text was updated successfully, but these errors were encountered:
Compiler version
3.0.0...3.1.2-RC2
Minimized code
Output
Expectation
This should not compile. Instead a compilation error should be reported just like this happens for non-opaque types, e.g.
Alternatively maybe we should consider making opaque types unoverridable? It seems quite strange to me that currently it's possible to override a concrete opaque type although you cannot define an abstract one. Additionally it looks like redefining an opaque type in a subtype works as a hack to leak the opaque type's internals, e.g. the code below compiles successfully unless you comment out the marked line:
The text was updated successfully, but these errors were encountered: