Skip to content

Commit 721f609

Browse files
authored
Merge pull request #6780 from dotty-staging/fix-#6734
Fix #6734: Suppress interpolation for extension methods
2 parents 317505e + 6ca6062 commit 721f609

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,11 @@ class Typer extends Namer
22062206

22072207
/** Interpolate and simplify the type of the given tree. */
22082208
protected def simplify(tree: Tree, pt: Type, locked: TypeVars)(implicit ctx: Context): tree.type = {
2209-
if (!tree.denot.isOverloaded) // for overloaded trees: resolve overloading before simplifying
2209+
if (!tree.denot.isOverloaded &&
2210+
// for overloaded trees: resolve overloading before simplifying
2211+
!tree.isInstanceOf[Applications.IntegratedTypeArgs]
2212+
// don't interpolate in the middle of an extension method application
2213+
)
22102214
if (!tree.tpe.widen.isInstanceOf[MethodOrPoly] // wait with simplifying until method is fully applied
22112215
|| tree.isDef) // ... unless tree is a definition
22122216
{

tests/pos/i6734.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Bug {
2+
3+
def (ab: (A, B)) pipe2[A, B, Z](f: (A, B) => Z): Z = f(ab._1, ab._2)
4+
5+
def (a: A) leftErr[A, B](b: B): A = (a, b).pipe2((a, b) => a) //Did not compile before.
6+
def (a: A) leftOk1[A, B](b: B): A = Tuple2(a, b).pipe2((a, b) => a) //Compiles
7+
def (a: A) leftOk2[A, B](b: B): A = {
8+
val t = (a, b)
9+
t.pipe2((a, b) => a) //Compiles
10+
}
11+
}

0 commit comments

Comments
 (0)