Skip to content

Commit 6a2d978

Browse files
committed
Undo #7130
Undo the change where we do not interpolate a type variable if its lower bound is nothing. It turned out this broke type inference.
1 parent bc43b3a commit 6a2d978

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,7 @@ trait Inferencing { this: Typer =>
433433
else if (!hasUnreportedErrors)
434434
if (v.intValue != 0) {
435435
typr.println(i"interpolate $tvar in $state in $tree: $tp, fromBelow = ${v.intValue == 1}, $constraint")
436-
if (true) {
437-
val fromBelow = v.intValue == 1
438-
val instType = ctx.typeComparer.instanceType(tvar.origin, fromBelow)
439-
if (!(fromBelow && instType.isRef(defn.NothingClass)))
440-
tvar.instantiateWith(instType)
441-
}
442-
else
443-
tvar.instantiate(fromBelow = v.intValue == 1)
436+
tvar.instantiate(fromBelow = v.intValue == 1)
444437
}
445438
else typr.println(i"no interpolation for nonvariant $tvar in $state")
446439
}
File renamed without changes.
File renamed without changes.

tests/pos/i7149.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait ZIO[-R, +E, +A] { self =>
2+
3+
final def +++[R1, B, E1 >: E](that: ZIO[R1, E1, B]): ZIO[Either[R, R1], E1, Either[A, B]] =
4+
for {
5+
e <- ZIO.environment[Either[R, R1]]
6+
r <- e.fold(self.map(Left(_)) provide _, that.map(Right(_)) provide _)
7+
} yield r
8+
// Found: (Left[A, Any] | Right[Any, B])(r)
9+
// Required: Either[A, B]
10+
11+
def flatMap[R1 <: R, E1 >: E, B](f: A => ZIO[R1, E1, B]): ZIO[R1, E1, B] = ???
12+
13+
def map[B](f: A => B): ZIO[R, E, B] = ???
14+
15+
def provide[R](R: R): ZIO[Any, E, A] = ???
16+
}
17+
18+
object ZIO {
19+
def environment[R]: ZIO[R, Nothing, R] = ???
20+
}

0 commit comments

Comments
 (0)