Skip to content

Commit

Permalink
Fix code after TypeKind has been replaced by BType
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritsuku committed Jan 27, 2017
1 parent 6c0556a commit 2cd885e
Showing 1 changed file with 15 additions and 15 deletions.
Expand Up @@ -217,34 +217,34 @@ trait ScalaJavaMapper extends InternalCompilerServices with ScalaAnnotationHelpe
javaDescriptor(tpe).replace('/', '.')
}

import icodes._
import genBCode.bTypes._

/** Return the descriptor of the given type. A typed descriptor is defined
* by the JVM Specification Section 4.3 (http://docs.oracle.com/javase/specs/vms/se7/html/jvms-4.html#jvms-4.3)
*
* Example:
* javaDescriptor(Array[List[Int]]) == "[Lscala/collection/immutable/List;"
*/
private def javaDescriptor(tk: TypeKind): String = {
private def javaDescriptor(bt: BType): String = {
import Signature._
(tk: @unchecked) match {
case BOOL => C_BOOLEAN.toString
case BYTE => C_BYTE.toString
case SHORT => C_SHORT.toString
case CHAR => C_CHAR.toString
case INT => C_INT.toString
case UNIT => C_VOID.toString
case LONG => C_LONG.toString
case FLOAT => C_FLOAT.toString
case DOUBLE => C_DOUBLE.toString
case REFERENCE(cls) => s"L${cls.javaBinaryName};"
case ARRAY(elem) => s"[${javaDescriptor(elem)}"
bt match {
case BOOL => C_BOOLEAN.toString
case BYTE => C_BYTE.toString
case SHORT => C_SHORT.toString
case CHAR => C_CHAR.toString
case INT => C_INT.toString
case UNIT => C_VOID.toString
case LONG => C_LONG.toString
case FLOAT => C_FLOAT.toString
case DOUBLE => C_DOUBLE.toString
case ClassBType(cls) => s"L$cls;"
case ArrayBType(elem) => s"[${javaDescriptor(elem)}"
}
}

override def javaDescriptor(tpe: Type): String =
if (tpe.isErroneous) "Ljava/lang/Object;"
else javaDescriptor(toTypeKind(tpe.erasure)) // `toTypeKind` only handles erased types
else javaDescriptor(typeToBType(tpe))

override def enclosingTypeName(s : Symbol): String =
if (s == NoSymbol || s.hasFlag(Flags.PACKAGE)) ""
Expand Down

0 comments on commit 2cd885e

Please sign in to comment.