Skip to content

Commit

Permalink
Use inferred type transformer for SeqLiterals (#19472)
Browse files Browse the repository at this point in the history
Fixes #19470
  • Loading branch information
Linyxus authored Jan 18, 2024
2 parents 3bf7b5d + f5ba0e9 commit 2c388fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:

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

case _ =>
traverseChildren(tree)
Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i19470.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- [E007] Type Mismatch Error: tests/neg/i19470.scala:9:12 -------------------------------------------------------------
9 | List(foo(f())) // error
| ^^^^^^^^
| Found: Inv[? >: IO <: box IO^{f}]
| Required: box Inv[box IO^?]^?
|
| longer explanation available when compiling with `-explain`
9 changes: 9 additions & 0 deletions tests/neg/i19470.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import language.experimental.captureChecking
trait IO
case class Inv[X](x: X)

def foo(x: IO^): Inv[IO^{x}] = Inv(x)

def main(io: IO^): Unit =
def test(f: () => IO^) =
List(foo(f())) // error

0 comments on commit 2c388fa

Please sign in to comment.