Skip to content

Commit

Permalink
Add a workaround: Surface.of[A] throws InternalError on REPL (#308)
Browse files Browse the repository at this point in the history
* Add a workaround: Surface.of[A] throws InternalError on REPL

* Remove unnecessary logger
  • Loading branch information
xerial committed Nov 12, 2018
1 parent 2cf505b commit 1be3796
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,21 @@ class GenericSurface(
override val objectFactory: Option[ObjectFactory] = None
) extends Surface {

private def getClassName: String = {
try {
rawType.getSimpleName
} catch {
case e: InternalError =>
// Scala REPL use class name like $line3.$read$$iw$$iw$A, which causes InternalError at getSimpleName
rawType.getName
}
}

def name: String = {
if (typeArgs.isEmpty) {
rawType.getSimpleName
getClassName
} else {
s"${rawType.getSimpleName}[${typeArgs.map(_.name).mkString(",")}]"
s"${getClassName}[${typeArgs.map(_.name).mkString(",")}]"
}
}

Expand Down

0 comments on commit 1be3796

Please sign in to comment.