diff options
author | Martin Odersky <odersky@gmail.com> | 2013-10-27 18:33:57 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-10-27 18:33:57 +0100 |
commit | 52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53 (patch) | |
tree | 7f029c717a8f8ea0787f669412ce2047e68a630d /src/dotty/tools/dotc/core/Types.scala | |
parent | 41e7d9d46177650d23447f99989e8347aca56e71 (diff) | |
download | dotty-52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53.tar.gz dotty-52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53.tar.bz2 dotty-52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53.zip |
Fixed unpickling of polymorphic constructors.
Constructors of parameterized classes now get polymorphic types when unpickled, as is the case when defining them or when reading them from a Java classfile. This caused a ripple of other faults which this commit also fixes.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 5f60454b5..ea4d1f572 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -901,6 +901,17 @@ object Types { if (buf == null) Nil else buf.toList } + /** The core type without any type arguments. + * @param `typeArgs` must be the type arguments of this type. + */ + final def withoutArgs(typeArgs: List[Type]): Type = typeArgs match { + case _ :: typeArgs1 => + val RefinedType(tycon, _) = this + tycon.withoutArgs(typeArgs.tail) + case nil => + this + } + /** If this is the image of a type argument to type parameter `tparam`, * recover the type argument, otherwise NoType. */ @@ -1504,10 +1515,17 @@ object Types { def derivedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type)(implicit ctx: Context): RefinedType = { def originalName = parent.typeParams.apply(refinedName.hkParamIndex).name + def checkForTypeParams(tpe: Type): Boolean = tpe match { + case tpe: NamedType => tpe.symbol.isCompleted + case ThisType(cls) => cls.isCompleted + case tpe: BoundType => false + case tp: TypeProxy => checkForTypeParams(tp.underlying) + case _ => true + } 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 + checkForTypeParams(parent) && // to avoid cyclic reference errors refinedName.hkParamIndex < typeParams.length && originalName != refinedName) derivedRefinedType(parent, originalName, refinedInfo) |