aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-01 13:31:07 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:12 +0200
commite2fb134fd3a49848ea49a6db42a298276c08b110 (patch)
treeaea6cce496b072b155514e2c89f17b338c5c9eed
parentb2bd0bf7d3df3b4c418e411290c2a2b18321aabf (diff)
downloaddotty-e2fb134fd3a49848ea49a6db42a298276c08b110.tar.gz
dotty-e2fb134fd3a49848ea49a6db42a298276c08b110.tar.bz2
dotty-e2fb134fd3a49848ea49a6db42a298276c08b110.zip
Simplify classfile parser "own name" checking
Simplifies the test that the class represented by a classfile is the class logically referenced by the file. The simplification is needed if we want to populate package scopes with unmangled classnames.
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala17
1 files changed, 5 insertions, 12 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index 13934f237..27afa4d09 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -39,7 +39,7 @@ class ClassfileParser(
protected val staticScope: MutableScope = newScope // the scope of all static definitions
protected var pool: ConstantPool = _ // the classfile's constant pool
- protected var currentClassName: Name = _ // JVM name of the current class
+ protected var currentClassName: SimpleTermName = _ // JVM name of the current class
protected var classTParams = Map[Name,Symbol]()
classRoot.info = (new NoCompleter).withDecls(instanceScope)
@@ -47,8 +47,8 @@ class ClassfileParser(
private def currentIsTopLevel(implicit ctx: Context) = classRoot.owner is Flags.PackageClass
- private def mismatchError(c: Symbol) =
- throw new IOException(s"class file '${in.file}' has location not matching its contents: contains $c")
+ private def mismatchError(className: SimpleTermName) =
+ throw new IOException(s"class file '${in.file}' has location not matching its contents: contains class $className")
def run()(implicit ctx: Context): Option[Embedded] = try {
ctx.debuglog("[class] >> " + classRoot.fullName)
@@ -92,15 +92,8 @@ class ClassfileParser(
val nameIdx = in.nextChar
currentClassName = pool.getClassName(nameIdx)
- if (currentIsTopLevel) {
- val c = pool.getClassSymbol(nameIdx)
- if (c != classRoot.symbol) {
- println(currentClassName.debugString) // TODO: remove
- println(c.name.debugString)
- println(classRoot.symbol.name.debugString)
- mismatchError(c)
- }
- }
+ if (currentIsTopLevel && currentClassName != classRoot.fullName.toSimpleName)
+ mismatchError(currentClassName)
addEnclosingTParams()