diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 6b72f3a8b56e..9d5c1352b106 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -407,7 +407,9 @@ object ProtoTypes { case closureDef(mdef) => hasInnerErrors(mdef.rhs) case _ => t.existsSubTree { t1 => - if t1.typeOpt.isError && t1.span.toSynthetic != t.span.toSynthetic then + if t1.typeOpt.isError + && t.span.toSynthetic != t1.span.toSynthetic + && t.typeOpt != t1.typeOpt then typr.println(i"error subtree $t1 of $t with ${t1.typeOpt}, spans = ${t1.span}, ${t.span}") true else diff --git a/tests/pos/i18645.scala b/tests/pos/i18645.scala new file mode 100644 index 000000000000..599396b678af --- /dev/null +++ b/tests/pos/i18645.scala @@ -0,0 +1,16 @@ +trait Printable { + def pprint(v: () => String): Unit = { + println(v()) + } +} + +extension (ctx: Printable) + def pprint(f: () => Int): Unit = { + ctx.pprint(() => f().toString) + } + +val x = new Printable {} + +def test = + x.pprint(() => ( 234 )) + x.pprint(() => { 123 }) \ No newline at end of file