summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-10-31 09:51:45 +0000
committerMartin Odersky <odersky@gmail.com>2006-10-31 09:51:45 +0000
commite02fed8e7df8aebe1ee96b3dc23b805c1171afd2 (patch)
tree2b9c7830429738f035ee88b8b25d12f2c4985e2f
parentdd9a27c37f40655dc467f71fd6e3539bd88afe22 (diff)
downloadscala-e02fed8e7df8aebe1ee96b3dc23b805c1171afd2.tar.gz
scala-e02fed8e7df8aebe1ee96b3dc23b805c1171afd2.tar.bz2
scala-e02fed8e7df8aebe1ee96b3dc23b805c1171afd2.zip
fixed bugs 599 and 757
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala17
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala16
-rw-r--r--test/files/pos/bug599.scala19
-rw-r--r--test/files/pos/bug757.scala13
-rw-r--r--test/files/pos/bug757a.scala1
5 files changed, 53 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index a3efad6ae9..0f9d334862 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -2053,21 +2053,26 @@ trait Parsers requires SyntaxAnalyzer {
*/
def compilationUnit(): Tree =
atPos(in.currentPos) {
+ val ts = new ListBuffer[Tree]
if (in.token == PACKAGE) {
in.nextToken()
val pkg = qualId()
- if (in.token == SEMI || in.token == NEWLINE) {
+ if (in.token == SEMI || in.token == NEWLINE || in.token == EOF) {
in.nextToken()
- makePackaging(pkg, topStatSeq())
+ ts += makePackaging(pkg, topStatSeq())
} else {
accept(LBRACE)
- val t = makePackaging(pkg, topStatSeq())
+ ts += makePackaging(pkg, topStatSeq())
accept(RBRACE)
- if (in.token == SEMI || in.token == NEWLINE) in.nextToken()
- t
+ ts ++= topStatSeq()
}
} else {
- makePackaging(Ident(nme.EMPTY_PACKAGE_NAME), topStatSeq())
+ ts ++= topStatSeq()
+ }
+ val stats = ts.toList
+ stats match {
+ case List(stat @ PackageDef(_, _)) => stat
+ case _ => makePackaging(Ident(nme.EMPTY_PACKAGE_NAME), stats)
}
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index d0ee84fd58..58d86fed69 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -225,7 +225,7 @@ trait Types requires SymbolTable {
}
*/
case _ =>
- //System.out.println("" + this.widen + ".memberType(" + sym +":" + sym.tpe +")" + sym.ownerChain);//DEBUG
+ //System.out.println("" + this + ".memberType(" + sym +":" + sym.tpe +")" + sym.ownerChain);//DEBUG
sym.tpe.asSeenFrom(this, sym.owner)
}
}
@@ -876,6 +876,8 @@ trait Types requires SymbolTable {
def transform(tp: Type): Type =
tp.asSeenFrom(pre, sym.owner).subst(sym.typeParams, args)
+ def thisInfo = if (sym.isAbstractType) transform(sym.info) else sym.info
+
def transform(cl: Array[Type]): Array[Type] = {
val cl1 = new Array[Type](cl.length)
var i = 0
@@ -886,7 +888,7 @@ trait Types requires SymbolTable {
override def symbol = sym
override def bounds: TypeBounds =
- if (sym.isAbstractType) transform(sym.info.bounds).asInstanceOf[TypeBounds]
+ if (sym.isAbstractType) transform(thisInfo.bounds).asInstanceOf[TypeBounds]
else super.bounds
override def parents: List[Type] = {
@@ -894,7 +896,7 @@ trait Types requires SymbolTable {
if (period != currentPeriod) {
parentsPeriod = currentPeriod
if (!isValidForBaseClasses(period)) {
- parentsCache = sym.info.parents map transform
+ parentsCache = thisInfo.parents map transform
}
}
parentsCache
@@ -918,7 +920,7 @@ trait Types requires SymbolTable {
assert(sym1 != symbol, this)
case _ =>
}
- sym.info.decls
+ thisInfo.decls
}
override def baseType(clazz: Symbol): Type =
@@ -941,7 +943,7 @@ trait Types requires SymbolTable {
closureCache
}
- override def baseClasses: List[Symbol] = sym.info.baseClasses
+ override def baseClasses: List[Symbol] = thisInfo.baseClasses
// override def isNullable: boolean = sym.info.isNullable
@@ -961,9 +963,9 @@ trait Types requires SymbolTable {
else if (sym.isModuleClass)
objectPrefix + str
else if (sym.isAnonymousClass && sym.isInitialized && !settings.debug.value)
- sym.info.parents.mkString("", " with ", "{ ... }")
+ thisInfo.parents.mkString("", " with ", "{ ... }")
else if (sym.isRefinementClass && sym.isInitialized)
- sym.info.toString()
+ thisInfo.toString()
else str
}
diff --git a/test/files/pos/bug599.scala b/test/files/pos/bug599.scala
new file mode 100644
index 0000000000..968e2deaee
--- /dev/null
+++ b/test/files/pos/bug599.scala
@@ -0,0 +1,19 @@
+abstract class FooA {
+ type A <: AxA;
+ abstract class AxA;
+ abstract class InnerA {
+ type B <: A;
+ def doB : B;
+ }
+ }
+ trait FooB extends FooA {
+ type A <: AxB;
+ trait AxB extends AxA { def xxx : Int; }
+ abstract class InnerB extends InnerA {
+ // type B <: A;
+ val a : A = doB;
+ a.xxx;
+ val aaa: InnerB.this.B = doB
+ aaa.xxx;
+ }
+ }
diff --git a/test/files/pos/bug757.scala b/test/files/pos/bug757.scala
new file mode 100644
index 0000000000..cc6527f3f2
--- /dev/null
+++ b/test/files/pos/bug757.scala
@@ -0,0 +1,13 @@
+package foo {
+ object C {
+ def foo {
+ Console.println("foo")
+ }
+ }
+}
+
+package bar {
+ object Main extends Application {
+ foo.C.foo
+ }
+}
diff --git a/test/files/pos/bug757a.scala b/test/files/pos/bug757a.scala
new file mode 100644
index 0000000000..f52652b1ba
--- /dev/null
+++ b/test/files/pos/bug757a.scala
@@ -0,0 +1 @@
+package foo