You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compile with scalac -Yexplicit-nulls Wrapper.scala
Output
-- [E007] Type Mismatch Error: Wrapper.scala:6:9 ------------------------------------------------------------------------------------------
6 | Some(result)
| ^^^^^^
| Found: (result : V | Null)
| Required: V
|
| longer explanation available when compiling with `-explain`
1 error found
Expectation
Should compile.
If result is inlined as follows, it compiles:
Some(map.put(k, v))
The text was updated successfully, but these errors were encountered:
I understand that this is as specified because V is not a subtype of AnyRef, and that the reason for the specification is to avoid accepting code that would be rejected without -Yexplicit-nulls, but this particular minimized example does compile without -Yexplicit-nulls.
Is there perhaps a variation of the specification that would allow this to compile? Perhaps replace V is a subtype of AnyRef with V is not a subtype of AnyVal?
There are other similar examples throughout the community build.
Compiler version
Scala compiler version 3.2.0-RC1-bin-SNAPSHOT-git-7fbbeef -- Copyright 2002-2022, LAMP/EPFL
Minimized code
Minimized from
stdLib213/src/library/scala/collection/convert/JavaCollectionWrappers.scala
Compile with
scalac -Yexplicit-nulls Wrapper.scala
Output
Expectation
Should compile.
If
result
is inlined as follows, it compiles:Some(map.put(k, v))
The text was updated successfully, but these errors were encountered: