summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-08-28 17:05:08 +0000
committerMartin Odersky <odersky@gmail.com>2008-08-28 17:05:08 +0000
commitb85a3d25fcba0e6c6f056b926d02e87fc3b5b041 (patch)
tree3712943f46dbe46bb7a13ef97aa8c2fe56d20ffc /src
parent44bd48af53d309272941b79962490ec295f7a7ea (diff)
downloadscala-b85a3d25fcba0e6c6f056b926d02e87fc3b5b041.tar.gz
scala-b85a3d25fcba0e6c6f056b926d02e87fc3b5b041.tar.bz2
scala-b85a3d25fcba0e6c6f056b926d02e87fc3b5b041.zip
Fixed #1280, #1289
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala28
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala5
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala5
4 files changed, 29 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 6d0e72a3f9..5a2c5bac5c 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -421,14 +421,14 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
explicitOuter, // replace C.this by explicit outer pointers, eliminate pattern matching
// checkDefined,
erasure, // erase generic types to Java 1.4 types, add interfaces for traits
- lazyVals,
+ lazyVals, // transforms local lazy vals into vars and initialized bits
lambdaLift, // move nested functions to top level
// detach,
constructors // move field definitions into constructors
) ::: (
if (forMSIL) List() else List(flatten) // get rid of inner classes
) ::: List(
- mixer, // do mixin composition
+ mixer, // do mixin composition, translate lazy fields
cleanup, // some platform-specific cleanups
genicode, // generate portable intermediate code
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 6dfc4b9002..1b93f17cd0 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1437,7 +1437,7 @@ A type's typeSymbol should never be inspected directly.
val xform = transform(sym.info.resultType)
assert(xform ne this, this)
xform.normalize // cycles have been checked in typeRef
- } else PolyType(typeParams, transform(sym.info.resultType).normalize) // eta-expand
+ } else PolyType(typeParams, transform(sym.info.resultType).normalize) // eta-expand
// @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function*
} else if (isHigherKinded) {
// @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function*
@@ -3576,9 +3576,15 @@ A type's typeSymbol should never be inspected directly.
||
sym1 == NothingClass
||
- // Console.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " (sym2 isSubClass ObjectClass))
+ //{ Console.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " + (sym2 isSubClass ObjectClass)); true } &&
sym1 == NullClass &&
- sym2.isClass && (sym2 isNonBottomSubClass ObjectClass) && (!(tp2.normalize.typeSymbol isNonBottomSubClass NotNullClass)))
+ sym2.isClass && (sym2 isNonBottomSubClass ObjectClass) && (!(tp2.normalize.typeSymbol isNonBottomSubClass NotNullClass))
+ ||
+ {
+ val tp1n = normalizePlus(tp1)
+ val tp2n = normalizePlus(tp2)
+ ((tp1n ne tp1) || (tp2n ne tp2)) && isSubType(tp1n, tp2n, depth)
+ })
case (MethodType(pts1, res1), MethodType(pts2, res2)) =>
(pts1.length == pts2.length &&
matchingParams(pts1, pts2, tp1.isInstanceOf[JavaMethodType], tp2.isInstanceOf[JavaMethodType]) &&
@@ -3620,9 +3626,9 @@ A type's typeSymbol should never be inspected directly.
if (sym2 == SingletonClass && tp1.isStable) =>
true
case (_, RefinedType(parents2, ref2)) =>
- (parents2 forall (tp2 => tp1 <:< tp2 || tp2.typeSymbol == NotNullClass && tp1.isNotNull)) &&
+ (parents2 forall (tp2 => tp1 <:< tp2)) &&
(ref2.toList forall tp1.specializes) &&
- (!parents2.exists(_.typeSymbol.isAbstractType) || tp1.typeSymbol != NullClass)
+ (tp1.typeSymbol != NullClass || !parents2.exists(_.typeSymbol.isAbstractType))
case (ExistentialType(_, _), _) =>
try {
skolemizationLevel += 1
@@ -4291,14 +4297,20 @@ A type's typeSymbol should never be inspected directly.
/** If option `explaintypes' is set, print a subtype trace for
* `found <:< required'.
- *
- * @param found ...
- * @param required ...
*/
def explainTypes(found: Type, required: Type) {
if (settings.explaintypes.value) withTypesExplained(found <:< required)
}
+ /** If option `explaintypes' is set, print a subtype trace for
+ * `op(found, required)'.
+ */
+ def explainTypes(op: (Type, Type) => Any, found: Type, required: Type) {
+ if (settings.explaintypes.value) withTypesExplained(op(found, required))
+ }
+
+ /** Execute `op' while printing a trace of the operations on types executed.
+ */
def withTypesExplained[A](op: => A): A = {
val s = explainSwitch
try { explainSwitch = true; op } finally { explainSwitch = s }
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index ddbd83daae..ab020716d2 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -122,7 +122,10 @@ abstract class Mixin extends InfoTransform {
def isOverriddenAccessor(member: Symbol, bcs: List[Symbol]): Boolean = atPhase(ownPhase) {
def hasOverridingAccessor(clazz: Symbol) = {
clazz.info.nonPrivateDecl(member.name).alternatives.exists(
- sym => isConcreteAccessor(sym) && matchesType(sym.tpe, member.tpe, true))
+ sym =>
+ isConcreteAccessor(sym) &&
+ !sym.hasFlag(MIXEDIN) &&
+ matchesType(sym.tpe, member.tpe, true))
}
bcs.head != member.owner &&
(hasOverridingAccessor(bcs.head) || isOverriddenAccessor(member, bcs.tail))
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 6c50f40d9b..30a1fdc202 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -218,9 +218,10 @@ abstract class RefChecks extends InfoTransform {
//if (!member.typeParams.isEmpty) // (1.7) @MAT
// overrideError("may not be parameterized");
var memberTp = self.memberType(member)
-
- if (!(self.memberInfo(other).bounds containsType memberTp)) { // (1.7.1) {
+ val otherTp = self.memberInfo(other)
+ if (!(otherTp.bounds containsType memberTp)) { // (1.7.1) {
overrideTypeError(); // todo: do an explaintypes with bounds here
+ explainTypes(_.bounds containsType _, otherTp, memberTp)
}
// check overriding (abstract type --> abstract type or abstract type --> concrete type member (a type alias))