Skip to content

Java collection conversions #21297

@DavidPerezIngeniero

Description

@DavidPerezIngeniero

Compiler version

3.3.3 and 3.4.2

Minimized code

scala-cli -j system -S 2.13.14 --dep org.python:jython-standalone:2.7.1b3 scala> val x = new org.python.core.PyList val x: org.python.core.PyList = [] scala> import scala.jdk.CollectionConverters._ import scala.jdk.CollectionConverters._ scala> x.asScala val res0: scala.collection.mutable.Buffer[_] = Buffer() 
Welcome to Scala 3.3.3 (21.0.3, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. scala> val x = new org.python.core.PyList val x: org.python.core.PyList = [] scala> import scala.jdk.CollectionConverters.* scala> x.asScala -- [E008] Not Found Error: ----------------------------------------------------- 1 |x.asScala |^^^^^^^^^ |value asScala is not a member of org.python.core.PyList 1 error found 

Scala 3.4.2 behaves like 3.3.3

Output

Scala 3 doesn't compile, Scala 2 does.

Expectation

Scala 2 and 3 behave the same

Notes

Take into account that PyList is just a wrapper around java.util.List:

public class PyList extends PySequenceList implements List { .... } 

https://stackoverflow.com/questions/78811147/scala-3-bug-in-collection-conversions

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions