summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-07-10 16:54:35 +0000
committerMartin Odersky <odersky@gmail.com>2008-07-10 16:54:35 +0000
commit9dc05dc520c149d97877526d651d40d9c31214e3 (patch)
treed76aa3e9b76df3006e6460314b2707392e1c27e4
parent79727b4ea3c4e672d2f9ce64a167de47e8006d15 (diff)
downloadscala-9dc05dc520c149d97877526d651d40d9c31214e3.tar.gz
scala-9dc05dc520c149d97877526d651d40d9c31214e3.tar.bz2
scala-9dc05dc520c149d97877526d651d40d9c31214e3.zip
fixed #764 and #770
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala3
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala14
-rw-r--r--test/files/neg/t0764.check6
-rw-r--r--test/files/neg/t0764.scala14
-rw-r--r--test/files/pos/t0770.scala13
-rwxr-xr-xtest/files/pos/t1059.scala28
6 files changed, 68 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 5758676b8f..e4dbb2eb32 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1082,7 +1082,8 @@ trait Types {
while (j < clSize) {
closureCache(j) match {
case RefinedType(parents, decls) =>
- if (!decls.isEmpty) assert(false, "computing closure of "+this+":"+this.isInstanceOf[RefinedType])
+ // can't assert decls.isEmpty; see t0764
+ //if (!decls.isEmpty) assert(false, "computing closure of "+this+":"+this.isInstanceOf[RefinedType]+"/"+closureCache(j))
//Console.println("compute closure of "+this+" => glb("+parents+")")
closureCache(j) = mergePrefixAndArgs(parents, -1, maxClosureDepth(parents) + LubGlbMargin) match {
case Some(tp0) => tp0
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index fd557911cf..59dd57e8fd 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -355,11 +355,6 @@ abstract class Mixin extends InfoTransform {
/** The typer */
private var localTyper: erasure.Typer = _
- /** Within a static implementation method: the interface type corresponding
- * to the implementation module; undefined evrywhere else.
- */
- private var enclInterface: Symbol = _
-
/** The first transform; called in a pre-order traversal at phase mixin
* (that is, every node is processed before its children).
* What transform does:
@@ -389,7 +384,6 @@ abstract class Mixin extends InfoTransform {
self = sym.newValue(sym.pos, nme.SELF)
.setFlag(PARAM)
.setInfo(toInterface(currentOwner.typeOfThis));
- enclInterface = currentOwner.toInterface
val selfdef = ValDef(self) setType NoType
copy.DefDef(tree, mods, name, tparams, List(selfdef :: vparams), tpt, rhs)
} else {
@@ -781,13 +775,15 @@ abstract class Mixin extends InfoTransform {
case Select(Super(_, _), name) =>
tree
- case Select(qual, name) if sym.owner.isImplClass && !isStaticOnly(sym) && enclInterface != null =>
+ case Select(qual, name) if sym.owner.isImplClass && !isStaticOnly(sym) =>
// refer to fields in some implementation class via an abstract
// getter in the interface.
+
if (sym.isMethod)
assert(false, "no method allowed here: " + sym + sym.isImplOnly +
" " + flagsToString(sym.flags))
- val getter = sym.getter(enclInterface)
+ val iface = toInterface(sym.owner.tpe).typeSymbol
+ val getter = sym.getter(iface)
assert(getter != NoSymbol)
localTyper.typed {
atPos(tree.pos) {
@@ -800,7 +796,7 @@ abstract class Mixin extends InfoTransform {
// setter in the interface.
localTyper.typed {
atPos(tree.pos) {
- Apply(Select(qual, lhs.symbol.setter(enclInterface)) setPos lhs.pos, List(rhs))
+ Apply(Select(qual, lhs.symbol.setter(toInterface(lhs.symbol.owner.tpe).typeSymbol)) setPos lhs.pos, List(rhs))
}
}
case _ =>
diff --git a/test/files/neg/t0764.check b/test/files/neg/t0764.check
new file mode 100644
index 0000000000..b622f17c5e
--- /dev/null
+++ b/test/files/neg/t0764.check
@@ -0,0 +1,6 @@
+t0764.scala:13: error: type mismatch;
+ found : java.lang.Object with Node{type T = _1.type} where val _1: Main.this.AType
+ required: Node{type T = Main.this.AType}
+ new Main[AType]( (value: AType).prepend )
+ ^
+one error found
diff --git a/test/files/neg/t0764.scala b/test/files/neg/t0764.scala
new file mode 100644
index 0000000000..daeeb21d91
--- /dev/null
+++ b/test/files/neg/t0764.scala
@@ -0,0 +1,14 @@
+class Top[A] {
+ type AType = A
+}
+
+trait Node extends NotNull { outer =>
+ type T <: Node
+ def prepend = new Node { type T = outer.type }
+}
+
+class Main[NextType <: Node](value: Node { type T = NextType })
+ extends Top[Node { type T = NextType }] {
+
+ new Main[AType]( (value: AType).prepend )
+}
diff --git a/test/files/pos/t0770.scala b/test/files/pos/t0770.scala
new file mode 100644
index 0000000000..7a0a2bf9bb
--- /dev/null
+++ b/test/files/pos/t0770.scala
@@ -0,0 +1,13 @@
+trait A
+{
+ private[this] val p = 5
+
+ def f = (b: Byte) => p
+}
+
+trait B
+{
+ def failure: Boolean
+ def success = !failure
+}
+
diff --git a/test/files/pos/t1059.scala b/test/files/pos/t1059.scala
new file mode 100755
index 0000000000..659bf375ca
--- /dev/null
+++ b/test/files/pos/t1059.scala
@@ -0,0 +1,28 @@
+package com;
+
+import scala.xml._
+
+object Main {
+
+ def main(args : Array[String]) : Unit = {
+
+ var m : PartialFunction[Any, Any] = {
+
+ case SafeNodeSeq(s @ _*) => println(s) }
+
+ println(m(<a/> ++ <b/>))
+ println(m.isDefinedAt(<a/> ++ <b/>))
+
+ }
+
+}
+
+object SafeNodeSeq {
+
+ def unapplySeq(any: Any) : Option[Seq[Node]] = any match { case s: Seq[_] => Some(s flatMap ( _ match {
+
+ case n: Node => n case _ => NodeSeq.Empty
+
+ })) case _ => None }
+
+}