summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-05-22 10:59:44 +0000
committerMartin Odersky <odersky@gmail.com>2006-05-22 10:59:44 +0000
commitffffaf4910710fec7d77d45ee232e8a6fb0d6a9f (patch)
tree406923023b9dda4d4e44f8d91d9514262bc85e3b
parent06ab9264e8136bcf0da1bce6842e02371569049a (diff)
downloadscala-ffffaf4910710fec7d77d45ee232e8a6fb0d6a9f.tar.gz
scala-ffffaf4910710fec7d77d45ee232e8a6fb0d6a9f.tar.bz2
scala-ffffaf4910710fec7d77d45ee232e8a6fb0d6a9f.zip
Fixed bug 604,605, 606, 607, 608, 611
-rw-r--r--lib/.nfs0109874b0000002cbin0 -> 100868 bytes
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala24
-rw-r--r--test/files/pos/bug604.scala8
-rw-r--r--test/files/pos/bug608.scala17
5 files changed, 44 insertions, 7 deletions
diff --git a/lib/.nfs0109874b0000002c b/lib/.nfs0109874b0000002c
new file mode 100644
index 0000000000..9a98399342
--- /dev/null
+++ b/lib/.nfs0109874b0000002c
Binary files differ
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 50b8a241c6..7936b250b0 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -434,7 +434,7 @@ trait Scanners requires SyntaxAnalyzer {
def inLastOfStat(token: int) = token match {
case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | SYMBOLLIT |
- IDENTIFIER | THIS | NULL | TRUE | FALSE | RETURN | USCORE | TYPE |
+ IDENTIFIER | THIS | NULL | TRUE | FALSE | RETURN | USCORE | TYPE | XMLSTART |
RPAREN | RBRACKET | RBRACE =>
true
case _ =>
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index cbd5504388..6423066612 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1539,8 +1539,10 @@ trait Types requires SymbolTable {
def isSubScope(s1: Scope, s2: Scope): boolean = s2.toList.forall {
sym2 =>
val sym1 = s1.lookup(sym2.name);
+ sym1 != NoSymbol &&
sym1.info =:= sym2.info.substThis(sym2.owner, sym1.owner.thisType)
}
+ System.out.println("is same? " + tp1 + " " + tp2 + " " + tp1.symbol.owner + " " + tp2.symbol.owner)
isSameTypes(parents1, parents2) && isSubScope(ref1, ref2) && isSubScope(ref2, ref1)
case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) =>
(pts1.length == pts2.length &&
@@ -1931,11 +1933,14 @@ trait Types requires SymbolTable {
// add a refinement symbol for all non-class members of lubBase
// which are refined by every type in ts.
if (!sym.isClass && !sym.isConstructor && (narrowts forall (t => refines(t, sym))))
- addMember(lubThisType, lubType, lubsym(sym));
+ try {
+ addMember(lubThisType, lubType, lubsym(sym))
+ } catch {
+ case ex: NoCommonType =>
+ }
if (lubType.decls.isEmpty) lubBase else lubType;
}
}
-
if (settings.debug.value) {
log(indent + "lub of " + ts);//debug
indent = indent + " ";
@@ -2004,7 +2009,11 @@ trait Types requires SymbolTable {
}
for (val t <- ts; val sym <- t.nonPrivateMembers)
if (!sym.isClass && !sym.isConstructor && !(glbThisType specializes sym))
- addMember(glbThisType, glbType, glbsym(sym));
+ try {
+ addMember(glbThisType, glbType, glbsym(sym))
+ } catch {
+ case ex: NoCommonType =>
+ }
if (glbType.decls.isEmpty) glbBase else glbType
}
} catch {
@@ -2099,7 +2108,7 @@ trait Types requires SymbolTable {
case PolyType(tparams1, _) if (tparams1.length == tparams.length) =>
tparams1 map (tparam => tparam.info.substSym(tparams1, tparams))
case _ =>
- throw new Error("lub/glb of incompatible types: " + tps.mkString("", " and ", ""))
+ throw new NoCommonType(tps)
}
/** All types in list must be polytypes with type parameter lists of
@@ -2112,7 +2121,7 @@ trait Types requires SymbolTable {
case PolyType(tparams1, restpe) if (tparams1.length == tparams.length) =>
restpe.substSym(tparams1, tparams)
case _ =>
- throw new Error("lub/glb of incompatible types: " + tps.mkString("", " and ", ""))
+ throw new NoCommonType(tps)
}
/** All types in list must be method types with equal parameter types.
@@ -2123,7 +2132,7 @@ trait Types requires SymbolTable {
case MethodType(pts1, res) if (isSameTypes(pts1, pts)) =>
res
case _ =>
- throw new Error("lub/glb of incompatible types: " + tps.mkString("", " and ", ""))
+ throw new NoCommonType(tps)
}
// Errors and Diagnostics ---------------------------------------------------------
@@ -2131,6 +2140,9 @@ trait Types requires SymbolTable {
/** An exception signalling a type error */
class TypeError(val msg: String) extends java.lang.Error(msg);
+ class NoCommonType(tps: List[Type]) extends java.lang.Error(
+ "lub/glb of incompatible types: " + tps.mkString("", " and ", ""));
+
/** An exception signalling a malformed type */
class MalformedType(msg: String) extends TypeError(msg) {
def this(pre: Type, tp: String) = this("malformed type: " + pre + "#" + tp)
diff --git a/test/files/pos/bug604.scala b/test/files/pos/bug604.scala
new file mode 100644
index 0000000000..fb90d5ae31
--- /dev/null
+++ b/test/files/pos/bug604.scala
@@ -0,0 +1,8 @@
+object Test
+{
+ type T = Foo.type
+ object Foo
+
+ def main(argv : Array[String]) : Unit = {
+ }
+}
diff --git a/test/files/pos/bug608.scala b/test/files/pos/bug608.scala
new file mode 100644
index 0000000000..24f515651a
--- /dev/null
+++ b/test/files/pos/bug608.scala
@@ -0,0 +1,17 @@
+trait CrashDueToTypeError {
+ def id[a](x :a) :a = x
+
+ trait Bifunctor {
+ type a; // content
+ type s <: Bifunctor
+
+ // uncomment this-vvvvvvvvvvvvvvvvvvvvvvvvvvvv, and it compiles
+ def bimap[c](f :a=>c) :s{/*type s=Bifunctor.this.s;*/type a=c; }
+ }
+
+ def hylo[hs <: Bifunctor,ha,hb,hc]
+ (f :hb=>hs{type s=hs; type a=ha},
+ g :hs{type s=hs; type a=ha}=>hc)(x :hb)
+ :hc
+ = g(f(x).bimap(id))
+}