Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit c7699eb

Browse files
author
Aleksandar Prokopec
committed
Add more logging.
1 parent aa555de commit c7699eb

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
15501550
val meth = addBody(tree, source)
15511551

15521552
val d = new Duplicator
1553-
debuglog("-->d DUPLICATING: " + meth)
1553+
log("-->d DUPLICATING: " + meth)
15541554
d.retyped(
15551555
localTyper.context1.asInstanceOf[d.Context],
15561556
meth,

src/compiler/scala/tools/nsc/typechecker/Duplicators.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ abstract class Duplicators extends Analyzer {
144144
sym
145145

146146
private def invalidate(tree: Tree) {
147-
debuglog("attempting to invalidate " + tree.symbol + ", owner - " + (if (tree.symbol ne null) tree.symbol.owner else "<NULL>"))
147+
log("attempting to invalidate " + tree.symbol + ", owner - " + (if (tree.symbol ne null) tree.symbol.owner else "<NULL>"))
148148
if (tree.isDef && tree.symbol != NoSymbol) {
149149
debuglog("invalid " + tree.symbol)
150150
invalidSyms(tree.symbol) = tree
@@ -160,12 +160,12 @@ abstract class Duplicators extends Analyzer {
160160
debuglog("newsym: " + newsym + " info: " + newsym.info)
161161

162162
case vdef @ ValDef(mods, name, _, rhs) if mods.hasFlag(Flags.LAZY) =>
163-
debuglog("ValDef " + name + " sym.info: " + vdef.symbol.info)
163+
log("ValDef " + name + " sym.info: " + vdef.symbol.info + ", owner: " + vdef.symbol.owner + " vs. context owner: " + context.owner)
164164
invalidSyms(vdef.symbol) = vdef
165165
val newsym = vdef.symbol.cloneSymbol(context.owner)
166166
newsym.setInfo(fixType(vdef.symbol.info))
167167
vdef.symbol = newsym
168-
debuglog("newsym: " + newsym + " info: " + newsym.info)
168+
log("newsym: " + newsym + " info: " + newsym.info + ", " + newsym.owner + ", whereas symbol.owner is: " + vdef.symbol.owner)
169169

170170
case DefDef(_, name, tparams, vparamss, _, rhs) =>
171171
// invalidate parameters
@@ -245,7 +245,7 @@ abstract class Duplicators extends Analyzer {
245245
super.typed(tree, mode, pt)
246246

247247
case ClassDef(_, _, _, tmpl @ Template(parents, _, stats)) =>
248-
// log("invalidating classdef " + tree.tpe)
248+
log("invalidating classdef " + tree.tpe)
249249
tmpl.symbol = tree.symbol.newLocalDummy(tree.pos)
250250
invalidate(stats)
251251
tree.tpe = null
@@ -257,6 +257,7 @@ abstract class Duplicators extends Analyzer {
257257
super.typed(ddef, mode, pt)
258258

259259
case vdef @ ValDef(mods, name, tpt, rhs) =>
260+
log("vdef: " + vdef)
260261
// log("vdef fixing tpe: " + tree.tpe + " with sym: " + tree.tpe.typeSymbol + " and " + invalidSyms)
261262
//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.
262263
vdef.tpt.tpe = fixType(vdef.tpt.tpe)
@@ -358,11 +359,15 @@ abstract class Duplicators extends Analyzer {
358359
tree
359360

360361
case _ =>
361-
debuglog("Duplicators default case: " + tree.summaryString)
362+
log("Duplicators default case: " + tree.summaryString)
362363
if (tree.hasSymbol && tree.symbol != NoSymbol && (tree.symbol.owner == definitions.AnyClass)) {
363364
tree.symbol = NoSymbol // maybe we can find a more specific member in a subclass of Any (see AnyVal members, like ==)
364365
}
365366
tree.tpe = null
367+
tree match {
368+
case Select(q, n) => log("Select: " + q + ", " + n + " = " + q.tpe.member(n) + ", members: " + q.tpe.members)
369+
case _ => log(tree.getClass)
370+
}
366371
super.typed(tree, mode, pt)
367372
}
368373
}

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,6 +3657,10 @@ trait Typers extends Modes with Adaptations with Taggings {
36573657

36583658
def typed1(tree: Tree, mode: Int, pt: Type): Tree = {
36593659
def isPatternMode = inPatternMode(mode)
3660+
tree match {
3661+
case This(_) => log("typed1: " + tree + ", " + tree.tpe)
3662+
case _ =>
3663+
}
36603664

36613665
//Console.println("typed1("+tree.getClass()+","+Integer.toHexString(mode)+","+pt+")")
36623666
//@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 {
42354239
def typedThis(qual: Name) = tree.symbol orElse qualifyingClass(tree, qual, packageOK = false) match {
42364240
case NoSymbol => tree
42374241
case clazz =>
4242+
log("typedThis: " + qual + ", " + clazz.thisType.underlying)
42384243
tree setSymbol clazz setType clazz.thisType.underlying
42394244
if (isStableContext(tree, mode, pt)) tree setType clazz.thisType else tree
42404245
}
@@ -4247,6 +4252,7 @@ trait Typers extends Modes with Adaptations with Taggings {
42474252
* @return ...
42484253
*/
42494254
def typedSelect(qual: Tree, name: Name): Tree = {
4255+
log("typedSelect: " + qual + ", name: " + name + ", member: " + (qual.tpe.members))
42504256
def asDynamicCall = dyna.mkInvoke(context.tree, tree, qual, name) map (typed1(_, mode, pt))
42514257

42524258
val sym = tree.symbol orElse member(qual, name) orElse {
@@ -4870,9 +4876,12 @@ trait Typers extends Modes with Adaptations with Taggings {
48704876

48714877
case Select(qual, name) =>
48724878
incCounter(typedSelectCount)
4873-
var qual1 = checkDead(typedQualifier(qual, mode))
4879+
val tpq = typedQualifier(qual, mode)
4880+
if (qual.tpe ne null) log("Select: " + qual + ", " + name + " = " + qual.tpe.member(name) + ", members: " + qual.tpe.members)
4881+
var qual1 = checkDead(tpq)
48744882
if (name.isTypeName) qual1 = checkStable(qual1)
4875-
4883+
log("members: " + qual.tpe.members)
4884+
48764885
val tree1 = // temporarily use `filter` and an alternative for `withFilter`
48774886
if (name == nme.withFilter)
48784887
silent(_ => typedSelect(qual1, name)) match {

test/files/pos/t4717.scala

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
3+
4+
5+
6+
7+
/*
8+
trait Bug1[@specialized(Boolean) A] extends TraversableOnce[A] {
9+
10+
def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] {
11+
lazy val it = that.toIterator
12+
def hasNext = it.hasNext
13+
def next = it.next
14+
}
15+
16+
}
17+
*/
18+
19+
20+
/*
21+
trait WorksFine[@specialized(Boolean) A] {
22+
class SubBounds[B >: A] extends Bounds[B] {
23+
lazy val it = ???
24+
it
25+
}
26+
def x[B >: A]: Unit = new SubBounds[B]
27+
}
28+
*/
29+
30+
31+
trait Bounds[@specialized(Boolean) A] {
32+
// okay without `>: A`
33+
def x[B >: A]: Unit = new Bounds[B] {
34+
lazy val it = ??? // def or val okay
35+
it
36+
}
37+
}
38+
39+

0 commit comments

Comments
 (0)