Skip to content

product mirror for scala.Nil.type tries to access the constructor #15234

Closed
@bishabosha

Description

@bishabosha

Any Mirror for a value alias to a case object will crash when calling the fromProduct method, this is because it tries to access the constructor. (i.e. a singleton mirror is not synthesised, but instead a standard product mirror).

Compiler version

3.0.0 - 3.1.2

Minimized code

import scala.deriving.Mirror

@main def Test =
  println(summon[Mirror.Of[Nil.type]].fromProduct(EmptyTuple))

Output

Exception in thread "main" java.lang.IllegalAccessError: tried to access method scala.collection.immutable.Nil$.<init>()V from class App$package$$anon$1
	at App$package$$anon$1.fromProduct(App.scala:4)
	at App$package$$anon$1.fromProduct(App.scala:4)
	at App$package$.Test(App.scala:4)
	at Test.main(App.scala:3)

Expectation

I expect to see List() printed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions