Skip to content

Commit f599bb8

Browse files
Don't use reflection to call Iterable.collectionClassName
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.
1 parent 3abeed8 commit f599bb8

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package pprint
22

33
object StringPrefix{
4-
def apply(i: Iterable[_]) = i.asInstanceOf[{ def collectionClassName: String }].collectionClassName
4+
def apply(i: Iterable[_]) =
5+
scala.collection.internal.pprint.CollectionName.get(i)
56
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package scala.collection.internal.pprint
2+
3+
object CollectionName {
4+
def get(iterable: scala.collection.Iterable[_]): String =
5+
iterable.collectionClassName
6+
}

pprint/src-3/StringPrefix.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package pprint
22

3-
import reflect.Selectable.reflectiveSelectable
4-
53
object StringPrefix{
6-
def apply(i: Iterable[_]) = i.asInstanceOf[{ def collectionClassName: String }].collectionClassName
4+
def apply(i: Iterable[_]) =
5+
scala.collection.internal.pprint.CollectionName.get(i)
76
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package scala.collection.internal.pprint
2+
3+
object CollectionName {
4+
def get(iterable: scala.collection.Iterable[_]): String =
5+
iterable.collectionClassName
6+
}

0 commit comments

Comments
 (0)