Skip to content

Commit 8776677

Browse files
authored
fix(#i18645): overload ext method body in braces didn't compile (#19651)
2 parents c8fd719 + 5a41b9c commit 8776677

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ object ProtoTypes {
407407
case closureDef(mdef) => hasInnerErrors(mdef.rhs)
408408
case _ =>
409409
t.existsSubTree { t1 =>
410-
if t1.typeOpt.isError && t1.span.toSynthetic != t.span.toSynthetic then
410+
if t1.typeOpt.isError
411+
&& t.span.toSynthetic != t1.span.toSynthetic
412+
&& t.typeOpt != t1.typeOpt then
411413
typr.println(i"error subtree $t1 of $t with ${t1.typeOpt}, spans = ${t1.span}, ${t.span}")
412414
true
413415
else

tests/pos/i18645.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait Printable {
2+
def pprint(v: () => String): Unit = {
3+
println(v())
4+
}
5+
}
6+
7+
extension (ctx: Printable)
8+
def pprint(f: () => Int): Unit = {
9+
ctx.pprint(() => f().toString)
10+
}
11+
12+
val x = new Printable {}
13+
14+
def test =
15+
x.pprint(() => ( 234 ))
16+
x.pprint(() => { 123 })

0 commit comments

Comments
 (0)