-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
Description
Reproduction steps
- works in Scala 3.3.6
- bad in Scala 2.13.16
private val CLASS_STACK_WALKER: java.util.function.Function[
java.util.stream.Stream[StackWalker.StackFrame], Array[Class[_]]] =
(frames: java.util.stream.Stream[StackWalker.StackFrame]) =>
frames.map(frame => frame.getDeclaringClass)
.toArray((size: Int) => new Array[Class[_]](size))
Problem
type mismatch;
[error] found : Array[Class[_]]
[error] required: Array[Class[Nothing]]
[error] Note: Class[_] >: Class[Nothing], but class Array is invariant in type T.
[error] You may wish to investigate a wildcard type such as `_ >: Class[Nothing]`. (SLS 3.2.10)
[error] .toArray((size: Int) => new Array[Class[_]](size))
How to fix:
Add the [Class[_]]
private val CLASS_STACK_WALKER: java.util.function.Function[
java.util.stream.Stream[StackWalker.StackFrame], Array[Class[_]]] =
(frames: java.util.stream.Stream[StackWalker.StackFrame]) =>
frames.map(frame => frame.getDeclaringClass)
.toArray[Class[_]]((size: Int) => new Array[Class[_]](size))
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)