From fbc48c2275b5b3f594af25e2be05a392d3e10449 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 31 Dec 2017 15:27:39 +0100 Subject: [PATCH] Handle SkolemTypes in avoid --- compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala | 2 ++ tests/pos/i3637.scala | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/pos/i3637.scala diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index bd7662032daf..59210fde2ea7 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -110,6 +110,8 @@ trait TypeAssigner { } case tp: ThisType if toAvoid(tp.cls) => range(tp.bottomType, apply(classBound(tp.cls.classInfo))) + case tp: SkolemType if partsToAvoid(mutable.Set.empty, tp.info).nonEmpty => + range(tp.info.bottomType, apply(tp.info)) case tp: TypeVar if ctx.typerState.constraint.contains(tp) => val lo = ctx.typeComparer.instanceType(tp.origin, fromBelow = variance >= 0) val lo1 = apply(lo) diff --git a/tests/pos/i3637.scala b/tests/pos/i3637.scala new file mode 100644 index 000000000000..542199800701 --- /dev/null +++ b/tests/pos/i3637.scala @@ -0,0 +1,10 @@ +import reflect.ClassTag + +object Demo { + def the[T](implicit ev: T): ev.type = ev // More precise implicitly, needed to crash + + { + case class B(i: Int) + the[ClassTag[B]] // Has to be the last statement of the block + } +}