summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Duplicators.scala15
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
-rw-r--r--test/files/pos/t4717.scala39
4 files changed, 61 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index e0f34b47c8..5a5e891620 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -1550,7 +1550,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val meth = addBody(tree, source)
val d = new Duplicator
- debuglog("-->d DUPLICATING: " + meth)
+ log("-->d DUPLICATING: " + meth)
d.retyped(
localTyper.context1.asInstanceOf[d.Context],
meth,
diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
index 2574a1d241..52335f85e1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
@@ -144,7 +144,7 @@ abstract class Duplicators extends Analyzer {
sym
private def invalidate(tree: Tree) {
- debuglog("attempting to invalidate " + tree.symbol + ", owner - " + (if (tree.symbol ne null) tree.symbol.owner else "<NULL>"))
+ log("attempting to invalidate " + tree.symbol + ", owner - " + (if (tree.symbol ne null) tree.symbol.owner else "<NULL>"))
if (tree.isDef && tree.symbol != NoSymbol) {
debuglog("invalid " + tree.symbol)
invalidSyms(tree.symbol) = tree
@@ -160,12 +160,12 @@ abstract class Duplicators extends Analyzer {
debuglog("newsym: " + newsym + " info: " + newsym.info)
case vdef @ ValDef(mods, name, _, rhs) if mods.hasFlag(Flags.LAZY) =>
- debuglog("ValDef " + name + " sym.info: " + vdef.symbol.info)
+ log("ValDef " + name + " sym.info: " + vdef.symbol.info + ", owner: " + vdef.symbol.owner + " vs. context owner: " + context.owner)
invalidSyms(vdef.symbol) = vdef
val newsym = vdef.symbol.cloneSymbol(context.owner)
newsym.setInfo(fixType(vdef.symbol.info))
vdef.symbol = newsym
- debuglog("newsym: " + newsym + " info: " + newsym.info)
+ log("newsym: " + newsym + " info: " + newsym.info + ", " + newsym.owner + ", whereas symbol.owner is: " + vdef.symbol.owner)
case DefDef(_, name, tparams, vparamss, _, rhs) =>
// invalidate parameters
@@ -245,7 +245,7 @@ abstract class Duplicators extends Analyzer {
super.typed(tree, mode, pt)
case ClassDef(_, _, _, tmpl @ Template(parents, _, stats)) =>
- // log("invalidating classdef " + tree.tpe)
+ log("invalidating classdef " + tree.tpe)
tmpl.symbol = tree.symbol.newLocalDummy(tree.pos)
invalidate(stats)
tree.tpe = null
@@ -257,6 +257,7 @@ abstract class Duplicators extends Analyzer {
super.typed(ddef, mode, pt)
case vdef @ ValDef(mods, name, tpt, rhs) =>
+ log("vdef: " + vdef)
// log("vdef fixing tpe: " + tree.tpe + " with sym: " + tree.tpe.typeSymbol + " and " + invalidSyms)
//if (mods.hasFlag(Flags.LAZY)) vdef.symbol.resetFlag(Flags.MUTABLE) // Martin to Iulian: lazy vars can now appear because they are no longer boxed; Please check that deleting this statement is OK.
vdef.tpt.tpe = fixType(vdef.tpt.tpe)
@@ -358,11 +359,15 @@ abstract class Duplicators extends Analyzer {
tree
case _ =>
- debuglog("Duplicators default case: " + tree.summaryString)
+ log("Duplicators default case: " + tree.summaryString)
if (tree.hasSymbol && tree.symbol != NoSymbol && (tree.symbol.owner == definitions.AnyClass)) {
tree.symbol = NoSymbol // maybe we can find a more specific member in a subclass of Any (see AnyVal members, like ==)
}
tree.tpe = null
+ tree match {
+ case Select(q, n) => log("Select: " + q + ", " + n + " = " + q.tpe.member(n) + ", members: " + q.tpe.members)
+ case _ => log(tree.getClass)
+ }
super.typed(tree, mode, pt)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 8c2eae1c86..aa0a776327 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3657,6 +3657,10 @@ trait Typers extends Modes with Adaptations with Taggings {
def typed1(tree: Tree, mode: Int, pt: Type): Tree = {
def isPatternMode = inPatternMode(mode)
+ tree match {
+ case This(_) => log("typed1: " + tree + ", " + tree.tpe)
+ case _ =>
+ }
//Console.println("typed1("+tree.getClass()+","+Integer.toHexString(mode)+","+pt+")")
//@M! get the type of the qualifier in a Select tree, otherwise: NoType
@@ -4235,6 +4239,7 @@ trait Typers extends Modes with Adaptations with Taggings {
def typedThis(qual: Name) = tree.symbol orElse qualifyingClass(tree, qual, packageOK = false) match {
case NoSymbol => tree
case clazz =>
+ log("typedThis: " + qual + ", " + clazz.thisType.underlying)
tree setSymbol clazz setType clazz.thisType.underlying
if (isStableContext(tree, mode, pt)) tree setType clazz.thisType else tree
}
@@ -4247,6 +4252,7 @@ trait Typers extends Modes with Adaptations with Taggings {
* @return ...
*/
def typedSelect(qual: Tree, name: Name): Tree = {
+ log("typedSelect: " + qual + ", name: " + name + ", member: " + (qual.tpe.members))
def asDynamicCall = dyna.mkInvoke(context.tree, tree, qual, name) map (typed1(_, mode, pt))
val sym = tree.symbol orElse member(qual, name) orElse {
@@ -4870,9 +4876,12 @@ trait Typers extends Modes with Adaptations with Taggings {
case Select(qual, name) =>
incCounter(typedSelectCount)
- var qual1 = checkDead(typedQualifier(qual, mode))
+ val tpq = typedQualifier(qual, mode)
+ if (qual.tpe ne null) log("Select: " + qual + ", " + name + " = " + qual.tpe.member(name) + ", members: " + qual.tpe.members)
+ var qual1 = checkDead(tpq)
if (name.isTypeName) qual1 = checkStable(qual1)
-
+ log("members: " + qual.tpe.members)
+
val tree1 = // temporarily use `filter` and an alternative for `withFilter`
if (name == nme.withFilter)
silent(_ => typedSelect(qual1, name)) match {
diff --git a/test/files/pos/t4717.scala b/test/files/pos/t4717.scala
new file mode 100644
index 0000000000..8144c0c48b
--- /dev/null
+++ b/test/files/pos/t4717.scala
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+/*
+trait Bug1[@specialized(Boolean) A] extends TraversableOnce[A] {
+
+ def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] {
+ lazy val it = that.toIterator
+ def hasNext = it.hasNext
+ def next = it.next
+ }
+
+}
+*/
+
+
+/*
+trait WorksFine[@specialized(Boolean) A] {
+ class SubBounds[B >: A] extends Bounds[B] {
+ lazy val it = ???
+ it
+ }
+ def x[B >: A]: Unit = new SubBounds[B]
+}
+*/
+
+
+trait Bounds[@specialized(Boolean) A] {
+ // okay without `>: A`
+ def x[B >: A]: Unit = new Bounds[B] {
+ lazy val it = ??? // def or val okay
+ it
+ }
+}
+
+