From 41e22296813188b1def6bc948e138244afd9cb92 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 14 Jan 2014 13:02:57 +0100 Subject: Renaming to make program Scala2x and Dotty compatible. --- src/dotty/tools/dotc/core/Substituters.scala | 2 +- src/dotty/tools/dotc/core/Types.scala | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools') diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala index 0df1ea49f..944931698 100644 --- a/src/dotty/tools/dotc/core/Substituters.scala +++ b/src/dotty/tools/dotc/core/Substituters.scala @@ -10,7 +10,7 @@ trait Substituters { this: Context => final def subst(tp: Type, from: BindingType, to: BindingType, map: SubstBindingMap): Type = tp match { case tp: BoundType => - if (tp.binder eq from) tp.copy(to.asInstanceOf[tp.BT]) else tp + if (tp.binder eq from) tp.copyBoundType(to.asInstanceOf[tp.BT]) else tp case tp: NamedType => if (tp.symbol.isStatic) tp else tp.derivedSelect(subst(tp.prefix, from, to, map)) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 85e89fa62..4e961ecd9 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1644,7 +1644,11 @@ object Types { abstract class BoundType extends UncachedProxyType with ValueType { type BT <: BindingType def binder: BT - def copy(bt: BT): Type + // Dotty deviation: copyBoundType was copy, but + // dotty generates copy methods always automatically, and therefore + // does not accept same-named method definitions in subclasses. + // Scala2x, on the other hand, requires them (not sure why!) + def copyBoundType(bt: BT): Type } abstract class ParamType extends BoundType { @@ -1654,7 +1658,7 @@ object Types { case class MethodParam(binder: MethodType, paramNum: Int) extends ParamType with SingletonType { type BT = MethodType override def underlying(implicit ctx: Context): Type = binder.paramTypes(paramNum) - def copy(bt: BT) = MethodParam(bt, paramNum) + def copyBoundType(bt: BT) = MethodParam(bt, paramNum) // need to customize hashCode and equals to prevent infinite recursion for dep meth types. override def hashCode = System.identityHashCode(binder) + paramNum @@ -1670,7 +1674,7 @@ object Types { case class PolyParam(binder: PolyType, paramNum: Int) extends ParamType { type BT = PolyType - def copy(bt: BT) = PolyParam(bt, paramNum) + def copyBoundType(bt: BT) = PolyParam(bt, paramNum) /** Looking only at the structure of `bound`, is one of the following true? * - fromBelow and param <:< bound @@ -1693,7 +1697,8 @@ object Types { case class RefinedThis(binder: RefinedType) extends BoundType with SingletonType { type BT = RefinedType override def underlying(implicit ctx: Context) = binder.parent - def copy(bt: BT) = RefinedThis(bt) + def copyBoundType(bt: BT) = RefinedThis(bt) + // need to customize hashCode and equals to prevent infinite recursion for // refinements that refer to the refinement type via this override def hashCode = System.identityHashCode(binder) -- cgit v1.2.3