Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnyVal value in a Selectable container class is stripped of its wrapper #14340

Closed
soronpo opened this issue Jan 24, 2022 · 1 comment
Closed
Labels
area:transform itype:bug Spree Suitable for a future Spree stat:unassigned This issue or PR is not assigned to anyone, but should be

Comments

@soronpo
Copy link
Contributor

soronpo commented Jan 24, 2022

Compiler version

v3.1.1-RC2

Minimized code

https://scastie.scala-lang.org/l6Js266rRd2FuA4p0SkJLA

class Foo(val value : Int) extends AnyVal
class Container extends reflect.Selectable
val cont = new Container:
  val foo = new Foo(1)

println(cont.foo.value) //ClassCastException

Output

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class Playground$Foo (java.lang.Integer is in module java.base of loader 'bootstrap'; Playground$Foo is in unnamed module of loader sbt.internal.BottomClassLoader @433c2ab9)
	at Playground$.<clinit>(main.scala:8)
	at Main$.<clinit>(main.scala:12)
	at Main.main(main.scala)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at sbt.Run.invokeMain(Run.scala:133)
	at sbt.Run.execute$1(Run.scala:82)
	at sbt.Run.$anonfun$runWithLoader$5(Run.scala:110)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
	at sbt.TrapExit$App.run(TrapExit.scala:258)
	at java.base/java.lang.Thread.run(Thread.java:831)

Expectation

No error.

@soronpo soronpo changed the title Selectable container with AnyVal value is stripped of its wrapper AnyVal value in a Selectable container class is stripped of its wrapper Jan 24, 2022
@bishabosha
Copy link
Member

related #4528

@anatoliykmetyuk anatoliykmetyuk added stat:needs triage Every issue needs to have an "area" and "itype" label Spree Suitable for a future Spree labels Jan 25, 2022
@odersky odersky removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jan 31, 2022
@dwijnand dwijnand added the stat:unassigned This issue or PR is not assigned to anyone, but should be label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:transform itype:bug Spree Suitable for a future Spree stat:unassigned This issue or PR is not assigned to anyone, but should be
Projects
None yet
Development

No branches or pull requests

5 participants