From 0dba636130702c0f1ca9cd977695e23c4a7c2c28 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 5 Feb 2020 09:51:04 +0100 Subject: [PATCH] Fix #8198: Handle trees with TypedSplice --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 5 +++-- tests/pos/i8198.scala | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i8198.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 703c0831fcd6..a91dda90b85d 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -948,8 +948,9 @@ trait Applications extends Compatibility { * { val xs = es; e' = e' + args } */ def typedOpAssign(implicit ctx: Context): Tree = { - val Apply(Select(lhs, name), rhss) = tree - val lhs1 = typedExpr(lhs) + val (lhs1, name, rhss) = tree match + case Apply(Select(lhs, name), rhss) => (typedExpr(lhs), name, rhss) + case Apply(untpd.TypedSplice(Select(lhs1, name)), rhss) => (lhs1, name, rhss) val liftedDefs = new mutable.ListBuffer[Tree] val lhs2 = untpd.TypedSplice(LiftComplex.liftAssigned(liftedDefs, lhs1)) val assign = untpd.Assign(lhs2, diff --git a/tests/pos/i8198.scala b/tests/pos/i8198.scala new file mode 100644 index 000000000000..0fa8ec704325 --- /dev/null +++ b/tests/pos/i8198.scala @@ -0,0 +1,10 @@ +trait Eq[A] { + def (x: A) === (y: A): Boolean + def (x: A) /== (y: A): Boolean = !(x === y) +} + +case class Id[T](id: T) + +given idEq[A](given eqA: Eq[A]): Eq[Id[A]] = new { + def (i1: Id[A]) === (i2: Id[A]) = !(i1.id /== i2.id) +}