-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use reflection to call Iterable.collectionClassName (#80)
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
1 parent
fb918d0
commit b7d8ea6
Showing
4 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
7 changes: 7 additions & 0 deletions
7
pprint/src-2.13/scala/collection/internal/pprint/CollectionName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
7 changes: 7 additions & 0 deletions
7
pprint/src-3/scala/collection/internal/pprint/CollectionName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |