Skip to content

Commit

Permalink
Don't use reflection to call Iterable.collectionClassName (#80)
Browse files Browse the repository at this point in the history
This is an issue on GraalVM, where all collection concrete classes would
need to be added to some Graal reflection config for collectionClassName
to be call-able by reflection.
  • Loading branch information
alexarchambault authored Nov 27, 2022
1 parent fb918d0 commit b7d8ea6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pprint/src-2.13/pprint/StringPrefix.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pprint

object StringPrefix{
def apply(i: Iterable[_]) = i.asInstanceOf[{ def collectionClassName: String }].collectionClassName
object StringPrefix {
def apply(i: Iterable[_]) =
scala.collection.internal.pprint.CollectionName.get(i)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package scala.collection.internal.pprint

// needs to be in a scala.* package to call Iterable.collectionClassName (which is private[scala])
object CollectionName {
def get(iterable: scala.collection.Iterable[_]): String =
iterable.collectionClassName
}
5 changes: 2 additions & 3 deletions pprint/src-3/StringPrefix.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pprint

import reflect.Selectable.reflectiveSelectable

object StringPrefix{
def apply(i: Iterable[_]) = i.asInstanceOf[{ def collectionClassName: String }].collectionClassName
def apply(i: Iterable[_]) =
scala.collection.internal.pprint.CollectionName.get(i)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package scala.collection.internal.pprint

// needs to be in a scala.* package to call Iterable.collectionClassName (which is private[scala])
object CollectionName {
def get(iterable: scala.collection.Iterable[_]): String =
iterable.collectionClassName
}

0 comments on commit b7d8ea6

Please sign in to comment.