-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js
Milestone
Description
Generic types should to display type parameters, even when dynamic or missing.
Types are displayed via o.runtimeType and in TypeError (CastError) messages.
When displayed in a TypeError message, the type parameters may have been erased:
class Foo<T extends num> {}
main() {
dynamic f = new Foo<int>();
List<String> a = f;
}When Foo.T has been erased, should the message display without the types, or with the defaulted (incorrect) bounds, or some indicator?
TypeError: Instance of 'Foo': type 'Foo' is not a subtype of type 'List<String>'
TypeError: Instance of 'Foo<num>': type 'Foo<num>' is not a subtype of type 'List<String>'
TypeError: Instance of 'Foo<?>': type 'Foo<?>' is not a subtype of type 'List<String>'
I think we will go with the raw type for now.
Types will be present if o.runtimeType is present. We will need to revisit this topic if we allow erasure and o.runtimeType, or if we implement partial (allocation-site specific) erasure.
- Change printed raw types
- JSArray might still usefully print as
JSArray<dynamic>from a Dart allocation andJSArrayfor allocations from interop code. If the array instance has type parameter erasure, we can't tell the difference!
- JSArray might still usefully print as
- Handle types optimized by erasing types
- Default-to-bound in forwarding stubs dart2js: Incorrect type variable bounds in argument defaulting stubs #32741
- Type literals
- Change type literals like
Setto print asSet<dynamic>. - Default types to bound in type literals.
FooisFoo<num>inclass Foo<T extends num> {} - If the type has erased type parameters, omit the type parameters.
- Ensure
new Foo().runtimeType == Foois always true.
- Change type literals like
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js