Skip to content

Exports generate broken code depending on location (scope) of said code #20079

Closed
@lbialy

Description

@lbialy

This is related to VirtusLab/besom#430.

This issue is really mind-bending: in repro in Besom repo I have this working fine if object exporting these implicit methods is in test scope but failing steadily if it's in main scope. Running scala-cli test . in this repro shows the same behavior: in main crashes while in test and local both work. If you do however run tests from metals in main and in test tests fail but local works!

Compiler version

3.3.1

Minimized code

https://github.com/lbialy/besom-issue-430

Output

Run scala-cli test . in the main folder of this repo and you will get:

repro.Suite:
==> X repro.Suite.in main  0.006s java.lang.ClassCastException: class scala.collection.immutable.$colon$colon cannot be cast to class scala.collection.View (scala.collection.immutable.$colon$colon and scala.collection.View are in unnamed module of loader 'app')
    at scala.collection.BuildFrom$$anon$8.fromSpecific(BuildFrom.scala:85)
    at repro.Output$.sequence(output.scala:20)
    at repro.OutputExtensionsFactory$OutputSequenceOps.sequence(output.scala:26)
    at repro.OutputExtensionsFactory$OutputTraverseOps.traverse(output.scala:30)
    at repro.Suite.$init$$$anonfun$1(suite.test.scala:19)
  + in test 0.001s
  + local 0.001s

Expectation

I would expect that Array("a", "b").toList.traverse(str => ...) would infer CC type param in traverse as List and not View:
Screenshot 2024-04-03 at 14 34 31

toList infers List[File]:
Screenshot 2024-04-03 at 11 46 35
but then traverse infers Output[View[X]]:
Screenshot 2024-04-03 at 11 47 00

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions