Skip to content

Commit

Permalink
fix(#i18645): overload ext method body in braces didn't compile (#19651)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand authored Feb 13, 2024
2 parents c8fd719 + 5a41b9c commit 8776677
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/pos/i18645.scala
Original file line number Diff line number Diff line change
@@ -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 })

0 comments on commit 8776677

Please sign in to comment.