Introducing Nullable Reference Types in C#. Is there hope for D, too?
Ola Fosheim Grøstad
ola.fosheim.grostad+dlang at gmail.com
Tue Nov 21 18:51:46 UTC 2017
On Tuesday, 21 November 2017 at 18:00:37 UTC, Meta wrote:
> I don't quite understand the logic here, because it seems to be
> backwards reasoning. Constrain<U,? super T> is a valid type
> because null inhabits it? That doesn't make sense to me. He
> also cites the "implicit constraint" that X extends U where X
> is ? super T, but X does not meet that constraint (Constrain<U,
> X extends U>) so how can the type checker deduce that X
> extends U?
I haven't dug into the details of the paper as I think the
authors didn't try to appear neutral, e.g. quoting null as the
billon dollar mistake, and made their finding seem more
spectacular than it is… What I get from skimming over it is this:
You get a call:
upcast(constrain,x) -> String
where:
constrain is of type Constrain<String, X>
x is of type X (X is unspecified supertype of Integer)
return type is String, which has X as subclass
So you get String <: X <: Integer
The deduction that String is a superclass of Integer could come
from:
Constrain<String, X>
where X = ? super Integer = unknown type that is supertype of
Integer
More information about the Digitalmars-d
mailing list