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
On top of equality (#444), we also need to decide on type literal semantics and the toString behavior of Type objects for NNBD.
A legacy library may expect (<T>()=>T)<int>().toString() to return int. However the actual type is int*. That suggests that we should not put the * into the toString of legacy types.
We can either say that we never include *, or that we only include * when a non-legacy type is part of the type represented by the Type object. That is, the toString of List<int*>* is "List<int>", but the toString of List<int*>? is "List<int*>?".
It's still possible to have different types with the same toString, the types List<int> and List<int*>* would both give List<int> as toString. That is unavoidable unless we mark non-nullable types (say with !), but we do not want that in the long run.
(The option of simply removing Type.toString and making it always return [Instance of Type] is probably too breaking, even if it would be great).
We could also add nnbdTypeToString() to Type which includes all annotations and make toString return the "legacy" toString. Not particularly good design. Or give Type.toString a parameter which makes it return an NNBD string instead of a legacy string. That would need a later migration to switch the default of that parameter, so that we can eventually remove it when removing NNBD-legacy mode completely.
Another question is what type a type literal represents.
int should represent non-nullable intin an NNBD-enabled library. That's the only future-proof value. What should int represent in a NNBD-legacy library? Likely int*. Then we are back to Equality of Type objects with NNBD types. #444 because it might be confusing if the two are not equal.
Assume a class like class C<T extends C<T>> {}.Then C as a type literal will trigger instantiate-to-bounds. Should instantiate-to-bounds be computed in the declaring or referring library, which may matter if one is NNBD and the other is legacy. Assuming the declaring library is NNBD-enabled the computed (super-)bound is C<dynamic>. Will the type literal in the legacy library be C<C<dymamic>>* or C<C<dynamic>*>*...? (since dynamic* is probably equivalent to dynamic),
The text was updated successfully, but these errors were encountered:
On top of equality (#444), we also need to decide on type literal semantics and the
toString
behavior ofType
objects for NNBD.A legacy library may expect
(<T>()=>T)<int>().toString()
to returnint
. However the actual type isint*
. That suggests that we should not put the*
into thetoString
of legacy types.We can either say that we never include
*
, or that we only include*
when a non-legacy type is part of the type represented by theType
object. That is, thetoString
ofList<int*>*
is"List<int>"
, but thetoString
ofList<int*>?
is"List<int*>?"
.It's still possible to have different types with the same
toString
, the typesList<int>
andList<int*>*
would both giveList<int>
astoString
. That is unavoidable unless we mark non-nullable types (say with!
), but we do not want that in the long run.(The option of simply removing
Type.toString
and making it always return[Instance of Type]
is probably too breaking, even if it would be great).We could also add
nnbdTypeToString()
toType
which includes all annotations and maketoString
return the "legacy" toString. Not particularly good design. Or giveType.toString
a parameter which makes it return an NNBD string instead of a legacy string. That would need a later migration to switch the default of that parameter, so that we can eventually remove it when removing NNBD-legacy mode completely.Another question is what type a type literal represents.
int
should represent non-nullableint
in an NNBD-enabled library. That's the only future-proof value. What shouldint
represent in a NNBD-legacy library? Likelyint*
. Then we are back to Equality ofType
objects with NNBD types. #444 because it might be confusing if the two are not equal.Assume a class like
class C<T extends C<T>> {}
.ThenC
as a type literal will trigger instantiate-to-bounds. Should instantiate-to-bounds be computed in the declaring or referring library, which may matter if one is NNBD and the other is legacy. Assuming the declaring library is NNBD-enabled the computed (super-)bound isC<dynamic>
. Will the type literal in the legacy library beC<C<dymamic>>*
orC<C<dynamic>*>*
...? (sincedynamic*
is probably equivalent todynamic
),The text was updated successfully, but these errors were encountered: