Skip to content

Commit 6ccc786

Browse files
Backport "fix(#i18645): overload ext method body in braces didn't compile" to LTS (#20916)
Backports #19651 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 0155d65 + b49f016 commit 6ccc786

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ object ProtoTypes {
394394
case closureDef(mdef) => hasInnerErrors(mdef.rhs)
395395
case _ =>
396396
t.existsSubTree { t1 =>
397-
if t1.typeOpt.isError && t1.span.toSynthetic != t.span.toSynthetic then
397+
if t1.typeOpt.isError
398+
&& t.span.toSynthetic != t1.span.toSynthetic
399+
&& t.typeOpt != t1.typeOpt then
398400
typr.println(i"error subtree $t1 of $t with ${t1.typeOpt}, spans = ${t1.span}, ${t.span}")
399401
true
400402
else

Diff for: tests/pos/i18645.scala

+16
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)