dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.07k stars 1.56k forks source link

`document.elementsFromPoint()` returns `List<dynamic>` under DDC #36002

Open seanburke-wf opened 5 years ago

seanburke-wf commented 5 years ago

Though elementsFromPoint() is typed as List<Element>, the actual return value under DDC is List<dynamic>. The following repro case will produce a runtime error when run via webdev serve:

import 'dart:html';

main() async {
  var foo = document.elementsFromPoint(5, 5);

  List<Element> elements = [];
  elements.addAll(foo);
}
aaronstgeorge-wf commented 5 years ago

I've found a similar behavior with window.navigator.languages the reported type is List<String>, the actual value under DDC is List<dynamic>.

vsmenon commented 5 years ago

@terrylucas - I think we'd need to either (a) statically type this as List<dynamic> or (b) reify / tag it at runtime as List<String>.

todbachman-wf commented 5 years ago

I've run into another API that is exhibiting similar behavior: window.performance.getEntriesByType. The return type is expected to be List<PerformanceEntry>, but when compiled with DDC it returns List<dynamic> and when compiled with dart2js it returns JSArray.