summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-10-23 11:06:50 +0000
committerMartin Odersky <odersky@gmail.com>2009-10-23 11:06:50 +0000
commit42a111ba41ce2f551d56ccde8ca878f1da27a0b4 (patch)
tree02a09563dac38f4fab691c67b697b2de8c48ddcc
parent92cfcd43997dc090edc35029ada027ed986a25e2 (diff)
downloadscala-42a111ba41ce2f551d56ccde8ca878f1da27a0b4.tar.gz
scala-42a111ba41ce2f551d56ccde8ca878f1da27a0b4.tar.bz2
scala-42a111ba41ce2f551d56ccde8ca878f1da27a0b4.zip
fixed #2428 for good.
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreePrinters.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala14
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala12
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
-rw-r--r--src/library/scala/collection/BitSetLike.scala2
-rwxr-xr-xtest/files/pos/t2429.scala4
-rw-r--r--test/files/run/bitsets.check20
8 files changed, 37 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
index c3819baae0..0423044aa3 100644
--- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
@@ -272,6 +272,7 @@ abstract class TreePrinters {
case Function(vparams, body) =>
print("("); printValueParams(vparams); print(" => "); print(body); print(")")
+ if (settings.uniqid.value && tree.symbol != null) print("#"+tree.symbol.id)
case Assign(lhs, rhs) =>
print(lhs); print(" = "); print(rhs)
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 3337366269..d1a1542b9b 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -1803,7 +1803,7 @@ trait Trees {
/** resets symbol and tpe fields in a tree, @see ResetAttrsTraverse
*/
- def resetAttrs[A<:Tree](x:A):A = {new ResetAttrsTraverser().traverse(x); x}
+ def resetAttrs[A<:Tree](x:A, strict: Boolean = false): A = {new ResetAttrsTraverser(strict).traverse(x); x}
/** A traverser which resets symbol and tpe fields of all nodes in a given tree
* except for (1) TypeTree nodes, whose <code>.tpe</code> field is kept and
@@ -1812,7 +1812,7 @@ trait Trees {
*
* (bq:) This traverser has mutable state and should be discarded after use
*/
- class ResetAttrsTraverser extends Traverser {
+ class ResetAttrsTraverser(strict: Boolean) extends Traverser {
private val erasedSyms = new HashSet[Symbol](8)
override def traverse(tree: Tree): Unit = tree match {
case EmptyTree | TypeTree() =>
@@ -1820,20 +1820,22 @@ trait Trees {
case Template(parents, self, body) =>
tree.symbol = NoSymbol
tree.tpe = null
- for (stat <- body)
- if (stat.isDef) erasedSyms.addEntry(stat.symbol)
+ if (!strict)
+ for (stat <- body)
+ if (stat.isDef) erasedSyms.addEntry(stat.symbol)
super.traverse(tree)
case _: DefTree | Function(_, _) =>
- erasedSyms.addEntry(tree.symbol)
+ if (!strict) erasedSyms.addEntry(tree.symbol)
tree.symbol = NoSymbol
tree.tpe = null
super.traverse(tree)
case _ =>
- if (tree.hasSymbol && erasedSyms.contains(tree.symbol)) tree.symbol = NoSymbol
+ if (tree.hasSymbol && (strict || erasedSyms.contains(tree.symbol))) tree.symbol = NoSymbol
tree.tpe = null
super.traverse(tree)
}
}
+
/* hook to memoize trees in IDE */
trait TreeKind {
def isType : Boolean
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 933c122d6b..bfb3b5f487 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -3585,10 +3585,14 @@ A type's typeSymbol should never be inspected directly.
case (_, et: ExistentialType) =>
et.withTypeVars(isConsistent(tp1, _))
}
- if (tp1.typeSymbol.isClass && tp1.typeSymbol.hasFlag(FINAL))
- tp1 <:< tp2 || isNumericValueClass(tp1.typeSymbol) && isNumericValueClass(tp2.typeSymbol)
- else tp1.baseClasses forall (bc =>
- tp2.baseTypeIndex(bc) < 0 || isConsistent(tp1.baseType(bc), tp2.baseType(bc)))
+
+ def check(tp1: Type, tp2: Type) =
+ if (tp1.typeSymbol.isClass && tp1.typeSymbol.hasFlag(FINAL))
+ tp1 <:< tp2 || isNumericValueClass(tp1.typeSymbol) && isNumericValueClass(tp2.typeSymbol)
+ else tp1.baseClasses forall (bc =>
+ tp2.baseTypeIndex(bc) < 0 || isConsistent(tp1.baseType(bc), tp2.baseType(bc)))
+
+ check(tp1, tp2)/* && check(tp2, tp1)*/ // need to investgate why this can't be made symmetric -- neg/gadts1 fails, and run/existials also.
}
/** Does a pattern of type `patType' need an outer test when executed against
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 96dad06e0f..b01a765714 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -402,6 +402,8 @@ trait Infer {
}
}
+ def isPlausiblyPopulated(tp1: Type, tp2: Type): Boolean = true
+
def isPlausiblyCompatible(tp: Type, pt: Type): Boolean = tp match {
case PolyType(_, restpe) =>
isPlausiblyCompatible(restpe, pt)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 5726e4be58..738c1252ab 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -801,8 +801,8 @@ trait Typers { self: Analyzer =>
typer1.silent(tpr => tpr.typed(tpr.applyImplicitArgs(tree), mode, pt)) match {
case result: Tree => result
case ex: TypeError =>
- if (settings.debug.value) log("fallback on implicits: "+tree)
- val tree1 = typed(resetAttrs(original), mode, WildcardType)
+ if (settings.debug.value) log("fallback on implicits: "+tree+"/"+resetAttrs(original, true))
+ val tree1 = typed(resetAttrs(original, true), mode, WildcardType)
tree1.tpe = addAnnotations(tree1, tree1.tpe)
if (tree1.isEmpty) tree1 else adapt(tree1, mode, pt, EmptyTree)
}
diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala
index bcd36cfd3d..f102071efa 100644
--- a/src/library/scala/collection/BitSetLike.scala
+++ b/src/library/scala/collection/BitSetLike.scala
@@ -129,6 +129,8 @@ trait BitSetLike[+This <: BitSetLike[This] with Set[Int]] extends SetLike[Int, T
}
sb append end
}
+
+ override def stringPrefix = "BitSet"
}
object BitSetLike {
diff --git a/test/files/pos/t2429.scala b/test/files/pos/t2429.scala
index 266baa3c2c..9b9cb89de7 100755
--- a/test/files/pos/t2429.scala
+++ b/test/files/pos/t2429.scala
@@ -19,3 +19,7 @@ object Msg {
} /*: Seq[T] Adding this type annotation avoids the compile error.*/)
}
}
+object Oops {
+ implicit def someImplicit(s: Seq[_]): String = error("stub")
+ def item: String = Nil map { case e: Any => e }
+}
diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check
index 388535dcf5..478de261af 100644
--- a/test/files/run/bitsets.check
+++ b/test/files/run/bitsets.check
@@ -1,6 +1,6 @@
-ms0 = Set(2)
-ms1 = Set(2)
-ms2 = Set(2)
+ms0 = BitSet(2)
+ms1 = BitSet(2)
+ms2 = BitSet(2)
mb0 = false
mb1 = true
mb2 = false
@@ -10,14 +10,14 @@ xs2 = List(2)
ma0 = List(2)
ma1 = List(2)
ma2 = List(2)
-mi0 = Set(2)
-mi1 = Set(2)
-mi2 = Set(2)
+mi0 = BitSet(2)
+mi1 = BitSet(2)
+mi2 = BitSet(2)
-is0 = Set()
-is1 = Set()
-is2 = Set(2)
-is3 = Set()
+is0 = BitSet()
+is1 = BitSet()
+is2 = BitSet(2)
+is3 = BitSet()
ib0 = false
ib1 = false
ib2 = true