From 42b8c1df6e22bf8a8fd982bbd542d6fc427f8deb Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 24 Sep 2014 17:17:17 +0200 Subject: TypeTestsCasts now handles casts to constant types. --- src/dotty/tools/dotc/core/Types.scala | 2 ++ src/dotty/tools/dotc/transform/TypeTestsCasts.scala | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 59adf764e..5348bac31 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -255,6 +255,8 @@ object Types { * value type, or because superclasses are ambiguous). */ final def classSymbol(implicit ctx: Context): Symbol = this match { + case ConstantType(constant) => + constant.tpe.classSymbol case tp: TypeRef => val sym = tp.symbol if (sym.isClass) sym else tp.underlying.classSymbol diff --git a/src/dotty/tools/dotc/transform/TypeTestsCasts.scala b/src/dotty/tools/dotc/transform/TypeTestsCasts.scala index 8c9ffb1fb..4f5c47c99 100644 --- a/src/dotty/tools/dotc/transform/TypeTestsCasts.scala +++ b/src/dotty/tools/dotc/transform/TypeTestsCasts.scala @@ -78,7 +78,7 @@ class TypeTestsCasts extends MiniPhaseTransform { } def transformAsInstanceOf(argType: Type): Tree = { - def argCls = argType.classSymbol + def argCls = argType.widen.classSymbol if (qual.tpe <:< argType) Typed(qual, tree.args.head) else if (qualCls.isPrimitiveValueClass) { -- cgit v1.2.3