aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2015-02-12 20:18:32 +0100
committerDmitry Petrashko <dark@d-d.me>2015-02-12 20:18:32 +0100
commitc12f21306ea01bd0411f07074a5a0637f23187ff (patch)
treeb84ef3006439871a5c9699646bbc66a362f2831a
parentb2ca9fe03adfcdbdf254b2fccd02350f9700c059 (diff)
parent10167c46191c1b02246635b01dcd3d1e0b75497a (diff)
downloaddotty-c12f21306ea01bd0411f07074a5a0637f23187ff.tar.gz
dotty-c12f21306ea01bd0411f07074a5a0637f23187ff.tar.bz2
dotty-c12f21306ea01bd0411f07074a5a0637f23187ff.zip
Merge pull request #358 from dotty-staging/backend-backports
Backend discovered issues
-rw-r--r--src/dotty/tools/dotc/Run.scala3
-rw-r--r--src/dotty/tools/dotc/core/Periods.scala11
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala26
-rw-r--r--src/dotty/tools/dotc/transform/ExtensionMethods.scala2
-rw-r--r--src/dotty/tools/dotc/transform/Flatten.scala2
-rw-r--r--src/dotty/tools/dotc/transform/SymUtils.scala2
-rw-r--r--tests/disabled/t2667.scala (renamed from tests/pos/t2667.scala)1
-rw-r--r--tests/disabled/t2669.scala (renamed from tests/pos/t2669.scala)1
8 files changed, 40 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index abee30aab..a182029e6 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -13,6 +13,9 @@ import scala.reflect.io.VirtualFile
class Run(comp: Compiler)(implicit ctx: Context) {
+ assert(comp.phases.last.last.id <= Periods.MaxPossiblePhaseId)
+ assert(ctx.runId <= Periods.MaxPossibleRunId)
+
var units: List[CompilationUnit] = _
def getSource(fileName: String): SourceFile = {
diff --git a/src/dotty/tools/dotc/core/Periods.scala b/src/dotty/tools/dotc/core/Periods.scala
index 66c26e381..b4e22bd87 100644
--- a/src/dotty/tools/dotc/core/Periods.scala
+++ b/src/dotty/tools/dotc/core/Periods.scala
@@ -119,16 +119,19 @@ object Periods {
object Period {
/** The single-phase period consisting of given run id and phase id */
- def apply(rid: RunId, pid: PhaseId): Period =
+ def apply(rid: RunId, pid: PhaseId): Period = {
new Period(((rid << PhaseWidth) | pid) << PhaseWidth)
+ }
/** The period consisting of given run id, and lo/hi phase ids */
- def apply(rid: RunId, loPid: PhaseId, hiPid: PhaseId): Period =
+ def apply(rid: RunId, loPid: PhaseId, hiPid: PhaseId): Period = {
new Period(((rid << PhaseWidth) | hiPid) << PhaseWidth | (hiPid - loPid))
+ }
/** The interval consisting of all periods of given run id */
- def allInRun(rid: RunId) =
+ def allInRun(rid: RunId) = {
apply(rid, 0, PhaseMask)
+ }
}
final val Nowhere = new Period(0)
@@ -141,6 +144,8 @@ object Periods {
type RunId = Int
final val NoRunId = 0
final val InitialRunId = 1
+ final val RunWidth = java.lang.Integer.SIZE - PhaseWidth * 2 - 1/* sign */
+ final val MaxPossibleRunId = (1 << RunWidth) - 1
/** An ordinal number for phases. First phase has number 1. */
type PhaseId = Int
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 6b3532944..bce4322ff 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -292,6 +292,21 @@ object SymDenotations {
if (isType) fn.toTypeName else fn.toTermName
}
+
+ /** The encoded flat name of this denotation, where joined names are separated by `separator` characters. */
+ def flatName(separator: Char = '$')(implicit ctx: Context): Name =
+ if (symbol == NoSymbol || owner == NoSymbol || owner.isEffectiveRoot || (owner is PackageClass)) name
+ else {
+ var owner = this
+ var sep = ""
+ do {
+ owner = owner.owner
+ sep += separator
+ } while (!owner.isClass && !owner.isPackageObject)
+ val fn = owner.flatName(separator) ++ sep ++ name
+ if (isType) fn.toTypeName else fn.toTermName
+ }
+
/** `fullName` where `.' is the separator character */
def fullName(implicit ctx: Context): Name = fullNameSeparated('.')
@@ -622,15 +637,22 @@ object SymDenotations {
* the completers.
*/
/** The class implementing this module, NoSymbol if not applicable. */
- final def moduleClass(implicit ctx: Context): Symbol =
+ final def moduleClass(implicit ctx: Context): Symbol = {
+ def notFound = {println(s"missing module class for $name: $myInfo"); NoSymbol}
if (this is ModuleVal)
myInfo match {
case info: TypeRef => info.symbol
case ExprType(info: TypeRef) => info.symbol // needed after uncurry, when module terms might be accessor defs
case info: LazyType => info.moduleClass
- case _ => println(s"missing module class for $name: $myInfo"); NoSymbol
+ case t: MethodType =>
+ t.resultType match {
+ case info: TypeRef => info.symbol
+ case _ => notFound
+ }
+ case _ => notFound
}
else NoSymbol
+ }
/** The module implemented by this module class, NoSymbol if not applicable. */
final def sourceModule(implicit ctx: Context): Symbol = myInfo match {
diff --git a/src/dotty/tools/dotc/transform/ExtensionMethods.scala b/src/dotty/tools/dotc/transform/ExtensionMethods.scala
index 2ff43c55b..a006f04a7 100644
--- a/src/dotty/tools/dotc/transform/ExtensionMethods.scala
+++ b/src/dotty/tools/dotc/transform/ExtensionMethods.scala
@@ -35,7 +35,7 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
case ref: ClassDenotation if ref is ModuleClass =>
ref.linkedClass match {
case origClass: ClassSymbol if isDerivedValueClass(origClass) =>
- val cinfo = ref.classInfo
+ val cinfo = ref.classInfo // ./tests/pos/t2667.scala dies here for module class AnyVal$
val decls1 = cinfo.decls.cloneScope
ctx.atPhase(thisTransformer.next) { implicit ctx =>
for (decl <- origClass.classInfo.decls) {
diff --git a/src/dotty/tools/dotc/transform/Flatten.scala b/src/dotty/tools/dotc/transform/Flatten.scala
index ff3f06c68..0bd1bb75f 100644
--- a/src/dotty/tools/dotc/transform/Flatten.scala
+++ b/src/dotty/tools/dotc/transform/Flatten.scala
@@ -19,7 +19,7 @@ class Flatten extends MiniPhaseTransform with SymTransformer { thisTransform =>
def transformSym(ref: SymDenotation)(implicit ctx: Context) = {
if (ref.isClass && !ref.is(Package) && !ref.owner.is(Package)) {
ref.copySymDenotation(
- name = ref.flatName,
+ name = ref.flatName(),
owner = ref.enclosingPackageClass)
}
else ref
diff --git a/src/dotty/tools/dotc/transform/SymUtils.scala b/src/dotty/tools/dotc/transform/SymUtils.scala
index 0a5854ea7..c38b7cebd 100644
--- a/src/dotty/tools/dotc/transform/SymUtils.scala
+++ b/src/dotty/tools/dotc/transform/SymUtils.scala
@@ -93,7 +93,7 @@ class SymUtils(val self: Symbol) extends AnyVal {
self.owner.info.decl(self.asTerm.name.fieldName).suchThat(!_.is(Method)).symbol
/** `fullName` where `$' is the separator character */
- def flatName(implicit ctx: Context): Name = self.fullNameSeparated('$')
+ def flatName(implicit ctx: Context): Name = self.flatName('$')
def initializer(implicit ctx: Context): TermSymbol =
self.owner.info.decl(InitializerName(self.asTerm.name)).symbol.asTerm
diff --git a/tests/pos/t2667.scala b/tests/disabled/t2667.scala
index 7f1f36f00..600c1eaf0 100644
--- a/tests/pos/t2667.scala
+++ b/tests/disabled/t2667.scala
@@ -1,3 +1,4 @@
+// ExtensionMethods info transformer fails here for AnyVal$
object A {
def foo(x: Int, y: Int*): Int = 45
def foo[T](x: T*): Int = 55
diff --git a/tests/pos/t2669.scala b/tests/disabled/t2669.scala
index 72e931178..609e88786 100644
--- a/tests/pos/t2669.scala
+++ b/tests/disabled/t2669.scala
@@ -1,4 +1,5 @@
// #2629, #2639, #2669
+// dies in classfile parser while parsing java.util.Vector(requested by bakend)
object Test2669 {
def test[T](l: java.util.ArrayList[_ <: T]) = 1