diff options
author | Martin Odersky <odersky@gmail.com> | 2013-09-23 12:28:57 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-09-23 12:28:57 +0200 |
commit | 2a8abfa8da9742e0a8b5460c6032d7ef610e44ab (patch) | |
tree | 3f94c270f779e8a4b72ed63ece37899b885d81d8 /src/dotty | |
parent | c90e09fc7bd79c3bf9c95ce87f3c11cb3dfd4405 (diff) | |
download | dotty-2a8abfa8da9742e0a8b5460c6032d7ef610e44ab.tar.gz dotty-2a8abfa8da9742e0a8b5460c6032d7ef610e44ab.tar.bz2 dotty-2a8abfa8da9742e0a8b5460c6032d7ef610e44ab.zip |
Avoided a cyclic reference error when dealing with hk types.
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index b97c569ef..33eeff5c8 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1423,6 +1423,7 @@ object Types { if ((parent eq this.parent) && (refinedName eq this.refinedName) && (refinedInfo eq this.refinedInfo)) this else if (refinedName.isHkParamName && + parent.typeSymbol.isCompleted && // to avoid cyclic reference errors refinedName.hkParamIndex < typeParams.length && originalName != refinedName) derivedRefinedType(parent, originalName, refinedInfo) @@ -1467,6 +1468,10 @@ object Types { if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this else AndType(tp1, tp2) + def derived_& (tp1: Type, tp2: Type)(implicit ctx: Context) = + if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this + else tp1 & tp2 + override def computeHash = doHash(tp1, tp2) } @@ -1482,6 +1487,10 @@ object Types { if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this else OrType(tp1, tp2) + def derived_| (tp1: Type, tp2: Type)(implicit ctx: Context) = + if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this + else tp1 | tp2 + override def computeHash = doHash(tp1, tp2) } @@ -1879,6 +1888,8 @@ object Types { else ClassInfo(prefix, cls, classParents, decls, selfInfo) override def computeHash = doHash(cls, prefix) + + override def toString = s"ClassInfo($prefix, $cls)" } final class CachedClassInfo(prefix: Type, cls: ClassSymbol, classParents: List[TypeRef], decls: Scope, selfInfo: DotClass) @@ -2123,6 +2134,12 @@ object Types { val inst = tp.instanceOpt if (inst.exists) apply(inst) else tp + case tp: AndType => + tp.derivedAndType(this(tp.tp1), this(tp.tp2)) + + case tp: OrType => + tp.derivedOrType(this(tp.tp1), this(tp.tp2)) + case tp @ WildcardType => tp.derivedWildcardType(mapOver(tp.optBounds)) @@ -2302,15 +2319,6 @@ object Types { class CyclicReference(val denot: SymDenotation) extends FatalTypeError(s"cyclic reference involving $denot") - class ClassMergeError(cinfo: ClassInfo, tp2: Type)(implicit ctx: Context) - extends FatalTypeError(s"cannot merge ${showTypeType(cinfo)} with ${showTypeType(tp2)} as members of ${cinfo.prefix.show}") - - private def showTypeType(tp: Type)(implicit ctx: Context) = tp match { - case ClassInfo(_, cls, _, _, _) => cls.showLocated - case bounds: TypeBounds => "type bounds" + bounds.show - case _ => tp.show - } - // ----- Debug --------------------------------------------------------- var debugTrace = false |