aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-08-28 18:22:36 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-28 18:22:36 +0200
commite195a2e31320edc796a6ef84d1ad13dc5b5b3732 (patch)
treebbda1ae7aaa92f5de7cb63dedb6dfcba476d8072 /src/dotty/tools/dotc/core/Types.scala
parent7663191c433e101e3e4faab2e0db12c5f4db1fc2 (diff)
downloaddotty-e195a2e31320edc796a6ef84d1ad13dc5b5b3732.tar.gz
dotty-e195a2e31320edc796a6ef84d1ad13dc5b5b3732.tar.bz2
dotty-e195a2e31320edc796a6ef84d1ad13dc5b5b3732.zip
Fix in underlyingClassRef
Made implementation conform to doc comment.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index e09d54a23..9effa59fe 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -658,7 +658,10 @@ object Types {
* a class, the class type ref, otherwise NoType.
*/
def underlyingClassRef(implicit ctx: Context): Type = dealias match {
- case tp: TypeRef if tp.symbol.isClass => tp
+ case tp: TypeRef =>
+ if (tp.symbol.isClass) tp
+ else if (tp.symbol.isAliasType) tp.underlying.underlyingClassRef
+ else NoType
case tp: TypeVar => tp.underlying.underlyingClassRef
case tp: AnnotatedType => tp.underlying.underlyingClassRef
case tp: RefinedType => tp.underlying.underlyingClassRef
@@ -2387,6 +2390,17 @@ object Types {
// Special type objects and classes -----------------------------------------------------
+ /** The type of an erased array */
+ abstract case class JavaArrayType(elemType: Type) extends CachedGroundType with ValueType {
+ override def computeHash = doHash(elemType)
+ def derivedJavaArrayType(elemtp: Type)(implicit ctx: Context) =
+ if (elemtp eq this.elemType) this else JavaArrayType(elemtp)
+ }
+ final class CachedJavaArrayType(elemType: Type) extends JavaArrayType(elemType)
+ object JavaArrayType {
+ def apply(elemType: Type)(implicit ctx: Context) = unique(new CachedJavaArrayType(elemType))
+ }
+
/** The type of an import clause tree */
case class ImportType(expr: Tree) extends UncachedGroundType
@@ -2569,6 +2583,9 @@ object Types {
case tp @ WildcardType =>
tp.derivedWildcardType(mapOver(tp.optBounds))
+ case tp: JavaArrayType =>
+ tp.derivedJavaArrayType(this(tp.elemType))
+
case tp: ProtoType =>
tp.map(this)
@@ -2699,6 +2716,9 @@ object Types {
case tp: WildcardType =>
this(x, tp.optBounds)
+ case tp: JavaArrayType =>
+ this(x, tp.elemType)
+
case tp: ProtoType =>
tp.fold(x, this)