Hej,
we are currently working on a static type inference for Dart and in this respect also take a look at the dart2js compiler code base. While this is work in progress, we have found the following case, which we think is a somewhat imprecise type annotation (i.e., the annotated static type for ' mirrorSystemGetNameNodes' does not provide a property which is later accessed whilst the actual type provides it) in dart2js:
> // pkg/compiler/lib/src/mirror_renamer/renamer.dart
> class MirrorRenamerImpl implements MirrorRenamer {
> // imprecise annotated type, proposed fix: replace by List<Send> and <Send>[], respectively
> List<Node> mirrorSystemGetNameNodes = <Node>[];
> ...
> void registerStaticSend(Element currentElement, Element target, Send node) {
> ...
> // only place where mirrorSystemGetNameNodes is modified
> mirrorSystemGetNameNodes.add(node);
> ...
> mirrorSystemGetNameNodes.forEach((node) {
> // annotated type is List<Node>, but Node does not provide properties selector/receiver
> renames[node.selector] = renames[getNameFunctionNode.name];
> renames[node.receiver] = '';
> // pkg/compiler/lib/src/tree/nodes.dart
> abstract class Node extends NullTreeElementMixin implements Spannable {
> // no property defined for name selector or receiver
> ...
>
> abstract class Expression extends Node {
> // no property defined for name selector or receiver
> ...
>
> class Send extends Expression with StoredTreeElementMixin {
> final Node receiver;
> final Node selector;
> ...
> // pkg/compiler/lib/src/mirror_renamer/mirror_renamer.dart
> class MirrorRenamer {
> void registerStaticSend(Element currentElement, Element target, Node node) {}
> ...
> // pkg/compiler/lib/src/dart_backend/placeholder_collector.dart
> ...
> visitStaticSend(Send node) {
> Element element = elements[node];
> // only call for method with this name
> collector.mirrorRenamer.registerStaticSend(
> collector.currentElement, element, node);
Our proposed fix would be, as noted in the comments, to replace 'List<Node>' by 'List<Send>' and '<Node>[]' by '<Send>[]'.
Kind regards
Thomas Heinze
To unsubscribe from this group and stop receiving emails from it, send an email to compiler-dev...@dartlang.org.