summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-04-16 21:56:30 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2015-04-16 21:56:30 +0200
commit2fbd539e353fd9d234f9a633d7606529d871d939 (patch)
tree5b04839c2c8942be64c88abad41d94a21b78afdb /src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
parentd2a174d27bce392329a9c5e4c7d2acee263cdb34 (diff)
downloadscala-2fbd539e353fd9d234f9a633d7606529d871d939.tar.gz
scala-2fbd539e353fd9d234f9a633d7606529d871d939.tar.bz2
scala-2fbd539e353fd9d234f9a633d7606529d871d939.zip
Don't crash GenBCode for value classes with a self declaration
If a value class has a self declaration class V(x: Long) extends AnyVal { self => /* ... */ } `vClassSymbol.typeOfThis.typeSymbol` is `class Long` in the backend. The InlineInfo for traits contains a field for the self type of the trait. This is required for re-writing calls to final trait methods to the static implementation method: the self type appears in the impl method signature. By mistake, the backend was recording the self type of all classes, not only of traits. In the case of a value class with a self declaration, this broke the assumption that the self type is always a class type (not a primitive type). The simple fix: only record the self type for traits.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
index 162da4236a..eadc404bee 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
@@ -329,10 +329,12 @@ final class BCodeAsmCommon[G <: Global](val global: G) {
* Build the [[InlineInfo]] for a class symbol.
*/
def buildInlineInfoFromClassSymbol(classSym: Symbol, classSymToInternalName: Symbol => InternalName, methodSymToDescriptor: Symbol => String): InlineInfo = {
- val selfType = {
+ val traitSelfType = if (classSym.isTrait && !classSym.isImplClass) {
// The mixin phase uses typeOfThis for the self parameter in implementation class methods.
val selfSym = classSym.typeOfThis.typeSymbol
if (selfSym != classSym) Some(classSymToInternalName(selfSym)) else None
+ } else {
+ None
}
val isEffectivelyFinal = classSym.isEffectivelyFinal
@@ -394,6 +396,6 @@ final class BCodeAsmCommon[G <: Global](val global: G) {
}
}).toMap
- InlineInfo(selfType, isEffectivelyFinal, methodInlineInfos, warning)
+ InlineInfo(traitSelfType, isEffectivelyFinal, methodInlineInfos, warning)
}
}