diff options
author | Martin Odersky <odersky@gmail.com> | 2009-10-23 11:06:50 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-10-23 11:06:50 +0000 |
commit | 42a111ba41ce2f551d56ccde8ca878f1da27a0b4 (patch) | |
tree | 02a09563dac38f4fab691c67b697b2de8c48ddcc /src | |
parent | 92cfcd43997dc090edc35029ada027ed986a25e2 (diff) | |
download | scala-42a111ba41ce2f551d56ccde8ca878f1da27a0b4.tar.gz scala-42a111ba41ce2f551d56ccde8ca878f1da27a0b4.tar.bz2 scala-42a111ba41ce2f551d56ccde8ca878f1da27a0b4.zip |
fixed #2428 for good.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreePrinters.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 14 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 12 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/BitSetLike.scala | 2 |
6 files changed, 23 insertions, 12 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 { |