Skip to content

Fix #6734: Suppress interpolation for extension methods #6780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,11 @@ class Typer extends Namer

/** Interpolate and simplify the type of the given tree. */
protected def simplify(tree: Tree, pt: Type, locked: TypeVars)(implicit ctx: Context): tree.type = {
if (!tree.denot.isOverloaded) // for overloaded trees: resolve overloading before simplifying
if (!tree.denot.isOverloaded &&
// for overloaded trees: resolve overloading before simplifying
!tree.isInstanceOf[Applications.IntegratedTypeArgs]
// don't interpolatie in the middle of an extension method application
)
if (!tree.tpe.widen.isInstanceOf[MethodOrPoly] // wait with simplifying until method is fully applied
|| tree.isDef) // ... unless tree is a definition
{
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i6734.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Bug {

def (ab: (A, B)) pipe2[A, B, Z](f: (A, B) => Z): Z = f(ab._1, ab._2)

def (a: A) leftErr[A, B](b: B): A = (a, b).pipe2((a, b) => a) //Did not compile before.
def (a: A) leftOk1[A, B](b: B): A = Tuple2(a, b).pipe2((a, b) => a) //Compiles
def (a: A) leftOk2[A, B](b: B): A = {
val t = (a, b)
t.pipe2((a, b) => a) //Compiles
}
}