Skip to content

Commit 2c388fa

Browse files
authored
Use inferred type transformer for SeqLiterals (#19472)
Fixes #19470
2 parents 3bf7b5d + f5ba0e9 commit 2c388fa

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
416416

417417
case tree @ SeqLiteral(elems, tpt: TypeTree) =>
418418
traverse(elems)
419-
transformTT(tpt, boxed = true, exact = false)
419+
tpt.rememberType(box(transformInferredType(tpt.tpe)))
420420

421421
case _ =>
422422
traverseChildren(tree)

tests/neg/i19470.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i19470.scala:9:12 -------------------------------------------------------------
2+
9 | List(foo(f())) // error
3+
| ^^^^^^^^
4+
| Found: Inv[? >: IO <: box IO^{f}]
5+
| Required: box Inv[box IO^?]^?
6+
|
7+
| longer explanation available when compiling with `-explain`

tests/neg/i19470.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import language.experimental.captureChecking
2+
trait IO
3+
case class Inv[X](x: X)
4+
5+
def foo(x: IO^): Inv[IO^{x}] = Inv(x)
6+
7+
def main(io: IO^): Unit =
8+
def test(f: () => IO^) =
9+
List(foo(f())) // error

0 commit comments

Comments
 (0)