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

Crash at pickling when summon ClassTag for union of nested arrays #13131

Closed
bishabosha opened this issue Jul 22, 2021 · 3 comments · Fixed by #13156
Closed

Crash at pickling when summon ClassTag for union of nested arrays #13131

bishabosha opened this issue Jul 22, 2021 · 3 comments · Fixed by #13156
Assignees
Labels
itype:bug itype:crash Spree Suitable for a future Spree
Milestone

Comments

@bishabosha
Copy link
Member

Compiler version

3.0.1

Minimized code

val foo = reflect.classTag[Array[Array[Int]] | Array[Array[Int]]]

Output (click arrow to expand)

Crash is caused by a missing case of JavaArrayType in the TreePickler

scala.MatchError: JavaArrayType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)) (of class dotty.tools.dotc.core.Types$CachedJavaArrayType) while compiling sem/foo.scala
Exception in thread "main" scala.MatchError: JavaArrayType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)) (of class dotty.tools.dotc.core.Types$CachedJavaArrayType)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:302)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:171)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$11$$anonfun$1(TreePickler.scala:192)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$2(TreePickler.scala:192)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:192)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:171)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleConstant(TreePickler.scala:153)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:454)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$38$$anonfun$1(TreePickler.scala:439)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:439)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:440)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$38$$anonfun$1(TreePickler.scala:439)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:439)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:440)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:330)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:345)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:347)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:556)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:371)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:371)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:597)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:598)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:342)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:347)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:573)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:371)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:371)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$29(TreePickler.scala:613)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:69)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:613)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:784)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:784)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$3$$anonfun$2(Pickler.scala:69)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:106)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:106)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:111)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:216)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:231)
	at dotty.tools.dotc.Run.compileSources(Run.scala:166)
	at dotty.tools.dotc.Run.compile(Run.scala:150)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
	at dotty.tools.dotc.Driver.process(Driver.scala:199)
	at dotty.tools.dotc.Driver.process(Driver.scala:167)
	at dotty.tools.dotc.Driver.process(Driver.scala:179)
	at dotty.tools.dotc.Driver.main(Driver.scala:209)
	at dotty.tools.dotc.Main.main(Main.scala)
@bishabosha bishabosha added the Spree Suitable for a future Spree label Jul 22, 2021
@smarter
Copy link
Member

smarter commented Jul 22, 2021

Crash is caused by a missing case of JavaArrayType in the TreePickler

I don't think JavaArrayType should reach TreePickler, i think the issue is that https://github.com/lampepfl/dotty/blob/ec15557c1bcce768c1cc8c59b7bc4cb6e8d5e9dc/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala#L42-L44 should recursively replace JavaArrayType by ArrayOf in elemType

@griggt
Copy link
Contributor

griggt commented Jul 22, 2021

See also #11043 (same stack trace)

@bishabosha
Copy link
Member Author

palindrome issue

bishabosha added a commit to dotty-staging/dotty that referenced this issue Jul 26, 2021
@bishabosha bishabosha self-assigned this Jul 26, 2021
smarter added a commit that referenced this issue Jul 26, 2021
fix #13131: escape java array in ClassTag
tanishiking pushed a commit to tanishiking/scala3 that referenced this issue Aug 10, 2021
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug itype:crash Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants