diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeOps.scala | 2 | ||||
-rw-r--r-- | tests/pos/i2064.scala | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 6c40794e3..6e9e1f2e5 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -239,7 +239,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object. case tp1: RecType => tp1.rebind(approximateOr(tp1.parent, tp2)) case tp1: TypeProxy if !isClassRef(tp1) => - orDominator(tp1.superType | tp2) + orDominator(tp1.superType.bounds.hi | tp2) case _ => tp2 match { case tp2: RecType => diff --git a/tests/pos/i2064.scala b/tests/pos/i2064.scala new file mode 100644 index 000000000..909923372 --- /dev/null +++ b/tests/pos/i2064.scala @@ -0,0 +1,15 @@ +object p { + +class Foo[T] { + // Crashes: + def f(): Foo[T] = (if (true) this else this).bar + + // Works: + // def f(): Foo[T] = new Bar(if (true) this else this).bar +} + +implicit class Bar[A](val self: A) { + def bar(): A = self +} + +} |