Skip to content

Commit 8ddfbd6

Browse files
committed
Fix #6734: Suppress interpolattion for extension methods
Suppress interpolation in the middle of an ExtMethodApply. The reason is that the ExtMethodApply has a WildcardType, which hides information about bound type variables in the result type.
1 parent e2f4070 commit 8ddfbd6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ trait Inferencing { this: Typer =>
384384
// `qualifying`.
385385

386386
val ownedVars = state.ownedVars
387-
if ((ownedVars ne locked) && !ownedVars.isEmpty) {
387+
if ((ownedVars ne locked) && !ownedVars.isEmpty &&
388+
!tree.isInstanceOf[Applications.IntegratedTypeArgs] // suppress interpolation in the middle of an extension method application
389+
) {
388390
val qualifying = ownedVars -- locked
389391
if (!qualifying.isEmpty) {
390392
typr.println(i"interpolate $tree: ${tree.tpe.widen} in $state, owned vars = ${state.ownedVars.toList}%, %, previous = ${locked.toList}%, % / ${state.constraint}")

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)