-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix overriding in explicit nulls #13647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
At https://github.com/lampepfl/dotty/blob/01f040bbf7b703a7aa0e8dc03799e0e142073410/compiler/src/dotty/tools/dotc/typer/RefChecks.scala#L564 , would is be better to write According to |
Yes, matching should be symmetric, if it isn't it's a bug, so the order doesn't matter. |
Maybe we're looking at this the wrong way? FromJavaObject is defined as a type alias of Object (https://github.com/lampepfl/dotty/blob/eb8773ecbedd32b7f7f6822696f3c3df3cde6930/compiler/src/dotty/tools/dotc/core/Definitions.scala#L407), but maybe it should be a type alias of |
@smarter We don't need to change the FromJavaObject alias in explicit nulls, because we are going nullify the types from Java anyway. I added some logic in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Fix #13040 #13486 #13608.
During overriding check,
Array[? <: FromJavaObject | Null].matchs(Array[? <: Object | Null])
is tested.The TypeBounds
? <: FromJavaObject | Null
is normalized with? <: Any
using&
(indef isSubArg
).Since
Any <:< FromJavaObject
, the intersection result is arbitrary, and in this case, is? <: Any
.Then,
? <: Any
is no longer a subtype of? <: Object | Null
, and the match test fails.This fix will handle
FromJavaObject
specially when computing the intersection of two TypeBounds. We will try to preserve the information ofFromJavaObject
in upper bounds.