Summary
Least upper bound returns top type for a nullable type NullableType(T1_inner) and a non-nullable type T2 if T2 is not a subtype of T1_inner, even if there is a more specific bound.
Todo
[x] Write test
[x] Fix
Description
Example code
data Fruit = foreign java Fruit {}
data Orange <: Fruit = foreign java Orange {}
data Banana <: Fruit = foreign java Banana {}
func lub_nullable(orange: Orange, banana: Banana) -> unit = {
val x = [orange, banana?]
; unit
}
Expected: type of x is Fruit?*
Actual: type of x is TOP*
Summary Least upper bound returns top type for a nullable type
NullableType(T1_inner)
and a non-nullable typeT2
ifT2
is not a subtype ofT1_inner
, even if there is a more specific bound.Todo
Description Example code
Expected: type of
x
isFruit?*
Actual: type ofx
isTOP*