Skip to content

Backend discovered issues #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
11 changes: 8 additions & 3 deletions src/dotty/tools/dotc/core/Periods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
26 changes: 24 additions & 2 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/ExtensionMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/Flatten.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/SymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/pos/t2667.scala → tests/disabled/t2667.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/pos/t2669.scala → tests/disabled/t2669.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down