diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-07-19 14:45:15 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-07-19 14:47:55 +0200 |
commit | 2c2fd4f4b63e1d9a6ee1243637ad8bcb0deb11d6 (patch) | |
tree | 169bc0545d5e96f9a87ecdd8fd019b4a258648dc /src/compiler/scala/tools/nsc/backend/jvm | |
parent | 31db427375ed50a0ccf1e9ea12d858c71f3f5777 (diff) | |
download | scala-2c2fd4f4b63e1d9a6ee1243637ad8bcb0deb11d6.tar.gz scala-2c2fd4f4b63e1d9a6ee1243637ad8bcb0deb11d6.tar.bz2 scala-2c2fd4f4b63e1d9a6ee1243637ad8bcb0deb11d6.zip |
SD-20 Inlcude static methods in the InlineInfo in mixed compilation
In mixed compilation, the InlineInfo for a Java-defined class is created
using the class symbol (vs in separate compilation, where the info is
created by looking at the classfile and its methods). The scala compiler
puts static java methods into the companion symbol, and we forgot to
include them in the list of methods in the InlineInfo.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm')
3 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala index 7b2686e7a9..f6b640bea4 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala @@ -1145,8 +1145,7 @@ object BTypes { final case class InlineInfo(isEffectivelyFinal: Boolean, sam: Option[String], methodInfos: Map[String, MethodInlineInfo], - warning: Option[ClassInlineInfoWarning]) { - } + warning: Option[ClassInlineInfoWarning]) val EmptyInlineInfo = InlineInfo(false, None, Map.empty, None) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala index 1a4590e7d1..e0f0f269cb 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala @@ -557,9 +557,16 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes { var warning = Option.empty[ClassSymbolInfoFailureSI9111] + def keepMember(sym: Symbol) = sym.isMethod && !scalaPrimitives.isPrimitive(sym) + val classMethods = classSym.info.decls.iterator.filter(keepMember) + val methods = if (!classSym.isJavaDefined) classMethods else { + val staticMethods = classSym.companionModule.info.decls.iterator.filter(m => !m.isConstructor && keepMember(m)) + staticMethods ++ classMethods + } + // Primitive methods cannot be inlined, so there's no point in building a MethodInlineInfo. Also, some // primitive methods (e.g., `isInstanceOf`) have non-erased types, which confuses [[typeToBType]]. - val methodInlineInfos = classSym.info.decls.iterator.filter(m => m.isMethod && !scalaPrimitives.isPrimitive(m)).flatMap({ + val methodInlineInfos = methods.flatMap({ case methodSym => if (completeSilentlyAndCheckErroneous(methodSym)) { // Happens due to SI-9111. Just don't provide any MethodInlineInfo for that method, we don't need fail the compiler. diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala b/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala index 7b640ac54f..72a371cabc 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala @@ -96,8 +96,8 @@ object BackendReporting { val missingClassWarning = missingClass match { case None => "" case Some(c) => - if (c.definedInJavaSource) s"\nNote that the parent class ${c.internalName} is defined in a Java source (mixed compilation), no bytecode is available." - else s"\nNote that the parent class ${c.internalName} could not be found on the classpath." + if (c.definedInJavaSource) s"\nNote that class ${c.internalName} is defined in a Java source (mixed compilation), no bytecode is available." + else s"\nNote that class ${c.internalName} could not be found on the classpath." } s"The method $name$descriptor could not be found in the class $ownerInternalName or any of its parents." + missingClassWarning |