summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-03-30 13:40:08 +0000
committerMartin Odersky <odersky@gmail.com>2007-03-30 13:40:08 +0000
commit098db0fd0bb6ad0ddf978b5fc719fa6a8c2954f0 (patch)
treefaf5798c666f5f810bb386f38314a7be04fe9b0b /src/compiler/scala
parent4b37b5a01cf94d9fde0c6d736082f34e5e09dced (diff)
downloadscala-098db0fd0bb6ad0ddf978b5fc719fa6a8c2954f0.tar.gz
scala-098db0fd0bb6ad0ddf978b5fc719fa6a8c2954f0.tar.bz2
scala-098db0fd0bb6ad0ddf978b5fc719fa6a8c2954f0.zip
fixed bug1024.
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala5
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala9
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Scopes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala11
6 files changed, 22 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index e76f95d207..2250ac379c 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -23,7 +23,10 @@ trait CompilationUnits requires Global {
/** the content of the compilation unit in tree form */
var body: Tree = EmptyTree
- val depends = new HashSet[AbstractFile]
+ /** Note: depends now contains toplevel classes.
+ * To get their sourcefiles, you need to dereference with .sourcefile
+ */
+ val depends = new HashSet[Symbol]
def position(pos: int) = new Position(source, pos)
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
index d4ff2d1737..aba34b0d51 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
@@ -182,6 +182,15 @@ abstract class TreeInfo {
case _ => false
}
+ /** can this type be a type pattern */
+ def mayBeTypePat(tree: Tree): boolean = tree match {
+ case CompoundTypeTree(Template(tps, List())) => tps exists mayBeTypePat
+ case Annotated(_, tp) => mayBeTypePat(tp)
+ case AppliedTypeTree(constr, args) => mayBeTypePat(constr) || args.exists(.isInstanceOf[Bind])
+ case SelectFromTypeTree(tp, _) => mayBeTypePat(tp)
+ case _ => false
+ }
+
/** Is this pattern node a catch-all (wildcard or variable) pattern? */
def isDefaultCase(cdef: CaseDef) = cdef match {
case CaseDef(Ident(nme.WILDCARD), EmptyTree, _) => true
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index f65cb3b05b..e1b72f557d 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -62,7 +62,7 @@ abstract class TreeBuilder {
override def traverse(tree: Tree): unit = tree match {
case Bind(name, Typed(tree1, tpt)) =>
if ((name != nme.WILDCARD) && (buf.elements forall (name !=)))
- buf += (name, tpt)
+ buf += (name, if (treeInfo.mayBeTypePat(tpt)) TypeTree() else tpt)
traverse(tree1)
case Bind(name, tree1) =>
if ((name != nme.WILDCARD) && (buf.elements forall (name !=)))
diff --git a/src/compiler/scala/tools/nsc/symtab/Scopes.scala b/src/compiler/scala/tools/nsc/symtab/Scopes.scala
index cfaccf44f1..6d66875474 100644
--- a/src/compiler/scala/tools/nsc/symtab/Scopes.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Scopes.scala
@@ -178,7 +178,7 @@ trait Scopes requires SymbolTable {
elems = e.next
} else {
var e1 = elems
- while (e1.next != e) e1 = e1.next;
+ while (e1.next != e) e1 = e1.next
e1.next = e.next
}
if (hashtable ne null) {
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index 76ad75e317..606a252b24 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -179,6 +179,9 @@ abstract class Constructors extends Transform {
paramInits ::: constrPrefixBuf.toList ::: constrStatBuf.toList,
constrBody.expr));
+ for (val sym <- clazz.info.decls.toList)
+ if (!isAccessed(sym)) clazz.info.decls unlink sym
+
copy.Template(impl, impl.parents, defBuf.toList filter (stat => isAccessed(stat.symbol)))
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index d79bb134ad..64e49e4b35 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -336,13 +336,10 @@ trait Infer requires Analyzer {
errorTree(tree, underlying(sym).toString() + " cannot be accessed in " +
(if (sym.isClassConstructor) context.enclClass.owner else pre.widen) +
explanation)
- if (context.unit != null) sym.toplevelClass match {
- case clazz : ClassSymbol =>
- if (clazz.sourceFile != null) {
- context.unit.depends += clazz.sourceFile
- }
- case _ =>
- }
+
+ if (context.unit != null)
+ context.unit.depends += sym.toplevelClass
+
val sym1 = sym filter (alt => context.isAccessible(alt, pre, site.isInstanceOf[Super]))
if (sym1 == NoSymbol) {
if (settings.debug.value) {