-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
class Foo {
def foo(x: String|Null): Int = 100
}
erases to
package <empty> {
@scala.annotation.internal.SourceFile("kk.scala") trait Foo() extends Object {
def foo(x: Object): Int = 100
}
}
instead of def foo(x: String): Int = 100
.
This is just an unintended consequence of erasedLub going up the class hierarchy (as opposed to the type hierarchy), where Null's parent is AnyRef and not String.
https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/TypeErasure.scala#L286
It seems like we should special-case Null
and Nothing
in erasedLub
.