diff --git a/pkg/dev_compiler/.travis.yml b/pkg/dev_compiler/.travis.yml index bf3ba7fdead2..ff2f86de42f8 100644 --- a/pkg/dev_compiler/.travis.yml +++ b/pkg/dev_compiler/.travis.yml @@ -14,6 +14,7 @@ before_install: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start before_script: + - nvm install 5.5.0 - npm install script: - ./tool/presubmit.sh && ./tool/coverage.sh diff --git a/pkg/dev_compiler/lib/runtime/dart/_debugger.js b/pkg/dev_compiler/lib/runtime/dart/_debugger.js index 4e541ef64a5d..972dfb559825 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_debugger.js +++ b/pkg/dev_compiler/lib/runtime/dart/_debugger.js @@ -13,14 +13,14 @@ dart_library.library('dart/_debugger', null, /* Imports */[ }, set _devtoolsFormatter(_) {} }); - function typeof$(object) { + function _typeof(object) { return typeof object; } - dart.fn(typeof$, core.String, [dart.dynamic]); - function instanceof$(object, clazz) { + dart.fn(_typeof, core.String, [dart.dynamic]); + function _instanceof(object, clazz) { return object instanceof clazz; } - dart.fn(instanceof$, core.bool, [dart.dynamic, dart.dynamic]); + dart.fn(_instanceof, core.bool, [dart.dynamic, dart.dynamic]); function getOwnPropertyNames(object) { return dart.as(dart.list(Object.getOwnPropertyNames(object), core.String), core.List$(core.String)); } @@ -45,14 +45,14 @@ dart_library.library('dart/_debugger', null, /* Imports */[ names: ['getProperty', 'setProperty'] }); function isRegularDartObject(object) { - if (typeof$(object) == 'function') return false; - return instanceof$(object, core.Object); + if (_typeof(object) == 'function') return false; + return _instanceof(object, core.Object); } dart.fn(isRegularDartObject, core.bool, [dart.dynamic]); function getObjectTypeName(object) { let realRuntimeType = dart.realRuntimeType(object); if (realRuntimeType == null) { - if (typeof$(object) == 'function') { + if (_typeof(object) == 'function') { return '[[Raw JavaScript Function]]'; } return ''; @@ -217,7 +217,7 @@ dart_library.library('dart/_debugger', null, /* Imports */[ let nameSpan = new JsonMLElement('span'); nameSpan.createTextChild(child.name != null ? dart.notNull(child.name) + ': ' : ''); nameSpan.setStyle('color: rgb(136, 19, 145);'); - if (typeof$(child.value) == 'object' || typeof$(child.value) == 'function') { + if (_typeof(child.value) == 'object' || _typeof(child.value) == 'function') { nameSpan.addStyle("padding-left: 13px;"); li.appendChild(nameSpan); let objectTag = li.createObjectTag(child.value); @@ -354,7 +354,7 @@ dart_library.library('dart/_debugger', null, /* Imports */[ }); class FunctionFormatter extends Formatter { accept(object) { - if (typeof$(object) != 'function') return false; + if (_typeof(object) != 'function') return false; return dart.realRuntimeType(object) != null; } hasChildren(object) { @@ -537,8 +537,6 @@ dart_library.library('dart/_debugger', null, /* Imports */[ dart.fn(registerDevtoolsFormatter); // Exports: exports.skipDartConfig = skipDartConfig; - exports.typeof = typeof$; - exports.instanceof = instanceof$; exports.getOwnPropertyNames = getOwnPropertyNames; exports.getOwnPropertySymbols = getOwnPropertySymbols; exports.JSNative = JSNative; diff --git a/pkg/dev_compiler/lib/runtime/dart/_js_mirrors.js b/pkg/dev_compiler/lib/runtime/dart/_js_mirrors.js index cc0d71f2d718..092a56acf2f9 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_js_mirrors.js +++ b/pkg/dev_compiler/lib/runtime/dart/_js_mirrors.js @@ -29,7 +29,6 @@ dart_library.library('dart/_js_mirrors', null, /* Imports */[ } dart.fn(reflectType, mirrors.TypeMirror, [core.Type]); const _dart = dart; - const _metadata = _dart.metadata; function _dload(obj, name) { return _dart.dload(obj, name); } @@ -96,12 +95,12 @@ dart_library.library('dart/_js_mirrors', null, /* Imports */[ [_toJsMap]: [dart.dynamic, [core.Map$(core.Symbol, dart.dynamic)]] }) }); - const _metadata$ = Symbol('_metadata'); + const _metadata = Symbol('_metadata'); const _declarations = Symbol('_declarations'); const _cls = Symbol('_cls'); class JsClassMirror extends core.Object { get metadata() { - return this[_metadata$]; + return this[_metadata]; } get declarations() { return this[_declarations]; @@ -109,10 +108,10 @@ dart_library.library('dart/_js_mirrors', null, /* Imports */[ _(cls) { this[_cls] = cls; this.simpleName = core.Symbol.new(cls.name); - this[_metadata$] = null; + this[_metadata] = null; this[_declarations] = null; let fn = this[_cls][dart.metadata]; - this[_metadata$] = fn == null ? dart.list([], mirrors.InstanceMirror) : core.List$(mirrors.InstanceMirror).from(dart.as(dart.dsend(dart.dcall(fn), 'map', dart.fn(i => new JsInstanceMirror._(i), JsInstanceMirror, [dart.dynamic])), core.Iterable)); + this[_metadata] = fn == null ? dart.list([], mirrors.InstanceMirror) : core.List$(mirrors.InstanceMirror).from(dart.as(dart.dsend(dart.dcall(fn), 'map', dart.fn(i => new JsInstanceMirror._(i), JsInstanceMirror, [dart.dynamic])), core.Iterable)); this[_declarations] = core.Map$(core.Symbol, mirrors.MethodMirror).new(); this[_declarations].set(this.simpleName, new JsMethodMirror._(this, this[_cls])); } diff --git a/pkg/dev_compiler/lib/runtime/dart/_runtime.js b/pkg/dev_compiler/lib/runtime/dart/_runtime.js index 97e39946de2d..2632bc822e98 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_runtime.js +++ b/pkg/dev_compiler/lib/runtime/dart/_runtime.js @@ -5,7 +5,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ 'dart/_js_helper', 'dart/async', 'dart/collection' -], function(exports, core, _interceptors, _js_helper, async$, collection) { +], function(exports, core, _interceptors, _js_helper, async, collection) { 'use strict'; function mixin(base, ...mixins) { class Mixin extends base { @@ -38,7 +38,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return clazz[_mixins]; } function getImplements(clazz) { - return clazz[implements$]; + return clazz[implements_]; } const _typeArguments = Symbol("typeArguments"); const _originalDeclaration = Symbol("originalDeclaration"); @@ -53,7 +53,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ throwInternalError('requires ' + length + ' or 0 type arguments'); } while (args.length < length) - args.push(dynamic); + args.push(dynamicR); let value = resultMap; for (let i = 0; i < length; i++) { let arg = args[i]; @@ -111,7 +111,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ if (f === void 0) f = obj[name]; f = f.bind(obj); let sig = getMethodType(obj, name); - assert(sig); + assert_(sig); tag(f, sig); return f; } @@ -185,7 +185,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ function registerExtension(jsType, dartExtType) { let extProto = dartExtType.prototype; let jsProto = jsType.prototype; - assert(jsProto[_extensionType] === void 0); + assert_(jsProto[_extensionType] === void 0); jsProto[_extensionType] = extProto; let dartObjProto = core.Object.prototype; while (extProto !== dartObjProto && extProto !== jsProto) { @@ -193,7 +193,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ extProto = extProto.__proto__; } let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get; - assert(originalSigFn); + assert_(originalSigFn); defineMemoizedGetter(jsType, _methodSig, originalSigFn); } function defineExtensionMembers(type, methodNames) { @@ -229,13 +229,13 @@ dart_library.library('dart/_runtime', null, /* Imports */[ derived.prototype.__proto__ = base.prototype; } function throwCastError(actual, type) { - throw$(new _js_helper.CastErrorImplementation(actual, type)); + throw_(new _js_helper.CastErrorImplementation(actual, type)); } function throwAssertionError() { - throw$(new core.AssertionError()); + throw_(new core.AssertionError()); } function throwNullValueError() { - throw$(new core.NoSuchMethodError(null, new core.Symbol(''), null, null, null)); + throw_(new core.NoSuchMethodError(null, new core.Symbol(''), null, null, null)); } const _jsIterator = Symbol("_jsIterator"); const _current = Symbol("_current"); @@ -243,7 +243,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ const SyncIterable_E = getGenericClass(_js_helper.SyncIterable)(E); return new SyncIterable_E(gen, args); } - function async(gen, T, ...args) { + function async_(gen, T, ...args) { let iter; function onValue(res) { if (res === void 0) res = null; @@ -255,12 +255,12 @@ dart_library.library('dart/_runtime', null, /* Imports */[ function next(ret) { if (ret.done) return ret.value; let future = ret.value; - if (!instanceOf(future, getGenericClass(async$.Future))) { - future = async$.Future.value(future); + if (!instanceOf(future, getGenericClass(async.Future))) { + future = async.Future.value(future); } return future.then(onValue, {onError: onError}); } - return getGenericClass(async$.Future)(T).new(function() { + return getGenericClass(async.Future)(T).new(function() { iter = gen(...args)[Symbol.iterator](); return onValue(); }); @@ -273,7 +273,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ this.isSuspendedAtYield = false; this.canceler = null; this.iterator = generator(this, ...args)[Symbol.iterator](); - this.controller = getGenericClass(async$.StreamController)(T).new({ + this.controller = getGenericClass(async.StreamController)(T).new({ onListen: (() => this.scheduleGenerator()).bind(this), onResume: (() => this.onResume()).bind(this), onCancel: (() => this.onCancel()).bind(this) @@ -289,7 +289,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return null; } if (this.canceler == null) { - this.canceler = async$.Completer.new(); + this.canceler = async.Completer.new(); this.scheduleGenerator(); } return this.canceler.future; @@ -305,7 +305,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return; } this.isScheduled = true; - async$.scheduleMicrotask((() => this.runBody()).bind(this)); + async.scheduleMicrotask((() => this.runBody()).bind(this)); } runBody(opt_awaitValue) { this.isScheduled = false; @@ -327,8 +327,8 @@ dart_library.library('dart/_runtime', null, /* Imports */[ if (this.isSuspendedAtYield || this.isAdding) return; this.isWaiting = true; let future = iter.value; - if (!instanceOf(future, getGenericClass(async$.Future))) { - future = async$.Future.value(future); + if (!instanceOf(future, getGenericClass(async.Future))) { + future = async.Future.value(future); } return future.then((x => this.runBody(x)).bind(this), { onError: ((e, s) => this.throwError(e, s)).bind(this) @@ -419,7 +419,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return true; } function throwNoSuchMethod(obj, name, pArgs, nArgs, extras) { - throw$(new core.NoSuchMethodError(obj, name, pArgs, nArgs, extras)); + throw_(new core.NoSuchMethodError(obj, name, pArgs, nArgs, extras)); } function throwNoSuchMethodFunc(obj, name, pArgs, opt_func) { if (obj === void 0) obj = opt_func; @@ -468,7 +468,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return value; } function _ignoreTypeFailure(actual, type) { - if (isSubtype(type, core.Iterable) && isSubtype(actual, core.Iterable) || isSubtype(type, async$.Future) && isSubtype(actual, async$.Future) || isSubtype(type, core.Map) && isSubtype(actual, core.Map) || isSubtype(type, core.Function) && isSubtype(actual, core.Function) || isSubtype(type, async$.Stream) && isSubtype(actual, async$.Stream) || isSubtype(type, async$.StreamSubscription) && isSubtype(actual, async$.StreamSubscription)) { + if (isSubtype(type, core.Iterable) && isSubtype(actual, core.Iterable) || isSubtype(type, async.Future) && isSubtype(actual, async.Future) || isSubtype(type, core.Map) && isSubtype(actual, core.Map) || isSubtype(type, core.Function) && isSubtype(actual, core.Function) || isSubtype(type, async.Stream) && isSubtype(actual, async.Stream) || isSubtype(type, async.StreamSubscription) && isSubtype(actual, async.StreamSubscription)) { console.warn('Ignoring cast fail from ' + typeName(actual) + ' to ' + typeName(type)); return true; } @@ -535,11 +535,11 @@ dart_library.library('dart/_runtime', null, /* Imports */[ } return map; } - function assert(condition) { + function assert_(condition) { if (!condition) throwAssertionError(); } const _stack = new WeakMap(); - function throw$(obj) { + function throw_(obj) { if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) { _stack.set(obj, new Error()); } @@ -580,7 +580,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return value; } const constants = new Map(); - function const$(obj) { + function const_(obj) { let objectKey = [realRuntimeType(obj)]; for (let name of getOwnNamesAndSymbols(obj)) { objectKey.push(name); @@ -642,7 +642,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ } let t; if (args.length == 0) { - t = definiteFunctionType(dynamic, Array(closure.length).fill(dynamic)); + t = definiteFunctionType(dynamicR, Array(closure.length).fill(dynamicR)); } else { t = definiteFunctionType.apply(null, args); } @@ -682,7 +682,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return obj.runtimeType; } function getFunctionType(obj) { - let args = Array(obj.length).fill(dynamic); + let args = Array(obj.length).fill(dynamicR); return definiteFunctionType(bottom, args); } function realRuntimeType(obj) { @@ -724,7 +724,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ tagComputed(value, getter); } const _mixins = Symbol("mixins"); - const implements$ = Symbol("implements"); + const implements_ = Symbol("implements"); const metadata = Symbol("metadata"); const TypeRep = class TypeRep extends LazyTagged(() => core.Type) { get name() { @@ -736,13 +736,13 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return "dynamic"; } }; - const dynamic = new Dynamic(); + const dynamicR = new Dynamic(); const Void = class Void extends TypeRep { toString() { return "void"; } }; - const void$ = new Void(); + const voidR = new Void(); const Bottom = class Bottom extends TypeRep { toString() { return "bottom"; @@ -829,7 +829,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ _canonize() { if (this.definite) return; function replace(a) { - return a == dynamic ? bottom : a; + return a == dynamicR ? bottom : a; } this.args = this.args.map(replace); if (this.optionals.length > 0) { @@ -935,7 +935,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ let ret1 = ft1.returnType; let ret2 = ft2.returnType; if (!isSubtype_(ret1, ret2)) { - if (ret2 != void$) { + if (ret2 != voidR) { return false; } } @@ -1008,7 +1008,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ return type == bottom; } function _isTop(type) { - return type == core.Object || type == dynamic; + return type == core.Object || type == dynamicR; } function isSubtype_(t1, t2) { t1 = canonicalType(t1); @@ -1030,10 +1030,10 @@ dart_library.library('dart/_runtime', null, /* Imports */[ } function isClassSubType(t1, t2) { t1 = canonicalType(t1); - assert(t2 == canonicalType(t2)); + assert_(t2 == canonicalType(t2)); if (t1 == t2) return true; if (t1 == core.Object) return false; - if (t1 == null) return t2 == core.Object || t2 == dynamic; + if (t1 == null) return t2 == core.Object || t2 == dynamicR; let raw1 = getGenericClass(t1); let raw2 = getGenericClass(t2); if (raw1 != null && raw1 == raw2) { @@ -1045,7 +1045,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ } else if (length == 0) { return false; } - assert(length == typeArguments2.length); + assert_(length == typeArguments2.length); for (let i = 0; i < length; ++i) { if (!isSubtype(typeArguments1[i], typeArguments2[i])) { return false; @@ -1086,7 +1086,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ let typeArgs = getGenericArgs(type); if (!typeArgs) return true; for (let t of typeArgs) { - if (t != core.Object && t != dynamic) return false; + if (t != core.Object && t != dynamicR) return false; } return true; } @@ -1161,7 +1161,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ function copyProperties(to, from) { return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); } - function export$(to, from, show, hide) { + function export_(to, from, show, hide) { if (show == void 0 || show.length == 0) { show = getOwnNamesAndSymbols(from); } @@ -1174,9 +1174,9 @@ dart_library.library('dart/_runtime', null, /* Imports */[ const defineLazyClass = defineLazy; const defineLazyProperties = defineLazy; const defineLazyClassGeneric = defineLazyProperty; - const as = cast; - const is = instanceOf; - const global = typeof window == "undefined" ? global : window; + const as_ = cast; + const is_ = instanceOf; + const global_ = typeof window == "undefined" ? global : window; const JsSymbol = Symbol; // Exports: exports.mixin = mixin; @@ -1205,7 +1205,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ exports.throwAssertionError = throwAssertionError; exports.throwNullValueError = throwNullValueError; exports.syncStar = syncStar; - exports.async = async; + exports.async = async_; exports.asyncStar = asyncStar; exports.dload = dload; exports.dput = dput; @@ -1227,15 +1227,15 @@ dart_library.library('dart/_runtime', null, /* Imports */[ exports.equals = equals; exports.notNull = notNull; exports.map = map; - exports.assert = assert; - exports.throw = throw$; + exports.assert = assert_; + exports.throw = throw_; exports.getError = getError; exports.stackPrint = stackPrint; exports.stackTrace = stackTrace; exports.nullSafe = nullSafe; exports.multiKeyPutIfAbsent = multiKeyPutIfAbsent; exports.constants = constants; - exports.const = const$; + exports.const = const_; exports.hashCode = hashCode; exports.toString = toString; exports.noSuchMethod = noSuchMethod; @@ -1250,13 +1250,13 @@ dart_library.library('dart/_runtime', null, /* Imports */[ exports.tag = tag; exports.tagComputed = tagComputed; exports.tagMemoized = tagMemoized; - exports.implements = implements$; + exports.implements = implements_; exports.metadata = metadata; exports.TypeRep = TypeRep; exports.Dynamic = Dynamic; - exports.dynamic = dynamic; + exports.dynamic = dynamicR; exports.Void = Void; - exports.void = void$; + exports.void = voidR; exports.Bottom = Bottom; exports.bottom = bottom; exports.JSObject = JSObject; @@ -1292,12 +1292,12 @@ dart_library.library('dart/_runtime', null, /* Imports */[ exports.defineMemoizedGetter = defineMemoizedGetter; exports.copyTheseProperties = copyTheseProperties; exports.copyProperties = copyProperties; - exports.export = export$; + exports.export = export_; exports.defineLazyClass = defineLazyClass; exports.defineLazyProperties = defineLazyProperties; exports.defineLazyClassGeneric = defineLazyClassGeneric; - exports.as = as; - exports.is = is; - exports.global = global; + exports.as = as_; + exports.is = is_; + exports.global = global_; exports.JsSymbol = JsSymbol; }); diff --git a/pkg/dev_compiler/lib/runtime/dart/html.js b/pkg/dev_compiler/lib/runtime/dart/html.js index db449c15b49f..1495e6ebeadd 100644 --- a/pkg/dev_compiler/lib/runtime/dart/html.js +++ b/pkg/dev_compiler/lib/runtime/dart/html.js @@ -12427,7 +12427,7 @@ dart_library.library('dart/html', null, /* Imports */[ Platform.supportsSimd = false; dart.defineLazyProperties(Platform, { get supportsTypedData() { - return !!window.ArrayBuffer; + return !!dart.global.ArrayBuffer; } }); function _wrapZone(callback) { @@ -12667,10 +12667,12 @@ dart_library.library('dart/html', null, /* Imports */[ sanitizeNode: [dart.void, [Node, Node]] }) }); - dart.copyProperties(exports, { + dart.defineLazyProperties(exports, { get window() { - return dart.as(wrap_jso(window), Window); - }, + return dart.as(wrap_jso(dart.global), Window); + } + }); + dart.copyProperties(exports, { get document() { return dart.as(wrap_jso(document), HtmlDocument); } diff --git a/pkg/dev_compiler/lib/src/codegen/js_codegen.dart b/pkg/dev_compiler/lib/src/codegen/js_codegen.dart index 4f8fb3772997..d35786f5ea79 100644 --- a/pkg/dev_compiler/lib/src/codegen/js_codegen.dart +++ b/pkg/dev_compiler/lib/src/codegen/js_codegen.dart @@ -25,7 +25,8 @@ import '../js/js_ast.dart' as JS; import '../js/js_ast.dart' show js; import '../closure/closure_annotator.dart' show ClosureAnnotator; -import '../compiler.dart' show AbstractCompiler; +import '../compiler.dart' + show AbstractCompiler, corelibOrder, getCorelibModuleName; import '../info.dart'; import '../options.dart' show CodegenOptions; import '../utils.dart'; @@ -81,7 +82,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { /// Imported libraries, and the temporaries used to refer to them. final _imports = new Map(); - final _exports = new Set(); + final _exports = {}; final _properties = []; final _privateNames = new HashMap(); final _moduleItems = []; @@ -184,6 +185,14 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { var items = []; if (!_isDartRuntime) { + if (currentLibrary.source.isInSystemLibrary) { + // Force the import order of runtime libs. + // TODO(ochafik): Reduce this to a minimum. + for (var lib in corelibOrder.reversed) { + // TODO(ochafik): Use uris instead in corelibOrder. + moduleBuilder.addImport(getCorelibModuleName(lib), null); + } + } moduleBuilder.addImport('dart/_runtime', _runtimeLibVar); var dartxImport = @@ -264,7 +273,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { args.add(new JS.ArrayInitializer(hiddenNames)); } - // When we compile _runtime.js, we need to source export_ from _utils.js: _moduleItems.add(js.statement('dart.export(#);', [args])); } @@ -538,7 +546,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { var name = type.name; var genericName = '$name\$'; var typeParams = _typeFormalsOf(type).map((p) => p.name); - if (isPublic(name)) _exports.add(genericName); + if (isPublic(name)) _addExport(genericName); return js.statement('const # = dart.generic(function(#) { #; return #; });', [genericName, typeParams, body, name]); } @@ -1302,7 +1310,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { var body = []; _flushLibraryProperties(body); - var name = _getJSExportName(node.element) ?? node.name.name; + var name = node.name.name; var fn = _visit(node.functionExpression); @@ -1318,7 +1326,9 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { .toStatement()); } - if (isPublic(name)) _addExport(name); + if (isPublic(name)) { + _addExport(name, _getJSExportName(node.element) ?? name); + } return _statement(body); } @@ -1751,7 +1761,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { JS.Expression _emitTopLevelName(Element e, {String suffix: ''}) { var libName = _libraryName(e.library); - var nameExpr = _propertyName((_getJSExportName(e) ?? e.name) + suffix); // Always qualify: // * mutable top-level fields @@ -1760,6 +1769,12 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { !e.isConst && !_isFinalJSDecl(e.computeNode()); bool fromAnotherLibrary = e.library != currentLibrary; + var nameExpr; + if (fromAnotherLibrary) { + nameExpr = _propertyName((_getJSExportName(e) ?? e.name) + suffix); + } else { + nameExpr = _propertyName(e.name + suffix); + } if (mutableTopLevel || fromAnotherLibrary) { return new JS.PropertyAccess(libName, nameExpr); } @@ -2137,8 +2152,26 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { } } - _addExport(String name) { - if (!_exports.add(name)) throw 'Duplicate top level name found: $name'; + /// Emits static fields. + /// + /// Instance fields are emitted in [_initializeFields]. + /// + /// These are generally treated the same as top-level fields, see + /// [visitTopLevelVariableDeclaration]. + @override + visitFieldDeclaration(FieldDeclaration node) { + if (!node.isStatic) return; + + for (var f in node.fields.variables) { + _loader.loadDeclaration(f, f.element); + } + } + + _addExport(String name, [String exportName]) { + if (_exports.containsKey(name)) { + throw 'Duplicate top level name found: $name'; + } + _exports[name] = exportName ?? name; } @override @@ -2247,12 +2280,18 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator { var isJSTopLevel = field.isFinal && _isFinalJSDecl(field); if (isJSTopLevel) eagerInit = true; - var fieldName = _getJSExportName(element) ?? field.name.name; - if (field.isConst && eagerInit || isJSTopLevel) { + var fieldName = field.name.name; + var exportName = fieldName; + if (element is TopLevelVariableElement) { + exportName = _getJSExportName(element) ?? fieldName; + } + if ((field.isConst && eagerInit && element is TopLevelVariableElement) || + isJSTopLevel) { // constant fields don't change, so we can generate them as `let` // but add them to the module's exports. However, make sure we generate // anything they depend on first. - if (isPublic(fieldName)) _addExport(fieldName); + + if (isPublic(fieldName)) _addExport(fieldName, exportName); var declKeyword = field.isConst || field.isFinal ? 'const' : 'let'; return annotateVariable( js.statement( diff --git a/pkg/dev_compiler/lib/src/codegen/module_builder.dart b/pkg/dev_compiler/lib/src/codegen/module_builder.dart index 42d8367ae0aa..9128526a7dac 100644 --- a/pkg/dev_compiler/lib/src/codegen/module_builder.dart +++ b/pkg/dev_compiler/lib/src/codegen/module_builder.dart @@ -12,8 +12,8 @@ import '../options.dart' show ModuleFormat; /// Helper that builds JS modules in a given [ModuleFormat]. abstract class ModuleBuilder { - final List _exports = []; - final List<_ModuleImport> _imports = <_ModuleImport>[]; + final _exports = {}; + final _imports = <_ModuleImport>[]; ModuleBuilder._(); @@ -30,17 +30,21 @@ abstract class ModuleBuilder { return new LegacyModuleBuilder(); case ModuleFormat.es6: return new ES6ModuleBuilder(); + case ModuleFormat.node: + return new NodeModuleBuilder(); } } /// Adds [name] to the list of names to be exported from the module. - void addExport(String name) { - _exports.add(name); + void addExport(String name, String exportName) { + _exports[name] = exportName; } /// Adds an import from a module named [name] and locally aliased as [libVar]. - /// When [isLazy] is true, the import should be lazy (i.e. there is some + /// When [isLazy] is `true`, the import should be lazy (i.e. there is some /// cyclic dependency of imports). + /// When [libVar] is `null`, the import is there just to force the import + /// order. void addImport(String name, JS.Identifier libVar, {bool isLazy: false}) { _imports.add(new _ModuleImport(name, libVar, isLazy)); } @@ -65,7 +69,7 @@ class LegacyModuleBuilder extends ModuleBuilder { LegacyModuleBuilder() : super._(); JS.Program build(String jsPath, String jsModuleValue, - JS.Identifier exportsVar, List moduleItems) { + JS.Identifier exportsVar, Iterable moduleItems) { // TODO(jmesserly): it would be great to run the renamer on the body, // then figure out if we really need each of these parameters. // See ES6 modules: https://github.com/dart-lang/dev_compiler/issues/34 @@ -77,6 +81,8 @@ class LegacyModuleBuilder extends ModuleBuilder { var moduleStatements = []; for (var i in _imports) { + // No need to force the import order for the legacy library mechanism. + if (i.libVar == null) continue; (i.isLazy ? lazyImports : imports).add(js.string(i.name, "'")); (i.isLazy ? lazyParams : params).add(i.libVar); } @@ -87,10 +93,10 @@ class LegacyModuleBuilder extends ModuleBuilder { if (_exports.isNotEmpty) { moduleStatements.add(js.comment('Exports:')); // TODO(jmesserly): make these immutable in JS? - for (var name in _exports) { + _exports.forEach((name, exportName) { moduleStatements - .add(js.statement('#.# = #;', [exportsVar, name, name])); - } + .add(js.statement('#.# = #;', [exportsVar, exportName, name])); + }); } var module = @@ -123,7 +129,6 @@ class ES6ModuleBuilder extends ModuleBuilder { JS.Program build(String jsPath, String jsModuleValue, JS.Identifier exportsVar, Iterable moduleItems) { var moduleStatements = [ - // Lazy declarations may reference exports. js.statement("const # = {};", [exportsVar]) ]; @@ -133,8 +138,13 @@ class ES6ModuleBuilder extends ModuleBuilder { for (var i in _imports) { var moduleName = js.string(_relativeModuleName(i.name, from: jsPath)); // TODO(ochafik): laziness, late binding, etc, to support Closure... - moduleStatements.add( - new JS.ImportDeclaration(defaultBinding: i.libVar, from: moduleName)); + if (i.libVar == null) { + moduleStatements + .add(new JS.ImportDeclaration(namedImports: [], from: moduleName)); + } else { + moduleStatements.add(new JS.ImportDeclaration( + defaultBinding: i.libVar, from: moduleName)); + } } moduleStatements.addAll(_flattenBlocks(moduleItems)); @@ -142,14 +152,46 @@ class ES6ModuleBuilder extends ModuleBuilder { if (_exports.isNotEmpty) { moduleStatements.add(js.comment('Exports:')); // TODO(jmesserly): make these immutable in JS? - for (var name in _exports) { + _exports.forEach((name, exportName) { moduleStatements - .add(js.statement('#.# = #;', [exportsVar, name, name])); - } + .add(js.statement('#.# = #;', [exportsVar, exportName, name])); + }); moduleStatements .add(new JS.ExportDeclaration(exportsVar, isDefault: true)); } - // TODO(ochafik): What to do of jsModuleValue? + // TODO(ochafik): What to do with jsModuleValue? + return new JS.Program(moduleStatements); + } +} + +/// Generates node modules. +class NodeModuleBuilder extends ModuleBuilder { + NodeModuleBuilder() : super._(); + + JS.Program build(String jsPath, String jsModuleValue, + JS.Identifier exportsVar, Iterable moduleItems) { + var moduleStatements = [js.statement("'use strict';"),]; + + for (var i in _imports) { + if (i.libVar == null) { + moduleStatements.add(js.statement('require(#);', [js.string(i.name)])); + } else { + moduleStatements.add( + js.statement('let # = require(#);', [i.libVar, js.string(i.name)])); + } + } + + moduleStatements.addAll(_flattenBlocks(moduleItems)); + + if (_exports.isNotEmpty) { + moduleStatements.add(js.comment('Exports:')); + _exports.forEach((name, exportName) { + moduleStatements + .add(js.statement('#.# = #;', [exportsVar, exportName, name])); + }); + } + // TODO(ochafik): What to do with jsModuleValue? + // (something like `let exports = jsModuleValue;`?) return new JS.Program(moduleStatements); } } diff --git a/pkg/dev_compiler/lib/src/compiler.dart b/pkg/dev_compiler/lib/src/compiler.dart index 61c568591624..921b857ae5ca 100644 --- a/pkg/dev_compiler/lib/src/compiler.dart +++ b/pkg/dev_compiler/lib/src/compiler.dart @@ -513,13 +513,27 @@ const corelibOrder = const [ 'dart._js_mirrors', 'dart.js', 'dart._metadata', - 'dart.dom.html_common', 'dart.dom.html', + 'dart.dom.html_common', 'dart._debugger' // _foreign_helper is not included, as it only defines the JS builtin that // the compiler handles at compile time. ]; +/// Returns the JS module name corresponding to a core library name (must be +/// from the [corelibOrder] list). +String getCorelibModuleName(String lib) { + assert(corelibOrder.contains(lib)); + switch (lib) { + case 'dart.dom.html_common': + return 'dart/html_common'; + case 'dart.dom.html': + return 'dart/html'; + default: + return lib.replaceAll('dart.', 'dart/'); + } +} + /// Runtime files added to all applications when running the compiler in the /// command line. final defaultRuntimeFiles = () { diff --git a/pkg/dev_compiler/lib/src/options.dart b/pkg/dev_compiler/lib/src/options.dart index d5abf8d2023e..2d132a48b46e 100644 --- a/pkg/dev_compiler/lib/src/options.dart +++ b/pkg/dev_compiler/lib/src/options.dart @@ -58,7 +58,7 @@ class SourceResolverOptions { this.useImplicitHtml: false}); } -enum ModuleFormat { es6, legacy } +enum ModuleFormat { es6, legacy, node } ModuleFormat parseModuleFormat(String s) => parseEnum(s, ModuleFormat.values); // TODO(jmesserly): refactor all codegen options here. @@ -315,7 +315,9 @@ final ArgParser argParser = new ArgParser() allowedHelp: { getEnumName(ModuleFormat.es6): 'es6 modules', getEnumName(ModuleFormat.legacy): - 'a custom format used by dartdevc, similar to AMD' + 'a custom format used by dartdevc, similar to AMD', + getEnumName(ModuleFormat.node): + 'node.js modules (https://nodejs.org/api/modules.html)' }, defaultsTo: getEnumName(ModuleFormat.legacy)) diff --git a/pkg/dev_compiler/test/browser/runtime_tests.js b/pkg/dev_compiler/test/browser/runtime_tests.js index 8e7bd4157578..938e76253fc9 100644 --- a/pkg/dev_compiler/test/browser/runtime_tests.js +++ b/pkg/dev_compiler/test/browser/runtime_tests.js @@ -22,7 +22,7 @@ suite('generic', () => { new RegExp('NoSuchMethodError.*\nReceiver: 42', 'm'), 'Calls with non-function receiver should throw a NoSuchMethodError' + ' with correct target'); - + // TODO(jmesserly): we should show the name "print" in there somewhere. assert.throws(() => dart.dcall(core.print, 1, 2, 3), new RegExp('NoSuchMethodError.*\n' + diff --git a/pkg/dev_compiler/test/codegen/expect/collection/equality.txt b/pkg/dev_compiler/test/codegen/expect/collection/equality.txt index e8d1caa801e5..433fdd0c1991 100644 --- a/pkg/dev_compiler/test/codegen/expect/collection/equality.txt +++ b/pkg/dev_compiler/test/codegen/expect/collection/equality.txt @@ -1 +1,10 @@ // Messages from compiling equality.dart +severe: [AnalyzerMessage] The redirected constructor '() → DefaultEquality' has incompatible parameters with '() → Equality' (package:collection/equality.dart, line 18, col 30) +severe: [STATIC_TYPE_ERROR] Type check failed: const DefaultEquality() (DefaultEquality) is not of type Equality because const DefaultEquality() cannot be typed as Equality (package:collection/equality.dart, line 75, col 31) +severe: [STATIC_TYPE_ERROR] Type check failed: const DefaultEquality() (DefaultEquality) is not of type Equality because const DefaultEquality() cannot be typed as Equality (package:collection/equality.dart, line 120, col 53) +severe: [STATIC_TYPE_ERROR] Type check failed: const DefaultEquality() (DefaultEquality) is not of type Equality because const DefaultEquality() cannot be typed as Equality (package:collection/equality.dart, line 205, col 38) +severe: [STATIC_TYPE_ERROR] Type check failed: const DefaultEquality() (DefaultEquality) is not of type Equality because const DefaultEquality() cannot be typed as Equality (package:collection/equality.dart, line 223, col 38) +severe: [STATIC_TYPE_ERROR] Type check failed: const DefaultEquality() (DefaultEquality) is not of type Equality because const DefaultEquality() cannot be typed as Equality (package:collection/equality.dart, line 263, col 42) +severe: [STATIC_TYPE_ERROR] Type check failed: const DefaultEquality() (DefaultEquality) is not of type Equality because const DefaultEquality() cannot be typed as Equality (package:collection/equality.dart, line 264, col 44) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (package:collection/equality.dart, line 87, col 36) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (package:collection/equality.dart, line 87, col 49) diff --git a/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.js b/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.js index 03744bc169ca..3e1e9ab14bfe 100644 --- a/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.js +++ b/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.js @@ -32,12 +32,9 @@ dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ return pair == null ? null : pair.last; } set(key, value) { - (() => { - dart.as(key, K); - dart.as(value, V); - if (!dart.notNull(this[_isValidKey](key))) return; - this[_base].set(dart.as(dart.dcall(this[_canonicalize], key), C), new (utils.Pair$(K, V))(key, value)); - })(); + dart.as(key, K); + dart.as(value, V); + this[_base].set(dart.as(dart.dcall(this[_canonicalize], key), C), new (utils.Pair$(K, V))(key, value)); return value; } addAll(other) { @@ -65,7 +62,7 @@ dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ return this[_base].isNotEmpty; } get keys() { - return this[_base].values[dartx.map](dart.fn(pair => pair.first, K, [utils.Pair$(K, V)])); + return dart.as(this[_base].values[dartx.map](dart.fn(pair => pair.first, K, [utils.Pair$(K, V)])), core.Iterable$(K)); } get length() { return this[_base].length; @@ -81,7 +78,7 @@ dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ return pair == null ? null : pair.last; } get values() { - return this[_base].values[dartx.map](dart.fn(pair => pair.last, V, [utils.Pair$(K, V)])); + return dart.as(this[_base].values[dartx.map](dart.fn(pair => pair.last, V, [utils.Pair$(K, V)])), core.Iterable$(V)); } toString() { return collection.Maps.mapToString(this); diff --git a/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.txt b/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.txt index 59bff0e185c1..b292e19bd8d1 100644 --- a/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.txt +++ b/pkg/dev_compiler/test/codegen/expect/collection/src/canonicalized_map.txt @@ -1,3 +1,5 @@ // Messages from compiling canonicalized_map.dart -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to C (package:collection/src/canonicalized_map.dart, line 61, col 11) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to C (package:collection/src/canonicalized_map.dart, line 93, col 30) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to C (package:collection/src/canonicalized_map.dart, line 67, col 11) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to Iterable (package:collection/src/canonicalized_map.dart, line 94, col 27) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to C (package:collection/src/canonicalized_map.dart, line 99, col 30) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to Iterable (package:collection/src/canonicalized_map.dart, line 109, col 29) diff --git a/pkg/dev_compiler/test/codegen/expect/collection/src/queue_list.txt b/pkg/dev_compiler/test/codegen/expect/collection/src/queue_list.txt index 02d24e699ebf..ab8828702105 100644 --- a/pkg/dev_compiler/test/codegen/expect/collection/src/queue_list.txt +++ b/pkg/dev_compiler/test/codegen/expect/collection/src/queue_list.txt @@ -1,10 +1,8 @@ // Messages from compiling queue_list.dart -severe: [INVALID_METHOD_OVERRIDE] Mixin introduces an invalid override. The type of ListMixin.expand (((E) → Iterable) → Iterable) is not a subtype of Iterable.expand (((E) → Iterable) → Iterable). (package:collection/src/queue_list.dart, line 12, col 40) -severe: [INVALID_METHOD_OVERRIDE] Mixin introduces an invalid override. The type of ListMixin.map (((E) → dynamic) → Iterable) is not a subtype of Iterable.map (((E) → T) → Iterable). (package:collection/src/queue_list.dart, line 12, col 40) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to List (package:collection/src/queue_list.dart, line 38, col 25) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 39, col 40) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to List (package:collection/src/queue_list.dart, line 55, col 19) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 61, col 52) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to List (package:collection/src/queue_list.dart, line 44, col 25) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 45, col 40) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to List (package:collection/src/queue_list.dart, line 61, col 19) warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 67, col 52) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 71, col 52) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 72, col 40) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 73, col 52) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 77, col 52) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (package:collection/src/queue_list.dart, line 78, col 40) diff --git a/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.js b/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.js new file mode 100644 index 000000000000..50d74201c58d --- /dev/null +++ b/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.js @@ -0,0 +1,229 @@ +dart_library.library('collection/src/unmodifiable_wrappers', null, /* Imports */[ + 'dart/_runtime', + 'dart/collection', + 'dart/core' +], /* Lazy imports */[ + 'collection/wrappers' +], function(exports, dart, collection, core, wrappers) { + 'use strict'; + let dartx = dart.dartx; + dart.export(exports, collection, ['UnmodifiableListView', 'UnmodifiableMapView'], []); + const NonGrowableListMixin$ = dart.generic(function(E) { + class NonGrowableListMixin extends core.Object { + static _throw() { + dart.throw(new core.UnsupportedError("Cannot change the length of a fixed-length list")); + } + set length(newLength) { + return NonGrowableListMixin$()._throw(); + } + add(value) { + dart.as(value, E); + return dart.as(NonGrowableListMixin$()._throw(), core.bool); + } + addAll(iterable) { + dart.as(iterable, core.Iterable$(E)); + return NonGrowableListMixin$()._throw(); + } + insert(index, element) { + dart.as(element, E); + return NonGrowableListMixin$()._throw(); + } + insertAll(index, iterable) { + dart.as(iterable, core.Iterable$(E)); + return NonGrowableListMixin$()._throw(); + } + remove(value) { + return dart.as(NonGrowableListMixin$()._throw(), core.bool); + } + removeAt(index) { + return dart.as(NonGrowableListMixin$()._throw(), E); + } + removeLast() { + return dart.as(NonGrowableListMixin$()._throw(), E); + } + removeWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return NonGrowableListMixin$()._throw(); + } + retainWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return NonGrowableListMixin$()._throw(); + } + removeRange(start, end) { + return NonGrowableListMixin$()._throw(); + } + replaceRange(start, end, iterable) { + dart.as(iterable, core.Iterable$(E)); + return NonGrowableListMixin$()._throw(); + } + clear() { + return NonGrowableListMixin$()._throw(); + } + } + NonGrowableListMixin[dart.implements] = () => [core.List$(E)]; + dart.setSignature(NonGrowableListMixin, { + methods: () => ({ + add: [core.bool, [E]], + addAll: [dart.void, [core.Iterable$(E)]], + insert: [dart.void, [core.int, E]], + insertAll: [dart.void, [core.int, core.Iterable$(E)]], + remove: [core.bool, [core.Object]], + removeAt: [E, [core.int]], + removeLast: [E, []], + removeWhere: [dart.void, [dart.functionType(core.bool, [E])]], + retainWhere: [dart.void, [dart.functionType(core.bool, [E])]], + removeRange: [dart.void, [core.int, core.int]], + replaceRange: [dart.void, [core.int, core.int, core.Iterable$(E)]], + clear: [dart.void, []] + }), + statics: () => ({_throw: [dart.dynamic, []]}), + names: ['_throw'] + }); + dart.defineExtensionMembers(NonGrowableListMixin, [ + 'add', + 'addAll', + 'insert', + 'insertAll', + 'remove', + 'removeAt', + 'removeLast', + 'removeWhere', + 'retainWhere', + 'removeRange', + 'replaceRange', + 'clear', + 'length' + ]); + return NonGrowableListMixin; + }); + let NonGrowableListMixin = NonGrowableListMixin$(); + const NonGrowableListView$ = dart.generic(function(E) { + class NonGrowableListView extends dart.mixin(wrappers.DelegatingList$(E), NonGrowableListMixin$(E)) { + NonGrowableListView(listBase) { + super.DelegatingList(listBase); + } + } + dart.setSignature(NonGrowableListView, { + constructors: () => ({NonGrowableListView: [exports.NonGrowableListView$(E), [core.List$(E)]]}) + }); + return NonGrowableListView; + }); + dart.defineLazyClassGeneric(exports, 'NonGrowableListView', {get: NonGrowableListView$}); + const _throw = Symbol('_throw'); + const UnmodifiableSetMixin$ = dart.generic(function(E) { + class UnmodifiableSetMixin extends core.Object { + [_throw]() { + dart.throw(new core.UnsupportedError("Cannot modify an unmodifiable Set")); + } + add(value) { + dart.as(value, E); + return dart.as(this[_throw](), core.bool); + } + addAll(elements) { + dart.as(elements, core.Iterable$(E)); + return this[_throw](); + } + remove(value) { + return dart.as(this[_throw](), core.bool); + } + removeAll(elements) { + return this[_throw](); + } + retainAll(elements) { + return this[_throw](); + } + removeWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_throw](); + } + retainWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_throw](); + } + clear() { + return this[_throw](); + } + } + UnmodifiableSetMixin[dart.implements] = () => [core.Set$(E)]; + dart.setSignature(UnmodifiableSetMixin, { + methods: () => ({ + [_throw]: [dart.dynamic, []], + add: [core.bool, [E]], + addAll: [dart.void, [core.Iterable$(E)]], + remove: [core.bool, [core.Object]], + removeAll: [dart.void, [core.Iterable]], + retainAll: [dart.void, [core.Iterable]], + removeWhere: [dart.void, [dart.functionType(core.bool, [E])]], + retainWhere: [dart.void, [dart.functionType(core.bool, [E])]], + clear: [dart.void, []] + }) + }); + return UnmodifiableSetMixin; + }); + let UnmodifiableSetMixin = UnmodifiableSetMixin$(); + const UnmodifiableSetView$ = dart.generic(function(E) { + class UnmodifiableSetView extends dart.mixin(wrappers.DelegatingSet$(E), UnmodifiableSetMixin$(E)) { + UnmodifiableSetView(setBase) { + super.DelegatingSet(setBase); + } + } + dart.setSignature(UnmodifiableSetView, { + constructors: () => ({UnmodifiableSetView: [exports.UnmodifiableSetView$(E), [core.Set$(E)]]}) + }); + return UnmodifiableSetView; + }); + dart.defineLazyClassGeneric(exports, 'UnmodifiableSetView', {get: UnmodifiableSetView$}); + const UnmodifiableMapMixin$ = dart.generic(function(K, V) { + class UnmodifiableMapMixin extends core.Object { + static _throw() { + dart.throw(new core.UnsupportedError("Cannot modify an unmodifiable Map")); + } + set(key, value) { + (() => { + dart.as(key, K); + dart.as(value, V); + return UnmodifiableMapMixin$()._throw(); + })(); + return value; + } + putIfAbsent(key, ifAbsent) { + dart.as(key, K); + dart.as(ifAbsent, dart.functionType(V, [])); + return dart.as(UnmodifiableMapMixin$()._throw(), V); + } + addAll(other) { + dart.as(other, core.Map$(K, V)); + return UnmodifiableMapMixin$()._throw(); + } + remove(key) { + return dart.as(UnmodifiableMapMixin$()._throw(), V); + } + clear() { + return UnmodifiableMapMixin$()._throw(); + } + } + UnmodifiableMapMixin[dart.implements] = () => [core.Map$(K, V)]; + dart.setSignature(UnmodifiableMapMixin, { + methods: () => ({ + set: [dart.void, [K, V]], + putIfAbsent: [V, [K, dart.functionType(V, [])]], + addAll: [dart.void, [core.Map$(K, V)]], + remove: [V, [core.Object]], + clear: [dart.void, []] + }), + statics: () => ({_throw: [dart.dynamic, []]}), + names: ['_throw'] + }); + return UnmodifiableMapMixin; + }); + let UnmodifiableMapMixin = UnmodifiableMapMixin$(); + // Exports: + exports.NonGrowableListMixin$ = NonGrowableListMixin$; + exports.NonGrowableListMixin = NonGrowableListMixin; + exports.NonGrowableListView$ = NonGrowableListView$; + exports.UnmodifiableSetMixin$ = UnmodifiableSetMixin$; + exports.UnmodifiableSetMixin = UnmodifiableSetMixin; + exports.UnmodifiableSetView$ = UnmodifiableSetView$; + exports.UnmodifiableMapMixin$ = UnmodifiableMapMixin$; + exports.UnmodifiableMapMixin = UnmodifiableMapMixin; +}); diff --git a/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.txt b/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.txt index 7d176160fa77..b544973d0ee4 100644 --- a/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.txt +++ b/pkg/dev_compiler/test/codegen/expect/collection/src/unmodifiable_wrappers.txt @@ -1,7 +1,5 @@ // Messages from compiling unmodifiable_wrappers.dart -severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/src/unmodifiable_wrappers.dart, line 20, col 7) -severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/src/unmodifiable_wrappers.dart, line 93, col 7) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (package:collection/src/unmodifiable_wrappers.dart, line 59, col 28) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (package:collection/src/unmodifiable_wrappers.dart, line 63, col 21) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to V (package:collection/src/unmodifiable_wrappers.dart, line 151, col 41) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to V (package:collection/src/unmodifiable_wrappers.dart, line 159, col 27) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (package:collection/src/unmodifiable_wrappers.dart, line 88, col 28) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (package:collection/src/unmodifiable_wrappers.dart, line 94, col 21) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to V (package:collection/src/unmodifiable_wrappers.dart, line 218, col 41) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to V (package:collection/src/unmodifiable_wrappers.dart, line 230, col 27) diff --git a/pkg/dev_compiler/test/codegen/expect/collection/wrappers.js b/pkg/dev_compiler/test/codegen/expect/collection/wrappers.js new file mode 100644 index 000000000000..d0f23a4eda12 --- /dev/null +++ b/pkg/dev_compiler/test/codegen/expect/collection/wrappers.js @@ -0,0 +1,809 @@ +dart_library.library('collection/wrappers', null, /* Imports */[ + 'dart/_runtime', + 'collection/src/canonicalized_map', + 'dart/core', + 'dart/math', + 'dart/collection' +], /* Lazy imports */[ + 'collection/src/unmodifiable_wrappers' +], function(exports, dart, canonicalized_map, core, math, collection, unmodifiable_wrappers) { + 'use strict'; + let dartx = dart.dartx; + dart.export(exports, canonicalized_map); + dart.export(exports, unmodifiable_wrappers); + const _base = Symbol('_base'); + const _DelegatingIterableBase$ = dart.generic(function(E) { + class _DelegatingIterableBase extends core.Object { + _DelegatingIterableBase() { + } + any(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_base][dartx.any](test); + } + contains(element) { + return this[_base][dartx.contains](element); + } + elementAt(index) { + return this[_base][dartx.elementAt](index); + } + every(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_base][dartx.every](test); + } + expand(f) { + dart.as(f, dart.functionType(core.Iterable, [E])); + return this[_base][dartx.expand](f); + } + get first() { + return this[_base][dartx.first]; + } + firstWhere(test, opts) { + dart.as(test, dart.functionType(core.bool, [E])); + let orElse = opts && 'orElse' in opts ? opts.orElse : null; + dart.as(orElse, dart.functionType(E, [])); + return this[_base][dartx.firstWhere](test, {orElse: orElse}); + } + fold(initialValue, combine) { + dart.as(combine, dart.functionType(dart.dynamic, [dart.dynamic, E])); + return this[_base][dartx.fold](initialValue, combine); + } + forEach(f) { + dart.as(f, dart.functionType(dart.void, [E])); + return this[_base][dartx.forEach](f); + } + get isEmpty() { + return this[_base][dartx.isEmpty]; + } + get isNotEmpty() { + return this[_base][dartx.isNotEmpty]; + } + get iterator() { + return this[_base][dartx.iterator]; + } + [Symbol.iterator]() { + return new dart.JsIterator(this.iterator); + } + join(separator) { + if (separator === void 0) separator = ""; + return this[_base][dartx.join](separator); + } + get last() { + return this[_base][dartx.last]; + } + lastWhere(test, opts) { + dart.as(test, dart.functionType(core.bool, [E])); + let orElse = opts && 'orElse' in opts ? opts.orElse : null; + dart.as(orElse, dart.functionType(E, [])); + return this[_base][dartx.lastWhere](test, {orElse: orElse}); + } + get length() { + return this[_base][dartx.length]; + } + map(f) { + dart.as(f, dart.functionType(dart.dynamic, [E])); + return this[_base][dartx.map](f); + } + reduce(combine) { + dart.as(combine, dart.functionType(E, [E, E])); + return this[_base][dartx.reduce](combine); + } + get single() { + return this[_base][dartx.single]; + } + singleWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_base][dartx.singleWhere](test); + } + skip(n) { + return this[_base][dartx.skip](n); + } + skipWhile(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_base][dartx.skipWhile](test); + } + take(n) { + return this[_base][dartx.take](n); + } + takeWhile(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_base][dartx.takeWhile](test); + } + toList(opts) { + let growable = opts && 'growable' in opts ? opts.growable : true; + return this[_base][dartx.toList]({growable: growable}); + } + toSet() { + return this[_base][dartx.toSet](); + } + where(test) { + dart.as(test, dart.functionType(core.bool, [E])); + return this[_base][dartx.where](test); + } + toString() { + return dart.toString(this[_base]); + } + } + _DelegatingIterableBase[dart.implements] = () => [core.Iterable$(E)]; + dart.setSignature(_DelegatingIterableBase, { + constructors: () => ({_DelegatingIterableBase: [_DelegatingIterableBase$(E), []]}), + methods: () => ({ + any: [core.bool, [dart.functionType(core.bool, [E])]], + contains: [core.bool, [core.Object]], + elementAt: [E, [core.int]], + every: [core.bool, [dart.functionType(core.bool, [E])]], + expand: [core.Iterable, [dart.functionType(core.Iterable, [E])]], + firstWhere: [E, [dart.functionType(core.bool, [E])], {orElse: dart.functionType(E, [])}], + fold: [dart.dynamic, [dart.dynamic, dart.functionType(dart.dynamic, [dart.dynamic, E])]], + forEach: [dart.void, [dart.functionType(dart.void, [E])]], + join: [core.String, [], [core.String]], + lastWhere: [E, [dart.functionType(core.bool, [E])], {orElse: dart.functionType(E, [])}], + map: [core.Iterable, [dart.functionType(dart.dynamic, [E])]], + reduce: [E, [dart.functionType(E, [E, E])]], + singleWhere: [E, [dart.functionType(core.bool, [E])]], + skip: [core.Iterable$(E), [core.int]], + skipWhile: [core.Iterable$(E), [dart.functionType(core.bool, [E])]], + take: [core.Iterable$(E), [core.int]], + takeWhile: [core.Iterable$(E), [dart.functionType(core.bool, [E])]], + toList: [core.List$(E), [], {growable: core.bool}], + toSet: [core.Set$(E), []], + where: [core.Iterable$(E), [dart.functionType(core.bool, [E])]] + }) + }); + dart.defineExtensionMembers(_DelegatingIterableBase, [ + 'any', + 'contains', + 'elementAt', + 'every', + 'expand', + 'firstWhere', + 'fold', + 'forEach', + 'join', + 'lastWhere', + 'map', + 'reduce', + 'singleWhere', + 'skip', + 'skipWhile', + 'take', + 'takeWhile', + 'toList', + 'toSet', + 'where', + 'toString', + 'first', + 'isEmpty', + 'isNotEmpty', + 'iterator', + 'last', + 'length', + 'single' + ]); + return _DelegatingIterableBase; + }); + let _DelegatingIterableBase = _DelegatingIterableBase$(); + const DelegatingIterable$ = dart.generic(function(E) { + class DelegatingIterable extends _DelegatingIterableBase$(E) { + DelegatingIterable(base) { + this[_base] = base; + super._DelegatingIterableBase(); + } + } + dart.setSignature(DelegatingIterable, { + constructors: () => ({DelegatingIterable: [DelegatingIterable$(E), [core.Iterable$(E)]]}) + }); + return DelegatingIterable; + }); + let DelegatingIterable = DelegatingIterable$(); + const _listBase = Symbol('_listBase'); + const DelegatingList$ = dart.generic(function(E) { + class DelegatingList extends DelegatingIterable$(E) { + DelegatingList(base) { + super.DelegatingIterable(base); + } + get [_listBase]() { + return dart.as(this[_base], core.List$(E)); + } + get(index) { + return this[_listBase][dartx.get](index); + } + set(index, value) { + dart.as(value, E); + this[_listBase][dartx.set](index, value); + return value; + } + add(value) { + dart.as(value, E); + this[_listBase][dartx.add](value); + } + addAll(iterable) { + dart.as(iterable, core.Iterable$(E)); + this[_listBase][dartx.addAll](iterable); + } + asMap() { + return this[_listBase][dartx.asMap](); + } + clear() { + this[_listBase][dartx.clear](); + } + fillRange(start, end, fillValue) { + if (fillValue === void 0) fillValue = null; + dart.as(fillValue, E); + this[_listBase][dartx.fillRange](start, end, fillValue); + } + getRange(start, end) { + return this[_listBase][dartx.getRange](start, end); + } + indexOf(element, start) { + dart.as(element, E); + if (start === void 0) start = 0; + return this[_listBase][dartx.indexOf](element, start); + } + insert(index, element) { + dart.as(element, E); + this[_listBase][dartx.insert](index, element); + } + insertAll(index, iterable) { + dart.as(iterable, core.Iterable$(E)); + this[_listBase][dartx.insertAll](index, iterable); + } + lastIndexOf(element, start) { + dart.as(element, E); + if (start === void 0) start = null; + return this[_listBase][dartx.lastIndexOf](element, start); + } + set length(newLength) { + this[_listBase][dartx.length] = newLength; + } + remove(value) { + return this[_listBase][dartx.remove](value); + } + removeAt(index) { + return this[_listBase][dartx.removeAt](index); + } + removeLast() { + return this[_listBase][dartx.removeLast](); + } + removeRange(start, end) { + this[_listBase][dartx.removeRange](start, end); + } + removeWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + this[_listBase][dartx.removeWhere](test); + } + replaceRange(start, end, iterable) { + dart.as(iterable, core.Iterable$(E)); + this[_listBase][dartx.replaceRange](start, end, iterable); + } + retainWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + this[_listBase][dartx.retainWhere](test); + } + get reversed() { + return this[_listBase][dartx.reversed]; + } + setAll(index, iterable) { + dart.as(iterable, core.Iterable$(E)); + this[_listBase][dartx.setAll](index, iterable); + } + setRange(start, end, iterable, skipCount) { + dart.as(iterable, core.Iterable$(E)); + if (skipCount === void 0) skipCount = 0; + this[_listBase][dartx.setRange](start, end, iterable, skipCount); + } + shuffle(random) { + if (random === void 0) random = null; + this[_listBase][dartx.shuffle](random); + } + sort(compare) { + if (compare === void 0) compare = null; + dart.as(compare, dart.functionType(core.int, [E, E])); + this[_listBase][dartx.sort](compare); + } + sublist(start, end) { + if (end === void 0) end = null; + return this[_listBase][dartx.sublist](start, end); + } + } + DelegatingList[dart.implements] = () => [core.List$(E)]; + dart.setSignature(DelegatingList, { + constructors: () => ({DelegatingList: [DelegatingList$(E), [core.List$(E)]]}), + methods: () => ({ + get: [E, [core.int]], + set: [dart.void, [core.int, E]], + add: [dart.void, [E]], + addAll: [dart.void, [core.Iterable$(E)]], + asMap: [core.Map$(core.int, E), []], + clear: [dart.void, []], + fillRange: [dart.void, [core.int, core.int], [E]], + getRange: [core.Iterable$(E), [core.int, core.int]], + indexOf: [core.int, [E], [core.int]], + insert: [dart.void, [core.int, E]], + insertAll: [dart.void, [core.int, core.Iterable$(E)]], + lastIndexOf: [core.int, [E], [core.int]], + remove: [core.bool, [core.Object]], + removeAt: [E, [core.int]], + removeLast: [E, []], + removeRange: [dart.void, [core.int, core.int]], + removeWhere: [dart.void, [dart.functionType(core.bool, [E])]], + replaceRange: [dart.void, [core.int, core.int, core.Iterable$(E)]], + retainWhere: [dart.void, [dart.functionType(core.bool, [E])]], + setAll: [dart.void, [core.int, core.Iterable$(E)]], + setRange: [dart.void, [core.int, core.int, core.Iterable$(E)], [core.int]], + shuffle: [dart.void, [], [math.Random]], + sort: [dart.void, [], [dart.functionType(core.int, [E, E])]], + sublist: [core.List$(E), [core.int], [core.int]] + }) + }); + dart.defineExtensionMembers(DelegatingList, [ + 'get', + 'set', + 'add', + 'addAll', + 'asMap', + 'clear', + 'fillRange', + 'getRange', + 'indexOf', + 'insert', + 'insertAll', + 'lastIndexOf', + 'remove', + 'removeAt', + 'removeLast', + 'removeRange', + 'removeWhere', + 'replaceRange', + 'retainWhere', + 'setAll', + 'setRange', + 'shuffle', + 'sort', + 'sublist', + 'length', + 'reversed' + ]); + return DelegatingList; + }); + let DelegatingList = DelegatingList$(); + const _setBase = Symbol('_setBase'); + const DelegatingSet$ = dart.generic(function(E) { + class DelegatingSet extends DelegatingIterable$(E) { + DelegatingSet(base) { + super.DelegatingIterable(base); + } + get [_setBase]() { + return dart.as(this[_base], core.Set$(E)); + } + add(value) { + dart.as(value, E); + return this[_setBase].add(value); + } + addAll(elements) { + dart.as(elements, core.Iterable$(E)); + this[_setBase].addAll(elements); + } + clear() { + this[_setBase].clear(); + } + containsAll(other) { + return this[_setBase].containsAll(other); + } + difference(other) { + dart.as(other, core.Set$(E)); + return this[_setBase].difference(other); + } + intersection(other) { + return this[_setBase].intersection(other); + } + lookup(element) { + return this[_setBase].lookup(element); + } + remove(value) { + return this[_setBase].remove(value); + } + removeAll(elements) { + this[_setBase].removeAll(elements); + } + removeWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + this[_setBase].removeWhere(test); + } + retainAll(elements) { + this[_setBase].retainAll(elements); + } + retainWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + this[_setBase].retainWhere(test); + } + union(other) { + dart.as(other, core.Set$(E)); + return this[_setBase].union(other); + } + toSet() { + return new (DelegatingSet$(E))(this[_setBase].toSet()); + } + } + DelegatingSet[dart.implements] = () => [core.Set$(E)]; + dart.setSignature(DelegatingSet, { + constructors: () => ({DelegatingSet: [DelegatingSet$(E), [core.Set$(E)]]}), + methods: () => ({ + add: [core.bool, [E]], + addAll: [dart.void, [core.Iterable$(E)]], + clear: [dart.void, []], + containsAll: [core.bool, [core.Iterable$(core.Object)]], + difference: [core.Set$(E), [core.Set$(E)]], + intersection: [core.Set$(E), [core.Set$(core.Object)]], + lookup: [E, [core.Object]], + remove: [core.bool, [core.Object]], + removeAll: [dart.void, [core.Iterable$(core.Object)]], + removeWhere: [dart.void, [dart.functionType(core.bool, [E])]], + retainAll: [dart.void, [core.Iterable$(core.Object)]], + retainWhere: [dart.void, [dart.functionType(core.bool, [E])]], + union: [core.Set$(E), [core.Set$(E)]], + toSet: [core.Set$(E), []] + }) + }); + dart.defineExtensionMembers(DelegatingSet, ['toSet']); + return DelegatingSet; + }); + let DelegatingSet = DelegatingSet$(); + const _baseQueue = Symbol('_baseQueue'); + const DelegatingQueue$ = dart.generic(function(E) { + class DelegatingQueue extends DelegatingIterable$(E) { + DelegatingQueue(queue) { + super.DelegatingIterable(queue); + } + get [_baseQueue]() { + return dart.as(this[_base], collection.Queue$(E)); + } + add(value) { + dart.as(value, E); + this[_baseQueue].add(value); + } + addAll(iterable) { + dart.as(iterable, core.Iterable$(E)); + this[_baseQueue].addAll(iterable); + } + addFirst(value) { + dart.as(value, E); + this[_baseQueue].addFirst(value); + } + addLast(value) { + dart.as(value, E); + this[_baseQueue].addLast(value); + } + clear() { + this[_baseQueue].clear(); + } + remove(object) { + return this[_baseQueue].remove(object); + } + removeWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + this[_baseQueue].removeWhere(test); + } + retainWhere(test) { + dart.as(test, dart.functionType(core.bool, [E])); + this[_baseQueue].retainWhere(test); + } + removeFirst() { + return this[_baseQueue].removeFirst(); + } + removeLast() { + return this[_baseQueue].removeLast(); + } + } + DelegatingQueue[dart.implements] = () => [collection.Queue$(E)]; + dart.setSignature(DelegatingQueue, { + constructors: () => ({DelegatingQueue: [DelegatingQueue$(E), [collection.Queue$(E)]]}), + methods: () => ({ + add: [dart.void, [E]], + addAll: [dart.void, [core.Iterable$(E)]], + addFirst: [dart.void, [E]], + addLast: [dart.void, [E]], + clear: [dart.void, []], + remove: [core.bool, [core.Object]], + removeWhere: [dart.void, [dart.functionType(core.bool, [E])]], + retainWhere: [dart.void, [dart.functionType(core.bool, [E])]], + removeFirst: [E, []], + removeLast: [E, []] + }) + }); + return DelegatingQueue; + }); + let DelegatingQueue = DelegatingQueue$(); + const DelegatingMap$ = dart.generic(function(K, V) { + class DelegatingMap extends core.Object { + DelegatingMap(base) { + this[_base] = base; + } + get(key) { + return this[_base].get(key); + } + set(key, value) { + dart.as(key, K); + dart.as(value, V); + this[_base].set(key, value); + return value; + } + addAll(other) { + dart.as(other, core.Map$(K, V)); + this[_base].addAll(other); + } + clear() { + this[_base].clear(); + } + containsKey(key) { + return this[_base].containsKey(key); + } + containsValue(value) { + return this[_base].containsValue(value); + } + forEach(f) { + dart.as(f, dart.functionType(dart.void, [K, V])); + this[_base].forEach(f); + } + get isEmpty() { + return this[_base].isEmpty; + } + get isNotEmpty() { + return this[_base].isNotEmpty; + } + get keys() { + return this[_base].keys; + } + get length() { + return this[_base].length; + } + putIfAbsent(key, ifAbsent) { + dart.as(key, K); + dart.as(ifAbsent, dart.functionType(V, [])); + return this[_base].putIfAbsent(key, ifAbsent); + } + remove(key) { + return this[_base].remove(key); + } + get values() { + return this[_base].values; + } + toString() { + return dart.toString(this[_base]); + } + } + DelegatingMap[dart.implements] = () => [core.Map$(K, V)]; + dart.setSignature(DelegatingMap, { + constructors: () => ({DelegatingMap: [DelegatingMap$(K, V), [core.Map$(K, V)]]}), + methods: () => ({ + get: [V, [core.Object]], + set: [dart.void, [K, V]], + addAll: [dart.void, [core.Map$(K, V)]], + clear: [dart.void, []], + containsKey: [core.bool, [core.Object]], + containsValue: [core.bool, [core.Object]], + forEach: [dart.void, [dart.functionType(dart.void, [K, V])]], + putIfAbsent: [V, [K, dart.functionType(V, [])]], + remove: [V, [core.Object]] + }) + }); + return DelegatingMap; + }); + let DelegatingMap = DelegatingMap$(); + const _baseMap = Symbol('_baseMap'); + const MapKeySet$ = dart.generic(function(E) { + class MapKeySet extends dart.mixin(_DelegatingIterableBase$(E), unmodifiable_wrappers.UnmodifiableSetMixin$(E)) { + MapKeySet(base) { + this[_baseMap] = base; + super._DelegatingIterableBase(); + } + get [_base]() { + return this[_baseMap].keys; + } + contains(element) { + return this[_baseMap].containsKey(element); + } + get isEmpty() { + return this[_baseMap].isEmpty; + } + get isNotEmpty() { + return this[_baseMap].isNotEmpty; + } + get length() { + return this[_baseMap].length; + } + toString() { + return `{${this[_base][dartx.join](', ')}}`; + } + containsAll(other) { + return other[dartx.every](dart.bind(this, 'contains')); + } + difference(other) { + dart.as(other, core.Set$(E)); + return this.where(dart.fn(element => !dart.notNull(other.contains(element)), core.bool, [E]))[dartx.toSet](); + } + intersection(other) { + return this.where(dart.bind(other, 'contains'))[dartx.toSet](); + } + lookup(element) { + dart.as(element, E); + return dart.throw(new core.UnsupportedError("MapKeySet doesn't support lookup().")); + } + union(other) { + dart.as(other, core.Set$(E)); + return (() => { + let _ = this.toSet(); + _.addAll(other); + return _; + })(); + } + } + dart.setSignature(MapKeySet, { + constructors: () => ({MapKeySet: [exports.MapKeySet$(E), [core.Map$(E, dart.dynamic)]]}), + methods: () => ({ + containsAll: [core.bool, [core.Iterable$(core.Object)]], + difference: [core.Set$(E), [core.Set$(E)]], + intersection: [core.Set$(E), [core.Set$(core.Object)]], + lookup: [E, [E]], + union: [core.Set$(E), [core.Set$(E)]] + }) + }); + dart.defineExtensionMembers(MapKeySet, [ + 'contains', + 'toString', + 'isEmpty', + 'isNotEmpty', + 'length' + ]); + return MapKeySet; + }); + dart.defineLazyClassGeneric(exports, 'MapKeySet', {get: MapKeySet$}); + const _keyForValue = Symbol('_keyForValue'); + const MapValueSet$ = dart.generic(function(K, V) { + class MapValueSet extends _DelegatingIterableBase$(V) { + MapValueSet(base, keyForValue) { + this[_baseMap] = base; + this[_keyForValue] = keyForValue; + super._DelegatingIterableBase(); + } + get [_base]() { + return this[_baseMap].values; + } + contains(element) { + if (element != null && !dart.is(element, V)) return false; + return this[_baseMap].containsKey(dart.dcall(this[_keyForValue], element)); + } + get isEmpty() { + return this[_baseMap].isEmpty; + } + get isNotEmpty() { + return this[_baseMap].isNotEmpty; + } + get length() { + return this[_baseMap].length; + } + toString() { + return dart.toString(this.toSet()); + } + add(value) { + dart.as(value, V); + let key = dart.as(dart.dcall(this[_keyForValue], value), K); + let result = false; + this[_baseMap].putIfAbsent(key, dart.fn(() => { + result = true; + return value; + }, V, [])); + return result; + } + addAll(elements) { + dart.as(elements, core.Iterable$(V)); + return elements[dartx.forEach](dart.bind(this, 'add')); + } + clear() { + return this[_baseMap].clear(); + } + containsAll(other) { + return other[dartx.every](dart.bind(this, 'contains')); + } + difference(other) { + dart.as(other, core.Set$(V)); + return this.where(dart.fn(element => !dart.notNull(other.contains(element)), core.bool, [V]))[dartx.toSet](); + } + intersection(other) { + return this.where(dart.bind(other, 'contains'))[dartx.toSet](); + } + lookup(element) { + return this[_baseMap].get(dart.dcall(this[_keyForValue], element)); + } + remove(value) { + if (value != null && !dart.is(value, V)) return false; + let key = dart.dcall(this[_keyForValue], value); + if (!dart.notNull(this[_baseMap].containsKey(key))) return false; + this[_baseMap].remove(key); + return true; + } + removeAll(elements) { + return elements[dartx.forEach](dart.bind(this, 'remove')); + } + removeWhere(test) { + dart.as(test, dart.functionType(core.bool, [V])); + let toRemove = []; + this[_baseMap].forEach(dart.fn((key, value) => { + dart.as(key, K); + dart.as(value, V); + if (dart.notNull(test(value))) toRemove[dartx.add](key); + }, dart.void, [K, V])); + toRemove[dartx.forEach](dart.bind(this[_baseMap], 'remove')); + } + retainAll(elements) { + let valuesToRetain = core.Set$(V).identity(); + for (let element of elements) { + if (element != null && !dart.is(element, V)) continue; + let key = dart.dcall(this[_keyForValue], element); + if (!dart.notNull(this[_baseMap].containsKey(key))) continue; + valuesToRetain.add(this[_baseMap].get(key)); + } + let keysToRemove = []; + this[_baseMap].forEach(dart.fn((k, v) => { + dart.as(k, K); + dart.as(v, V); + if (!dart.notNull(valuesToRetain.contains(v))) keysToRemove[dartx.add](k); + }, dart.void, [K, V])); + keysToRemove[dartx.forEach](dart.bind(this[_baseMap], 'remove')); + } + retainWhere(test) { + dart.as(test, dart.functionType(core.bool, [V])); + return this.removeWhere(dart.fn(element => !dart.notNull(test(element)), core.bool, [V])); + } + union(other) { + dart.as(other, core.Set$(V)); + return (() => { + let _ = this.toSet(); + _.addAll(other); + return _; + })(); + } + } + MapValueSet[dart.implements] = () => [core.Set$(V)]; + dart.setSignature(MapValueSet, { + constructors: () => ({MapValueSet: [MapValueSet$(K, V), [core.Map$(K, V), dart.functionType(K, [V])]]}), + methods: () => ({ + add: [core.bool, [V]], + addAll: [dart.void, [core.Iterable$(V)]], + clear: [dart.void, []], + containsAll: [core.bool, [core.Iterable$(core.Object)]], + difference: [core.Set$(V), [core.Set$(V)]], + intersection: [core.Set$(V), [core.Set$(core.Object)]], + lookup: [V, [core.Object]], + remove: [core.bool, [core.Object]], + removeAll: [dart.void, [core.Iterable$(core.Object)]], + removeWhere: [dart.void, [dart.functionType(core.bool, [V])]], + retainAll: [dart.void, [core.Iterable$(core.Object)]], + retainWhere: [dart.void, [dart.functionType(core.bool, [V])]], + union: [core.Set$(V), [core.Set$(V)]] + }) + }); + dart.defineExtensionMembers(MapValueSet, [ + 'contains', + 'toString', + 'isEmpty', + 'isNotEmpty', + 'length' + ]); + return MapValueSet; + }); + let MapValueSet = MapValueSet$(); + // Exports: + exports.DelegatingIterable$ = DelegatingIterable$; + exports.DelegatingIterable = DelegatingIterable; + exports.DelegatingList$ = DelegatingList$; + exports.DelegatingList = DelegatingList; + exports.DelegatingSet$ = DelegatingSet$; + exports.DelegatingSet = DelegatingSet; + exports.DelegatingQueue$ = DelegatingQueue$; + exports.DelegatingQueue = DelegatingQueue; + exports.DelegatingMap$ = DelegatingMap$; + exports.DelegatingMap = DelegatingMap; + exports.MapKeySet$ = MapKeySet$; + exports.MapValueSet$ = MapValueSet$; + exports.MapValueSet = MapValueSet; +}); diff --git a/pkg/dev_compiler/test/codegen/expect/html_input.html b/pkg/dev_compiler/test/codegen/expect/html_input.html index 210e5b2652c0..006499e9f062 100644 --- a/pkg/dev_compiler/test/codegen/expect/html_input.html +++ b/pkg/dev_compiler/test/codegen/expect/html_input.html @@ -21,8 +21,8 @@ - + diff --git a/pkg/dev_compiler/test/codegen/expect/language-all.js b/pkg/dev_compiler/test/codegen/expect/language-all.js index 1b51d3c398a6..d02176154e29 100644 --- a/pkg/dev_compiler/test/codegen/expect/language-all.js +++ b/pkg/dev_compiler/test/codegen/expect/language-all.js @@ -26391,6 +26391,253 @@ dart_library.library('language/built_in_identifier_prefix_library_typedef', null exports.C$ = C$; exports.C = C; }); +dart_library.library('language/built_in_identifier_test_01_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + class PseudoKWTest extends core.Object { + static testMain() { + let abstract = 0; + let as = 0; + let dynamic = 0; + let export$ = 0; + let external = 0; + let factory = 0; + let get = 0; + let implements$ = 0; + let import$ = 0; + let library = 0; + let operator = 0; + let part = 0; + let set = 0; + let static$ = 0; + let typedef = 0; + let native = 0; + { + function factory(set) { + return; + } + dart.fn(factory, dart.void, [dart.dynamic]); + } + get: + while (import$ > 0) { + break get; + } + return static$ + library * operator; + } + } + dart.setSignature(PseudoKWTest, { + statics: () => ({testMain: [dart.dynamic, []]}), + names: ['testMain'] + }); + function typedef(x) { + return `typedef ${x}`; + } + dart.fn(typedef); + function static$(abstract) { + return dart.equals(abstract, true); + } + dart.fn(static$); + class A extends core.Object { + A() { + this.typedef = 0; + this.operator = "smooth"; + } + set(x) { + this.typedef = dart.as(x, core.int); + } + get() { + return dart.notNull(this.typedef) - 5; + } + static static() { + return 1; + } + static check() { + let o = new A(); + o.set(55); + expect.Expect.equals(50, o.get()); + A.static(); + } + } + dart.setSignature(A, { + methods: () => ({ + set: [dart.dynamic, [dart.dynamic]], + get: [dart.dynamic, []] + }), + statics: () => ({ + static: [dart.dynamic, []], + check: [dart.dynamic, []] + }), + names: ['static', 'check'] + }); + class B extends core.Object { + B() { + this.set = 100; + } + get get() { + return this.set; + } + set get(get) { + return this.set = dart.asInt(2 * dart.notNull(dart.as(dart.dload(get, 'get'), core.num))); + } + static() { + let set = new B(); + set.get = set; + expect.Expect.equals(200, set.get); + } + operator() { + return 1; + } + } + dart.setSignature(B, { + methods: () => ({ + static: [dart.dynamic, []], + operator: [core.int, []] + }) + }); + class C extends core.Object { + static get set() { + return 111; + } + static set set(set) {} + } + C.operator = 5; + C.get = null; + function main() { + PseudoKWTest.testMain(); + A.check(); + new B().static(); + expect.Expect.equals(1, new B().operator()); + expect.Expect.equals(1, A.static()); + typedef("T"); + expect.Expect.equals("typedef T", typedef("T")); + static$("true"); + expect.Expect.equals(false, static$("true")); + expect.Expect.equals(5, C.operator); + expect.Expect.equals(null, C.get); + C.set = 0; + expect.Expect.equals(111, C.set); + } + dart.fn(main); + // Exports: + exports.PseudoKWTest = PseudoKWTest; + exports.typedef = typedef; + exports.static = static$; + exports.A = A; + exports.B = B; + exports.C = C; + exports.main = main; +}); +dart_library.library('language/built_in_identifier_test_none_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + class PseudoKWTest extends core.Object { + static testMain() { + let as = 0; + let dynamic = 0; + let export$ = 0; + let factory = 0; + let get = 0; + let implements$ = 0; + let import$ = 0; + let library = 0; + let operator = 0; + let part = 0; + let set = 0; + let typedef = 0; + let native = 0; + { + function factory(set) { + } + dart.fn(factory, dart.void, [dart.dynamic]); + } + get: + while (import$ > 0) { + break get; + } + return library * operator; + } + } + dart.setSignature(PseudoKWTest, { + statics: () => ({testMain: [dart.dynamic, []]}), + names: ['testMain'] + }); + class A extends core.Object { + A() { + this.typedef = 0; + this.operator = "smooth"; + } + set(x) { + this.typedef = dart.as(x, core.int); + } + get() { + return dart.notNull(this.typedef) - 5; + } + static check() { + let o = new A(); + o.set(55); + expect.Expect.equals(50, o.get()); + } + } + dart.setSignature(A, { + methods: () => ({ + set: [dart.dynamic, [dart.dynamic]], + get: [dart.dynamic, []] + }), + statics: () => ({check: [dart.dynamic, []]}), + names: ['check'] + }); + class B extends core.Object { + B() { + this.set = 100; + } + get get() { + return this.set; + } + set get(get) { + return this.set = dart.asInt(2 * dart.notNull(dart.as(dart.dload(get, 'get'), core.num))); + } + operator() { + return 1; + } + } + dart.setSignature(B, { + methods: () => ({operator: [core.int, []]}) + }); + class C extends core.Object { + static get set() { + return 111; + } + static set set(set) {} + } + C.operator = 5; + C.get = null; + function main() { + PseudoKWTest.testMain(); + A.check(); + expect.Expect.equals(1, new B().operator()); + expect.Expect.equals(5, C.operator); + expect.Expect.equals(null, C.get); + C.set = 0; + expect.Expect.equals(111, C.set); + } + dart.fn(main); + // Exports: + exports.PseudoKWTest = PseudoKWTest; + exports.A = A; + exports.B = B; + exports.C = C; + exports.main = main; +}); dart_library.library('language/call_argument_inference_test', null, /* Imports */[ 'dart/_runtime', 'dart/core', @@ -60417,6 +60664,131 @@ dart_library.library('language/function_getter_test', null, /* Imports */[ exports.A = A; exports.main = main; }); +dart_library.library('language/function_literals_test', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + const IntFunc = dart.typedef('IntFunc', () => dart.functionType(core.int, [dart.dynamic])); + class FunctionLiteralsTest extends core.Object { + static checkIntFunction(expected, f, arg) { + expect.Expect.equals(expected, dart.dcall(f, arg)); + } + static checkIntFuncFunction(expected, f, arg) { + expect.Expect.equals(expected, dart.dcall(dart.dcall(f, arg), arg)); + } + func1(x) { + return x; + } + func2(x) { + return dart.as(x, core.int); + } + func3(x) { + return x; + } + func4(x) { + return dart.as(x, core.int); + } + FunctionLiteralsTest() { + } + static testMain() { + let test = new FunctionLiteralsTest(); + test.testArrow(); + test.testArrowArrow(); + test.testArrowBlock(); + test.testBlock(); + test.testBlockArrow(); + test.testBlockBlock(); + test.testFunctionRef(); + } + testArrow() { + FunctionLiteralsTest.checkIntFunction(42, dart.fn(x => dart.as(x, core.int), core.int, [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFunction(42, dart.fn(x => x, core.int, [core.int]), 42); + } + testArrowArrow() { + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => dart.fn(y => dart.as(dart.dsend(x, '+', y), core.int), core.int, [dart.dynamic]), dart.functionType(core.int, [dart.dynamic]), [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFuncFunction(84, dart.as(dart.fn(x => dart.fn(y => dart.notNull(x) + dart.notNull(dart.as(y, core.num)), core.num, [dart.dynamic]), dart.functionType(core.num, [dart.dynamic]), [core.int]), __CastType0), 42); + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => dart.fn(y => dart.as(dart.dsend(x, '+', y), core.int), core.int, [dart.dynamic]), dart.functionType(core.int, [dart.dynamic]), [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFuncFunction(84, dart.as(dart.fn(x => dart.fn(y => dart.notNull(x) + dart.notNull(dart.as(y, core.num)), core.num, [dart.dynamic]), dart.functionType(core.num, [dart.dynamic]), [core.int]), dart.functionType(IntFunc, [dart.dynamic])), 42); + } + testArrowBlock() { + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => dart.fn(y => { + return dart.as(dart.dsend(x, '+', y), core.int); + }, core.int, [dart.dynamic]), dart.functionType(core.int, [dart.dynamic]), [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => dart.fn(y => { + return dart.asInt(dart.notNull(x) + dart.notNull(dart.as(y, core.num))); + }, core.int, [dart.dynamic]), dart.functionType(core.int, [dart.dynamic]), [core.int]), 42); + } + testBlock() { + FunctionLiteralsTest.checkIntFunction(42, dart.fn(x => { + return dart.as(x, core.int); + }, core.int, [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFunction(42, dart.fn(x => { + return x; + }, core.int, [core.int]), 42); + } + testBlockArrow() { + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => { + return dart.fn(y => dart.as(dart.dsend(x, '+', y), core.int), core.int, [dart.dynamic]); + }, IntFunc, [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => { + return dart.as(dart.fn(y => dart.notNull(x) + dart.notNull(dart.as(y, core.num)), core.num, [dart.dynamic]), IntFunc); + }, IntFunc, [core.int]), 42); + } + testBlockBlock() { + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => { + return dart.fn(y => { + return dart.as(dart.dsend(x, '+', y), core.int); + }, core.int, [dart.dynamic]); + }, IntFunc, [dart.dynamic]), 42); + FunctionLiteralsTest.checkIntFuncFunction(84, dart.fn(x => { + return dart.fn(y => { + return dart.asInt(dart.notNull(x) + dart.notNull(dart.as(y, core.num))); + }, core.int, [dart.dynamic]); + }, IntFunc, [core.int]), 42); + } + testFunctionRef() { + FunctionLiteralsTest.checkIntFunction(42, dart.bind(this, 'func1'), 42); + FunctionLiteralsTest.checkIntFunction(42, dart.bind(this, 'func2'), 42); + FunctionLiteralsTest.checkIntFunction(42, dart.bind(this, 'func3'), 42); + FunctionLiteralsTest.checkIntFunction(42, dart.bind(this, 'func4'), 42); + } + } + dart.setSignature(FunctionLiteralsTest, { + constructors: () => ({FunctionLiteralsTest: [FunctionLiteralsTest, []]}), + methods: () => ({ + func1: [core.int, [core.int]], + func2: [core.int, [dart.dynamic]], + func3: [core.int, [core.int]], + func4: [core.int, [dart.dynamic]], + testArrow: [dart.void, []], + testArrowArrow: [dart.void, []], + testArrowBlock: [dart.void, []], + testBlock: [dart.void, []], + testBlockArrow: [dart.void, []], + testBlockBlock: [dart.void, []], + testFunctionRef: [dart.void, []] + }), + statics: () => ({ + checkIntFunction: [dart.void, [dart.dynamic, dart.functionType(core.int, [dart.dynamic]), dart.dynamic]], + checkIntFuncFunction: [dart.void, [dart.dynamic, dart.functionType(IntFunc, [dart.dynamic]), dart.dynamic]], + testMain: [dart.void, []] + }), + names: ['checkIntFunction', 'checkIntFuncFunction', 'testMain'] + }); + function main() { + FunctionLiteralsTest.testMain(); + } + dart.fn(main); + const __CastType0 = dart.typedef('__CastType0', () => dart.functionType(IntFunc, [dart.dynamic])); + // Exports: + exports.IntFunc = IntFunc; + exports.FunctionLiteralsTest = FunctionLiteralsTest; + exports.main = main; +}); dart_library.library('language/function_propagation_test', null, /* Imports */[ 'dart/_runtime', 'dart/core', @@ -72541,6 +72913,129 @@ dart_library.library('language/if_null_assignment_static_test_03_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); +dart_library.library('language/if_null_assignment_static_test_05_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + dart.copyProperties(exports, { + get checkedMode() { + let checked = false; + dart.assert(checked = true); + return checked; + } + }); + function noMethod(e) { + return dart.is(e, core.NoSuchMethodError); + } + dart.fn(noMethod); + function bad() { + expect.Expect.fail('Should not be executed'); + } + dart.fn(bad); + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends A { + C() { + this.c = null; + super.A(); + } + } + dart.copyProperties(exports, { + get a() { + return null; + }, + set a(value) {}, + get b() { + return null; + }, + set b(value) {} + }); + class ClassWithStaticGetters extends core.Object { + static get a() { + return null; + } + static set a(value) {} + static get b() { + return null; + } + static set b(value) {} + } + class ClassWithInstanceGetters extends core.Object { + get a() { + return null; + } + set a(value) {} + get b() { + return null; + } + set b(value) {} + } + class DerivedClass extends ClassWithInstanceGetters { + get a() { + return dart.as(bad(), A); + } + set a(value) { + bad(); + } + get b() { + return dart.as(bad(), B); + } + set b(value) { + bad(); + } + derivedTest() { + if (!dart.notNull(exports.checkedMode)) { + (() => { + let t = super.b; + return t == null ? super.b = new A() : t; + })().a; + } + } + } + dart.setSignature(DerivedClass, { + methods: () => ({derivedTest: [dart.void, []]}) + }); + function main() { + let _ = null; + let t = _; + t == null ? _ = null : t; + new DerivedClass().derivedTest(); + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + } + dart.fn(main); + // Exports: + exports.noMethod = noMethod; + exports.bad = bad; + exports.A = A; + exports.B = B; + exports.C = C; + exports.ClassWithStaticGetters = ClassWithStaticGetters; + exports.ClassWithInstanceGetters = ClassWithInstanceGetters; + exports.DerivedClass = DerivedClass; + exports.main = main; +}); dart_library.library('language/if_null_assignment_static_test_08_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', @@ -72787,6 +73282,129 @@ dart_library.library('language/if_null_assignment_static_test_10_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); +dart_library.library('language/if_null_assignment_static_test_12_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + dart.copyProperties(exports, { + get checkedMode() { + let checked = false; + dart.assert(checked = true); + return checked; + } + }); + function noMethod(e) { + return dart.is(e, core.NoSuchMethodError); + } + dart.fn(noMethod); + function bad() { + expect.Expect.fail('Should not be executed'); + } + dart.fn(bad); + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends A { + C() { + this.c = null; + super.A(); + } + } + dart.copyProperties(exports, { + get a() { + return null; + }, + set a(value) {}, + get b() { + return null; + }, + set b(value) {} + }); + class ClassWithStaticGetters extends core.Object { + static get a() { + return null; + } + static set a(value) {} + static get b() { + return null; + } + static set b(value) {} + } + class ClassWithInstanceGetters extends core.Object { + get a() { + return null; + } + set a(value) {} + get b() { + return null; + } + set b(value) {} + } + class DerivedClass extends ClassWithInstanceGetters { + get a() { + return dart.as(bad(), A); + } + set a(value) { + bad(); + } + get b() { + return dart.as(bad(), B); + } + set b(value) { + bad(); + } + derivedTest() { + if (!dart.notNull(exports.checkedMode)) { + } + } + } + dart.setSignature(DerivedClass, { + methods: () => ({derivedTest: [dart.void, []]}) + }); + function main() { + let _ = null; + let t = _; + t == null ? _ = null : t; + new DerivedClass().derivedTest(); + if (!dart.notNull(exports.checkedMode)) { + (() => { + let t = exports.b; + return t == null ? exports.b = new A() : t; + })().a; + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + } + dart.fn(main); + // Exports: + exports.noMethod = noMethod; + exports.bad = bad; + exports.A = A; + exports.B = B; + exports.C = C; + exports.ClassWithStaticGetters = ClassWithStaticGetters; + exports.ClassWithInstanceGetters = ClassWithInstanceGetters; + exports.DerivedClass = DerivedClass; + exports.main = main; +}); dart_library.library('language/if_null_assignment_static_test_15_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', @@ -72886,7 +73504,378 @@ dart_library.library('language/if_null_assignment_static_test_15_multi', null, / if (!dart.notNull(exports.checkedMode)) { } (() => { - let o = ClassWithStaticGetters, t = o.a; + let o = ClassWithStaticGetters, t = o.a; + return t == null ? o.a = new A() : t; + })().a; + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + } + dart.fn(main); + // Exports: + exports.noMethod = noMethod; + exports.bad = bad; + exports.A = A; + exports.B = B; + exports.C = C; + exports.ClassWithStaticGetters = ClassWithStaticGetters; + exports.ClassWithInstanceGetters = ClassWithInstanceGetters; + exports.DerivedClass = DerivedClass; + exports.main = main; +}); +dart_library.library('language/if_null_assignment_static_test_17_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + dart.copyProperties(exports, { + get checkedMode() { + let checked = false; + dart.assert(checked = true); + return checked; + } + }); + function noMethod(e) { + return dart.is(e, core.NoSuchMethodError); + } + dart.fn(noMethod); + function bad() { + expect.Expect.fail('Should not be executed'); + } + dart.fn(bad); + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends A { + C() { + this.c = null; + super.A(); + } + } + dart.copyProperties(exports, { + get a() { + return null; + }, + set a(value) {}, + get b() { + return null; + }, + set b(value) {} + }); + class ClassWithStaticGetters extends core.Object { + static get a() { + return null; + } + static set a(value) {} + static get b() { + return null; + } + static set b(value) {} + } + class ClassWithInstanceGetters extends core.Object { + get a() { + return null; + } + set a(value) {} + get b() { + return null; + } + set b(value) {} + } + class DerivedClass extends ClassWithInstanceGetters { + get a() { + return dart.as(bad(), A); + } + set a(value) { + bad(); + } + get b() { + return dart.as(bad(), B); + } + set b(value) { + bad(); + } + derivedTest() { + if (!dart.notNull(exports.checkedMode)) { + } + } + } + dart.setSignature(DerivedClass, { + methods: () => ({derivedTest: [dart.void, []]}) + }); + function main() { + let _ = null; + let t = _; + t == null ? _ = null : t; + new DerivedClass().derivedTest(); + if (!dart.notNull(exports.checkedMode)) { + } + (() => { + let o = ClassWithStaticGetters, t = o.a; + return t == null ? o.a = new B() : t; + })().a; + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + } + dart.fn(main); + // Exports: + exports.noMethod = noMethod; + exports.bad = bad; + exports.A = A; + exports.B = B; + exports.C = C; + exports.ClassWithStaticGetters = ClassWithStaticGetters; + exports.ClassWithInstanceGetters = ClassWithInstanceGetters; + exports.DerivedClass = DerivedClass; + exports.main = main; +}); +dart_library.library('language/if_null_assignment_static_test_19_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + dart.copyProperties(exports, { + get checkedMode() { + let checked = false; + dart.assert(checked = true); + return checked; + } + }); + function noMethod(e) { + return dart.is(e, core.NoSuchMethodError); + } + dart.fn(noMethod); + function bad() { + expect.Expect.fail('Should not be executed'); + } + dart.fn(bad); + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends A { + C() { + this.c = null; + super.A(); + } + } + dart.copyProperties(exports, { + get a() { + return null; + }, + set a(value) {}, + get b() { + return null; + }, + set b(value) {} + }); + class ClassWithStaticGetters extends core.Object { + static get a() { + return null; + } + static set a(value) {} + static get b() { + return null; + } + static set b(value) {} + } + class ClassWithInstanceGetters extends core.Object { + get a() { + return null; + } + set a(value) {} + get b() { + return null; + } + set b(value) {} + } + class DerivedClass extends ClassWithInstanceGetters { + get a() { + return dart.as(bad(), A); + } + set a(value) { + bad(); + } + get b() { + return dart.as(bad(), B); + } + set b(value) { + bad(); + } + derivedTest() { + if (!dart.notNull(exports.checkedMode)) { + } + } + } + dart.setSignature(DerivedClass, { + methods: () => ({derivedTest: [dart.void, []]}) + }); + function main() { + let _ = null; + let t = _; + t == null ? _ = null : t; + new DerivedClass().derivedTest(); + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + (() => { + let o = ClassWithStaticGetters, t = o.b; + return t == null ? o.b = new A() : t; + })().a; + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + } + dart.fn(main); + // Exports: + exports.noMethod = noMethod; + exports.bad = bad; + exports.A = A; + exports.B = B; + exports.C = C; + exports.ClassWithStaticGetters = ClassWithStaticGetters; + exports.ClassWithInstanceGetters = ClassWithInstanceGetters; + exports.DerivedClass = DerivedClass; + exports.main = main; +}); +dart_library.library('language/if_null_assignment_static_test_22_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + dart.copyProperties(exports, { + get checkedMode() { + let checked = false; + dart.assert(checked = true); + return checked; + } + }); + function noMethod(e) { + return dart.is(e, core.NoSuchMethodError); + } + dart.fn(noMethod); + function bad() { + expect.Expect.fail('Should not be executed'); + } + dart.fn(bad); + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends A { + C() { + this.c = null; + super.A(); + } + } + dart.copyProperties(exports, { + get a() { + return null; + }, + set a(value) {}, + get b() { + return null; + }, + set b(value) {} + }); + class ClassWithStaticGetters extends core.Object { + static get a() { + return null; + } + static set a(value) {} + static get b() { + return null; + } + static set b(value) {} + } + class ClassWithInstanceGetters extends core.Object { + get a() { + return null; + } + set a(value) {} + get b() { + return null; + } + set b(value) {} + } + class DerivedClass extends ClassWithInstanceGetters { + get a() { + return dart.as(bad(), A); + } + set a(value) { + bad(); + } + get b() { + return dart.as(bad(), B); + } + set b(value) { + bad(); + } + derivedTest() { + if (!dart.notNull(exports.checkedMode)) { + } + } + } + dart.setSignature(DerivedClass, { + methods: () => ({derivedTest: [dart.void, []]}) + }); + function main() { + let _ = null; + let t = _; + t == null ? _ = null : t; + new DerivedClass().derivedTest(); + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + (() => { + let o = new ClassWithInstanceGetters(), t = o.a; return t == null ? o.a = new A() : t; })().a; if (!dart.notNull(exports.checkedMode)) { @@ -72895,8 +73884,6 @@ dart_library.library('language/if_null_assignment_static_test_15_multi', null, / } if (!dart.notNull(exports.checkedMode)) { } - if (!dart.notNull(exports.checkedMode)) { - } } dart.fn(main); // Exports: @@ -72910,7 +73897,7 @@ dart_library.library('language/if_null_assignment_static_test_15_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); -dart_library.library('language/if_null_assignment_static_test_17_multi', null, /* Imports */[ +dart_library.library('language/if_null_assignment_static_test_24_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', 'expect/expect' @@ -73008,8 +73995,10 @@ dart_library.library('language/if_null_assignment_static_test_17_multi', null, / new DerivedClass().derivedTest(); if (!dart.notNull(exports.checkedMode)) { } + if (!dart.notNull(exports.checkedMode)) { + } (() => { - let o = ClassWithStaticGetters, t = o.a; + let o = new ClassWithInstanceGetters(), t = o.a; return t == null ? o.a = new B() : t; })().a; if (!dart.notNull(exports.checkedMode)) { @@ -73018,8 +74007,6 @@ dart_library.library('language/if_null_assignment_static_test_17_multi', null, / } if (!dart.notNull(exports.checkedMode)) { } - if (!dart.notNull(exports.checkedMode)) { - } } dart.fn(main); // Exports: @@ -73033,7 +74020,7 @@ dart_library.library('language/if_null_assignment_static_test_17_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); -dart_library.library('language/if_null_assignment_static_test_22_multi', null, /* Imports */[ +dart_library.library('language/if_null_assignment_static_test_26_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', 'expect/expect' @@ -73133,11 +74120,11 @@ dart_library.library('language/if_null_assignment_static_test_22_multi', null, / } if (!dart.notNull(exports.checkedMode)) { } - (() => { - let o = new ClassWithInstanceGetters(), t = o.a; - return t == null ? o.a = new A() : t; - })().a; if (!dart.notNull(exports.checkedMode)) { + (() => { + let o = new ClassWithInstanceGetters(), t = o.b; + return t == null ? o.b = new A() : t; + })().a; } if (!dart.notNull(exports.checkedMode)) { } @@ -73156,7 +74143,7 @@ dart_library.library('language/if_null_assignment_static_test_22_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); -dart_library.library('language/if_null_assignment_static_test_24_multi', null, /* Imports */[ +dart_library.library('language/if_null_assignment_static_test_29_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', 'expect/expect' @@ -73256,12 +74243,12 @@ dart_library.library('language/if_null_assignment_static_test_24_multi', null, / } if (!dart.notNull(exports.checkedMode)) { } - (() => { - let o = new ClassWithInstanceGetters(), t = o.a; - return t == null ? o.a = new B() : t; - })().a; if (!dart.notNull(exports.checkedMode)) { } + (() => { + let o = dart.list([null], A), i = 0, t = o[dartx.get](i); + return t == null ? o[dartx.set](i, new A()) : t; + })().a; if (!dart.notNull(exports.checkedMode)) { } if (!dart.notNull(exports.checkedMode)) { @@ -73279,7 +74266,7 @@ dart_library.library('language/if_null_assignment_static_test_24_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); -dart_library.library('language/if_null_assignment_static_test_29_multi', null, /* Imports */[ +dart_library.library('language/if_null_assignment_static_test_31_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', 'expect/expect' @@ -73383,7 +74370,7 @@ dart_library.library('language/if_null_assignment_static_test_29_multi', null, / } (() => { let o = dart.list([null], A), i = 0, t = o[dartx.get](i); - return t == null ? o[dartx.set](i, new A()) : t; + return t == null ? o[dartx.set](i, new B()) : t; })().a; if (!dart.notNull(exports.checkedMode)) { } @@ -73402,7 +74389,7 @@ dart_library.library('language/if_null_assignment_static_test_29_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); -dart_library.library('language/if_null_assignment_static_test_31_multi', null, /* Imports */[ +dart_library.library('language/if_null_assignment_static_test_33_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', 'expect/expect' @@ -73504,11 +74491,11 @@ dart_library.library('language/if_null_assignment_static_test_31_multi', null, / } if (!dart.notNull(exports.checkedMode)) { } - (() => { - let o = dart.list([null], A), i = 0, t = o[dartx.get](i); - return t == null ? o[dartx.set](i, new B()) : t; - })().a; if (!dart.notNull(exports.checkedMode)) { + (() => { + let o = dart.list([null], B), i = 0, t = o[dartx.get](i); + return t == null ? o[dartx.set](i, new A()) : t; + })().a; } if (!dart.notNull(exports.checkedMode)) { } @@ -73771,6 +74758,129 @@ dart_library.library('language/if_null_assignment_static_test_38_multi', null, / exports.DerivedClass = DerivedClass; exports.main = main; }); +dart_library.library('language/if_null_assignment_static_test_40_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core', + 'expect/expect' +], /* Lazy imports */[ +], function(exports, dart, core, expect) { + 'use strict'; + let dartx = dart.dartx; + dart.copyProperties(exports, { + get checkedMode() { + let checked = false; + dart.assert(checked = true); + return checked; + } + }); + function noMethod(e) { + return dart.is(e, core.NoSuchMethodError); + } + dart.fn(noMethod); + function bad() { + expect.Expect.fail('Should not be executed'); + } + dart.fn(bad); + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends A { + C() { + this.c = null; + super.A(); + } + } + dart.copyProperties(exports, { + get a() { + return null; + }, + set a(value) {}, + get b() { + return null; + }, + set b(value) {} + }); + class ClassWithStaticGetters extends core.Object { + static get a() { + return null; + } + static set a(value) {} + static get b() { + return null; + } + static set b(value) {} + } + class ClassWithInstanceGetters extends core.Object { + get a() { + return null; + } + set a(value) {} + get b() { + return null; + } + set b(value) {} + } + class DerivedClass extends ClassWithInstanceGetters { + get a() { + return dart.as(bad(), A); + } + set a(value) { + bad(); + } + get b() { + return dart.as(bad(), B); + } + set b(value) { + bad(); + } + derivedTest() { + if (!dart.notNull(exports.checkedMode)) { + } + } + } + dart.setSignature(DerivedClass, { + methods: () => ({derivedTest: [dart.void, []]}) + }); + function main() { + let _ = null; + let t = _; + t == null ? _ = null : t; + new DerivedClass().derivedTest(); + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + } + if (!dart.notNull(exports.checkedMode)) { + (() => { + let o = new ClassWithInstanceGetters(), t = dart.nullSafe(o, _ => _.b); + return t == null ? (o == null ? null : o.b = new A()) : t; + })().a; + } + } + dart.fn(main); + // Exports: + exports.noMethod = noMethod; + exports.bad = bad; + exports.A = A; + exports.B = B; + exports.C = C; + exports.ClassWithStaticGetters = ClassWithStaticGetters; + exports.ClassWithInstanceGetters = ClassWithInstanceGetters; + exports.DerivedClass = DerivedClass; + exports.main = main; +}); dart_library.library('language/if_null_assignment_static_test_none_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core', @@ -140278,6 +141388,103 @@ dart_library.library('language/type_promotion_more_specific_test_03_multi', null exports.testInterface = testInterface; exports.testGeneric = testGeneric; }); +dart_library.library('language/type_promotion_more_specific_test_04_multi', null, /* Imports */[ + 'dart/_runtime', + 'dart/core' +], /* Lazy imports */[ +], function(exports, dart, core) { + 'use strict'; + let dartx = dart.dartx; + class A extends core.Object { + A() { + this.a = null; + } + } + class B extends A { + B() { + this.b = null; + super.A(); + } + } + class C extends core.Object { + C() { + this.c = null; + } + } + const D$ = dart.generic(function(T) { + class D extends core.Object { + D(d) { + this.d = d; + } + } + dart.setSignature(D, { + constructors: () => ({D: [D$(T), [T]]}) + }); + return D; + }); + let D = D$(); + const E$ = dart.generic(function(T) { + class E extends D$(T) { + E(e) { + this.e = dart.as(e, T); + super.D(dart.as(e, T)); + } + } + dart.setSignature(E, { + constructors: () => ({E: [E$(T), [dart.dynamic]]}) + }); + return E; + }); + let E = E$(); + function main() { + testInterface(); + testGeneric(); + } + dart.fn(main, dart.void, []); + function testInterface() { + let x = null; + let y = null; + let a = new B(); + if (dart.is(a, B)) { + } + if (dart.is(a, C)) { + } + let b = new B(); + if (dart.is(b, A)) { + } + if (dart.is(x, A)) { + y = dart.dload(x, 'b'); + } + } + dart.fn(testInterface, dart.void, []); + function testGeneric() { + let x = null; + let y = null; + let d1 = new (E$(B))(null); + if (dart.is(d1, E)) { + } + if (dart.is(d1, E$(A))) { + } + let d2 = new (E$(B))(null); + if (dart.is(d2, E)) { + } + let d3 = new (E$(B))(new B()); + if (dart.is(d3, E$(B))) { + } + } + dart.fn(testGeneric); + // Exports: + exports.A = A; + exports.B = B; + exports.C = C; + exports.D$ = D$; + exports.D = D; + exports.E$ = E$; + exports.E = E; + exports.main = main; + exports.testInterface = testInterface; + exports.testGeneric = testGeneric; +}); dart_library.library('language/type_promotion_more_specific_test_05_multi', null, /* Imports */[ 'dart/_runtime', 'dart/core' diff --git a/pkg/dev_compiler/test/codegen/expect/node_modules.js b/pkg/dev_compiler/test/codegen/expect/node_modules.js new file mode 100644 index 000000000000..5590ecb00c2a --- /dev/null +++ b/pkg/dev_compiler/test/codegen/expect/node_modules.js @@ -0,0 +1,50 @@ +'use strict'; +let dart = require("dart/_runtime"); +let core = require("dart/core"); +let dartx = dart.dartx; +const Callback = dart.typedef('Callback', () => dart.functionType(dart.void, [], {i: core.int})); +class A extends core.Object {} +class _A extends core.Object {} +const B$ = dart.generic(function(T) { + class B extends core.Object {} + return B; +}); +let B = B$(); +const _B$ = dart.generic(function(T) { + class _B extends core.Object {} + return _B; +}); +let _B = _B$(); +function f() { +} +dart.fn(f); +function _f() { +} +dart.fn(_f); +const constant = "abc"; +exports.finalConstant = "abc"; +dart.defineLazyProperties(exports, { + get lazy() { + return dart.as(dart.fn(() => { + core.print('lazy'); + return "abc"; + })(), core.String); + } +}); +exports.mutable = "abc"; +dart.defineLazyProperties(exports, { + get lazyMutable() { + return dart.as(dart.fn(() => { + core.print('lazyMutable'); + return "abc"; + })(), core.String); + }, + set lazyMutable(_) {} +}); +// Exports: +exports.Callback = Callback; +exports.A = A; +exports.B$ = B$; +exports.B = B; +exports.f = f; +exports.constant = constant; diff --git a/pkg/dev_compiler/test/codegen/expect/node_modules.txt b/pkg/dev_compiler/test/codegen/expect/node_modules.txt new file mode 100644 index 000000000000..314e2da1730d --- /dev/null +++ b/pkg/dev_compiler/test/codegen/expect/node_modules.txt @@ -0,0 +1 @@ +// Messages from compiling node_modules.dart diff --git a/pkg/dev_compiler/test/codegen/expect/sunflower/sunflower.html b/pkg/dev_compiler/test/codegen/expect/sunflower/sunflower.html index 97335ad71257..f83c57579f80 100644 --- a/pkg/dev_compiler/test/codegen/expect/sunflower/sunflower.html +++ b/pkg/dev_compiler/test/codegen/expect/sunflower/sunflower.html @@ -45,8 +45,8 @@

drfibonacci's Sunflower Spectacular

- + diff --git a/pkg/dev_compiler/test/codegen/node_modules.dart b/pkg/dev_compiler/test/codegen/node_modules.dart new file mode 100644 index 000000000000..6370fdc26d93 --- /dev/null +++ b/pkg/dev_compiler/test/codegen/node_modules.dart @@ -0,0 +1,25 @@ +library test; + +import 'dart:js'; + +typedef void Callback({int i}); + +class A {} +class _A {} +class B {} +class _B {} + +f() {} +_f() {} + +const String constant = "abc"; +final String finalConstant = "abc"; +final String lazy = (() { + print('lazy'); + return "abc"; +})(); +String mutable = "abc"; +String lazyMutable = (() { + print('lazyMutable'); + return "abc"; +})(); diff --git a/pkg/dev_compiler/test/codegen_test.dart b/pkg/dev_compiler/test/codegen_test.dart index fcb973b7288f..dd3ec981d138 100644 --- a/pkg/dev_compiler/test/codegen_test.dart +++ b/pkg/dev_compiler/test/codegen_test.dart @@ -153,7 +153,9 @@ $compilerMessages'''; var closure = filename == 'closure'; var moduleFormat = filename == 'es6_modules' ? ModuleFormat.es6 - : ModuleFormat.legacy; + : filename == 'node_modules' + ? ModuleFormat.node + : ModuleFormat.legacy; var success; // TODO(vsm): Is it okay to reuse the same context here? If there is // overlap between test files, we may need separate ones for each diff --git a/pkg/dev_compiler/tool/input_sdk/lib/html/ddc/html_ddc.dart b/pkg/dev_compiler/tool/input_sdk/lib/html/ddc/html_ddc.dart index a01c17e81de5..7c5c8510f38d 100644 --- a/pkg/dev_compiler/tool/input_sdk/lib/html/ddc/html_ddc.dart +++ b/pkg/dev_compiler/tool/input_sdk/lib/html/ddc/html_ddc.dart @@ -24,6 +24,7 @@ */ library dart.dom.html; +import 'dart:_runtime' show global_; import 'dart:async'; import 'dart:collection'; import 'dart:_internal' hide Symbol; @@ -4927,7 +4928,7 @@ class DocumentFragment extends Node implements ParentNode { treeSanitizer: treeSanitizer)); } - /** + /** * Alias for [querySelector]. Note this function is deprecated because its * semantics will be changing in the future. */ @@ -4938,7 +4939,7 @@ class DocumentFragment extends Node implements ParentNode { return querySelector(relativeSelectors); } - /** + /** * Alias for [querySelectorAll]. Note this function is deprecated because its * semantics will be changing in the future. */ @@ -7605,7 +7606,7 @@ class Event extends DartHtmlDomObject { e._initEvent(name, canBubble, cancelable); return e; } - + /** The CSS selector involved with event delegation. */ String _selector; @@ -7840,18 +7841,18 @@ class Events { class ElementEvents extends Events { /* Raw event target. */ static final webkitEvents = { - 'animationend' : 'webkitAnimationEnd', - 'animationiteration' : 'webkitAnimationIteration', - 'animationstart' : 'webkitAnimationStart', - 'fullscreenchange' : 'webkitfullscreenchange', + 'animationend' : 'webkitAnimationEnd', + 'animationiteration' : 'webkitAnimationIteration', + 'animationstart' : 'webkitAnimationStart', + 'fullscreenchange' : 'webkitfullscreenchange', 'fullscreenerror' : 'webkitfullscreenerror', - 'keyadded' : 'webkitkeyadded', - 'keyerror' : 'webkitkeyerror', - 'keymessage' : 'webkitkeymessage', - 'needkey' : 'webkitneedkey', - 'pointerlockchange' : 'webkitpointerlockchange', - 'pointerlockerror' : 'webkitpointerlockerror', - 'resourcetimingbufferfull' : 'webkitresourcetimingbufferfull', + 'keyadded' : 'webkitkeyadded', + 'keyerror' : 'webkitkeyerror', + 'keymessage' : 'webkitkeymessage', + 'needkey' : 'webkitneedkey', + 'pointerlockchange' : 'webkitpointerlockchange', + 'pointerlockerror' : 'webkitpointerlockerror', + 'resourcetimingbufferfull' : 'webkitresourcetimingbufferfull', 'transitionend': 'webkitTransitionEnd', 'speechchange' : 'webkitSpeechChange' }; @@ -8681,7 +8682,7 @@ class HttpRequest extends HttpRequestEventTarget { * * By default `request` will perform an HTTP GET request, but a different * method (`POST`, `PUT`, `DELETE`, etc) can be used by specifying the - * [method] parameter. (See also [HttpRequest.postFormData] for `POST` + * [method] parameter. (See also [HttpRequest.postFormData] for `POST` * requests only. * * The Future is completed when the response is available. @@ -8690,8 +8691,8 @@ class HttpRequest extends HttpRequestEventTarget { * [Blob], [Document], [String], or [FormData] along with the HttpRequest. * * If specified, [responseType] sets the desired response format for the - * request. By default it is [String], but can also be 'arraybuffer', 'blob', - * 'document', 'json', or 'text'. See also [HttpRequest.responseType] + * request. By default it is [String], but can also be 'arraybuffer', 'blob', + * 'document', 'json', or 'text'. See also [HttpRequest.responseType] * for more information. * * The [withCredentials] parameter specified that credentials such as a cookie @@ -8774,7 +8775,7 @@ class HttpRequest extends HttpRequestEventTarget { // redirect case will be handled by the browser before it gets to us, // so if we see it we should pass it through to the user. var unknownRedirect = xhr.status > 307 && xhr.status < 400; - + if (accepted || fileUri || notModified || unknownRedirect) { completer.complete(xhr); } else { @@ -10634,15 +10635,15 @@ abstract class ButtonInputElement implements InputElementBase { @Native("KeyboardEvent") class KeyboardEvent extends UIEvent { - /** - * Programmatically create a KeyboardEvent. + /** + * Programmatically create a KeyboardEvent. * * Due to browser differences, keyCode, charCode, or keyIdentifier values * cannot be specified in this base level constructor. This constructor * enables the user to programmatically create and dispatch a [KeyboardEvent], * but it will not contain any particular key content. For programmatically * creating keyboard events with specific key value contents, see the custom - * Event [KeyEvent]. + * Event [KeyEvent]. */ factory KeyboardEvent(String type, {Window view, bool canBubble: true, bool cancelable: true, @@ -18577,7 +18578,7 @@ class FixedSizeListIterator implements Iterator { final int _length; // Cache array length for faster access. int _position; T _current; - + FixedSizeListIterator(List array) : _array = array, _position = -1, @@ -19036,14 +19037,13 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent { // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - class Platform { /** * Returns true if dart:typed_data types are supported on this * browser. If false, using these types will generate a runtime * error. */ - static final supportsTypedData = JS('bool', '!!(window.ArrayBuffer)'); + static final supportsTypedData = JS('bool', '!!($global_.ArrayBuffer)'); /** * Returns true if SIMD types in dart:typed_data types are supported @@ -19555,7 +19555,8 @@ export 'dart:math' show Rectangle, Point; * * * [Window](https://developer.mozilla.org/en-US/docs/Web/API/window) from MDN. */ -Window get window => wrap_jso(JS('', 'window')); + +final Window window = wrap_jso(JS('', '$global_')); /** * Root node for all content in a web page. @@ -19798,4 +19799,3 @@ Function _getHtmlFunction(String key) { } return null; } - diff --git a/pkg/dev_compiler/tool/input_sdk/lib/html/html_common/html_common_ddc.dart b/pkg/dev_compiler/tool/input_sdk/lib/html/html_common/html_common_ddc.dart index 33ea63035091..51b9b9137811 100644 --- a/pkg/dev_compiler/tool/input_sdk/lib/html/html_common/html_common_ddc.dart +++ b/pkg/dev_compiler/tool/input_sdk/lib/html/html_common/html_common_ddc.dart @@ -23,4 +23,3 @@ part 'conversions_dart2js.dart'; part 'device.dart'; part 'filtered_element_list.dart'; part 'lists.dart'; - diff --git a/pkg/dev_compiler/tool/input_sdk/private/debugger.dart b/pkg/dev_compiler/tool/input_sdk/private/debugger.dart index 88ad1ae55069..2a8a877824da 100644 --- a/pkg/dev_compiler/tool/input_sdk/private/debugger.dart +++ b/pkg/dev_compiler/tool/input_sdk/private/debugger.dart @@ -18,8 +18,8 @@ final int maxIterableChildrenToDisplay = 50; var _devtoolsFormatter = new JsonMLFormatter(new DartFormatter()); -String typeof(object) => JS('String', 'typeof #', object); -bool instanceof(object, clazz) => JS('bool', '# instanceof #', object, clazz); +String _typeof(object) => JS('String', 'typeof #', object); +bool _instanceof(object, clazz) => JS('bool', '# instanceof #', object, clazz); List getOwnPropertyNames(object) => dart.list(JS('List', 'Object.getOwnPropertyNames(#)', object), String); @@ -37,14 +37,14 @@ class JSNative { } bool isRegularDartObject(object) { - if (typeof(object) == 'function') return false; - return instanceof(object, Object); + if (_typeof(object) == 'function') return false; + return _instanceof(object, Object); } String getObjectTypeName(object) { var realRuntimeType = dart.realRuntimeType(object); if (realRuntimeType == null) { - if (typeof(object) == 'function') { + if (_typeof(object) == 'function') { return '[[Raw JavaScript Function]]'; } return ''; @@ -209,8 +209,8 @@ class JsonMLFormatter { var nameSpan = new JsonMLElement('span') ..createTextChild(child.name != null ? child.name + ': ' : '') ..setStyle('color: rgb(136, 19, 145);'); - if (typeof(child.value) == 'object' || - typeof(child.value) == 'function') { + if (_typeof(child.value) == 'object' || + _typeof(child.value) == 'function') { nameSpan.addStyle("padding-left: 13px;"); li.appendChild(nameSpan); @@ -356,7 +356,7 @@ class ObjectFormatter extends Formatter { /// runtime type information. class FunctionFormatter extends Formatter { accept(object) { - if (typeof(object) != 'function') return false; + if (_typeof(object) != 'function') return false; return dart.realRuntimeType(object) != null; } diff --git a/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart b/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart index 41b9cbd5c38b..7b4647fc3486 100644 --- a/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart +++ b/pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart @@ -25,7 +25,6 @@ TypeMirror reflectType(Type key) { } final dynamic _dart = JS('', 'dart'); -final _metadata = JS('', '#.metadata', _dart); dynamic _dload(obj, String name) { return JS('', '#.dload(#, #)', _dart, obj, name); diff --git a/pkg/dev_compiler/tool/input_sdk/private/runtime.dart b/pkg/dev_compiler/tool/input_sdk/private/runtime.dart index 7035270b740c..061218b484e2 100644 --- a/pkg/dev_compiler/tool/input_sdk/private/runtime.dart +++ b/pkg/dev_compiler/tool/input_sdk/private/runtime.dart @@ -31,7 +31,8 @@ final as_ = JS('', '$cast'); @JSExportName('is') final is_ = JS('', '$instanceOf'); -final global = JS('', 'typeof window == "undefined" ? global : window'); +@JSExportName('global') +final global_ = JS('', 'typeof window == "undefined" ? global : window'); final JsSymbol = JS('', 'Symbol'); // TODO(vsm): This is referenced (as init.globalState) from diff --git a/pkg/dev_compiler/tool/input_sdk/private/types.dart b/pkg/dev_compiler/tool/input_sdk/private/types.dart index d74be7190782..f825850dcf36 100644 --- a/pkg/dev_compiler/tool/input_sdk/private/types.dart +++ b/pkg/dev_compiler/tool/input_sdk/private/types.dart @@ -57,7 +57,6 @@ final Void = JS('', ''' toString() { return "void"; } } '''); - @JSExportName('void') final voidR = JS('', 'new $Void()'); diff --git a/pkg/dev_compiler/tool/node_test.sh b/pkg/dev_compiler/tool/node_test.sh new file mode 100755 index 000000000000..4adc07d58061 --- /dev/null +++ b/pkg/dev_compiler/tool/node_test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e +# switch to the root directory of dev_compiler +cd $( dirname "${BASH_SOURCE[0]}" )/.. + +output_dir=tmp/node +[[ -d $output_dir ]] || mkdir -p $output_dir + +ddc_options=( + --destructure-named-params + --modules=node + -o $output_dir +) +node_harmony_options=( + --harmony + --harmony_destructuring + --harmony_default_parameters +) +function compile() { + ./bin/dartdevc.dart "${ddc_options[@]}" $1 +} +function run() { + NODE_PATH=$output_dir \ + node "${node_harmony_options[@]}" -e \ + "require('dart/_isolate_helper').startRootIsolate(require('$1').main, []);" +} + +# TODO(ochafik): Add full language tests (in separate Travis env/matrix config). + +echo "Compiling SDK for node to $output_dir" +./tool/build_sdk.sh "${ddc_options[@]}" + +echo "Now compiling hello_dart_test" +compile test/codegen/language/hello_dart_test.dart +run hello_dart_test + +echo "Now compiling DeltaBlue" +compile test/codegen/DeltaBlue.dart +run DeltaBlue diff --git a/pkg/dev_compiler/tool/presubmit.sh b/pkg/dev_compiler/tool/presubmit.sh index 880ad50dc8f8..54308c101caa 100755 --- a/pkg/dev_compiler/tool/presubmit.sh +++ b/pkg/dev_compiler/tool/presubmit.sh @@ -4,5 +4,6 @@ DIR=$(dirname "${BASH_SOURCE[0]}") $DIR/build_sdk.sh $DIR/test.sh $DIR/browser_test.sh +$DIR/node_test.sh $DIR/analyze.sh $DIR/format.sh diff --git a/pkg/dev_compiler/tool/sdk_expected_errors.txt b/pkg/dev_compiler/tool/sdk_expected_errors.txt index f8bd7e283c97..216c9f13b649 100644 --- a/pkg/dev_compiler/tool/sdk_expected_errors.txt +++ b/pkg/dev_compiler/tool/sdk_expected_errors.txt @@ -276,22 +276,22 @@ warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from (dynamic) → dynamic warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:js, line 359, col 12) warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:js, line 405, col 12) warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:js, line 410, col 12) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:_js_mirrors, line 127, col 31) -severe: [AnalyzerMessage] The setter 'classes' is not defined for the class 'Node' (dart:html, line 5561, col 32) -severe: [AnalyzerMessage] The method '_registerCustomElement' is not defined for the class 'HtmlDocument' (dart:html, line 8468, col 5) -severe: [AnalyzerMessage] 14 positional arguments expected, but 18 found (dart:html, line 11030, col 185) -severe: [AnalyzerMessage] The getter 'name' is not defined for the class 'Node' (dart:html, line 14662, col 32) -severe: [AnalyzerMessage] The getter 'value' is not defined for the class 'Node' (dart:html, line 14674, col 34) -severe: [INVALID_FIELD_OVERRIDE] Field declaration MutableRectangle.left cannot be overridden in CssRect. (dart:html, line 15349, col 3) -severe: [INVALID_FIELD_OVERRIDE] Field declaration MutableRectangle.top cannot be overridden in CssRect. (dart:html, line 15351, col 3) -severe: [AnalyzerMessage] The method 'matchesWithAncestors' is not defined for the class 'EventTarget' (dart:html, line 15948, col 31) -severe: [AnalyzerMessage] The method 'matchesWithAncestors' is not defined for the class 'EventTarget' (dart:html, line 15972, col 31) -severe: [AnalyzerMessage] Missing concrete implementation of 'EventTarget._addEventListener_1', 'EventTarget._removeEventListener_3', 'EventTarget._removeEventListener_1', 'EventTarget._removeEventListener_2' and 7 more (dart:html, line 18681, col 7) -severe: [AnalyzerMessage] Missing concrete implementation of 'KeyboardEvent._getModifierState_1', 'Event._stopImmediatePropagation_1', setter 'DartHtmlDomObject.raw', 'Event._preventDefault_1' and 4 more (dart:html, line 18829, col 7) -severe: [AnalyzerMessage] The method 'makeLeafDispatchRecord' is not defined for the class 'KeyEvent' (dart:html, line 18875, col 12) -severe: [AnalyzerMessage] The method 'setDispatchProperty' is not defined for the class 'KeyEvent' (dart:html, line 18945, col 5) -severe: [AnalyzerMessage] Undefined class 'DataTransfer' (dart:html, line 18989, col 3) -severe: [AnalyzerMessage] The getter 'clipboardData' is not defined for the class 'KeyboardEvent' (dart:html, line 18989, col 45) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:_js_mirrors, line 126, col 31) +severe: [AnalyzerMessage] The setter 'classes' is not defined for the class 'Node' (dart:html, line 5562, col 32) +severe: [AnalyzerMessage] The method '_registerCustomElement' is not defined for the class 'HtmlDocument' (dart:html, line 8469, col 5) +severe: [AnalyzerMessage] 14 positional arguments expected, but 18 found (dart:html, line 11031, col 185) +severe: [AnalyzerMessage] The getter 'name' is not defined for the class 'Node' (dart:html, line 14663, col 32) +severe: [AnalyzerMessage] The getter 'value' is not defined for the class 'Node' (dart:html, line 14675, col 34) +severe: [INVALID_FIELD_OVERRIDE] Field declaration MutableRectangle.left cannot be overridden in CssRect. (dart:html, line 15350, col 3) +severe: [INVALID_FIELD_OVERRIDE] Field declaration MutableRectangle.top cannot be overridden in CssRect. (dart:html, line 15352, col 3) +severe: [AnalyzerMessage] The method 'matchesWithAncestors' is not defined for the class 'EventTarget' (dart:html, line 15949, col 31) +severe: [AnalyzerMessage] The method 'matchesWithAncestors' is not defined for the class 'EventTarget' (dart:html, line 15973, col 31) +severe: [AnalyzerMessage] Missing concrete implementation of 'EventTarget._addEventListener_1', 'EventTarget._removeEventListener_3', 'EventTarget._removeEventListener_1', 'EventTarget._removeEventListener_2' and 7 more (dart:html, line 18682, col 7) +severe: [AnalyzerMessage] Missing concrete implementation of 'KeyboardEvent._getModifierState_1', 'Event._stopImmediatePropagation_1', setter 'DartHtmlDomObject.raw', 'Event._preventDefault_1' and 4 more (dart:html, line 18830, col 7) +severe: [AnalyzerMessage] The method 'makeLeafDispatchRecord' is not defined for the class 'KeyEvent' (dart:html, line 18876, col 12) +severe: [AnalyzerMessage] The method 'setDispatchProperty' is not defined for the class 'KeyEvent' (dart:html, line 18946, col 5) +severe: [AnalyzerMessage] Undefined class 'DataTransfer' (dart:html, line 18990, col 3) +severe: [AnalyzerMessage] The getter 'clipboardData' is not defined for the class 'KeyboardEvent' (dart:html, line 18990, col 45) severe: [AnalyzerMessage] Missing concrete implementation of getter 'DartHtmlDomObject.raw', 'Event._initEvent_1', 'Event._stopImmediatePropagation_1', setter 'DartHtmlDomObject.raw' and 2 more (dart:html, line 19063, col 7) severe: [AnalyzerMessage] Undefined class 'DataTransfer' (dart:html, line 19075, col 3) severe: [AnalyzerMessage] The getter 'clipboardData' is not defined for the class 'Event' (dart:html, line 19075, col 45) @@ -299,12 +299,12 @@ severe: [AnalyzerMessage] The method 'matches' is not defined for the class 'Eve severe: [AnalyzerMessage] The getter 'parent' is not defined for the class 'EventTarget' (dart:html, line 19122, col 23) severe: [AnalyzerMessage] The getter 'parent' is not defined for the class 'EventTarget' (dart:html, line 19123, col 56) severe: [AnalyzerMessage] Directives must appear before any declarations (dart:html, line 19526, col 1) -severe: [AnalyzerMessage] The name 'Entry' is not a type and cannot be used as a parameterized type (dart:html, line 19592, col 44) -severe: [AnalyzerMessage] Expected to find ';' (dart:html, line 19643, col 48) -severe: [AnalyzerMessage] Undefined name 'console' (dart:html, line 19658, col 5) -severe: [AnalyzerMessage] Undefined name 'js' (dart:html, line 19675, col 21) -severe: [AnalyzerMessage] Undefined name 'js' (dart:html, line 19676, col 23) -severe: [AnalyzerMessage] Undefined name 'js' (dart:html, line 19677, col 20) +severe: [AnalyzerMessage] The name 'Entry' is not a type and cannot be used as a parameterized type (dart:html, line 19593, col 44) +severe: [AnalyzerMessage] Expected to find ';' (dart:html, line 19644, col 48) +severe: [AnalyzerMessage] Undefined name 'console' (dart:html, line 19659, col 5) +severe: [AnalyzerMessage] Undefined name 'js' (dart:html, line 19676, col 21) +severe: [AnalyzerMessage] Undefined name 'js' (dart:html, line 19677, col 23) +severe: [AnalyzerMessage] Undefined name 'js' (dart:html, line 19678, col 20) severe: [AnalyzerMessage] The name 'File' is not defined and cannot be used in an 'is' expression (dart:html_common/conversions.dart, line 103, col 14) severe: [AnalyzerMessage] The name 'Blob' is not defined and cannot be used in an 'is' expression (dart:html_common/conversions.dart, line 104, col 14) severe: [AnalyzerMessage] The name 'FileList' is not defined and cannot be used in an 'is' expression (dart:html_common/conversions.dart, line 105, col 14) @@ -326,41 +326,41 @@ severe: [INVALID_METHOD_OVERRIDE] Invalid override. The type of CssClassSetImpl. severe: [INVALID_METHOD_OVERRIDE] Invalid override. The type of CssClassSetImpl.difference ((Set) → Set) is not a subtype of Set.difference ((Set) → Set). (dart:html_common/css_class_set.dart, line 186, col 3) severe: [AnalyzerMessage] The argument type 'List' cannot be assigned to the parameter type 'Iterable' (dart:html_common/filtered_element_list.dart, line 34, col 25) severe: [STATIC_TYPE_ERROR] Type check failed: _childNodes (List) is not of type Iterable (dart:html_common/filtered_element_list.dart, line 34, col 25) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to Iterable (dart:html, line 839, col 46) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 4631, col 31) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (dart:html, line 4876, col 21) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from (dynamic) → bool to (Element) → bool (dart:html, line 5272, col 41) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (dart:html, line 5895, col 21) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 7421, col 31) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 7723, col 26) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Future to Future (dart:html, line 8839, col 14) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 9760, col 28) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (dart:html, line 11357, col 23) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 11439, col 32) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 11961, col 31) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 11969, col 53) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to (num) → void (dart:html, line 13026, col 35) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15200, col 32) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15203, col 32) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 15256, col 20) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15290, col 32) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15292, col 32) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15322, col 32) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15324, col 55) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from ElementList to Iterable (dart:html, line 15869, col 44) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Stream to Stream (dart:html, line 15947, col 41) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Stream to Stream (dart:html, line 15971, col 41) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from StreamSubscription to StreamSubscription (dart:html, line 15986, col 12) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from StreamSubscription to StreamSubscription (dart:html, line 15995, col 12) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to (Event) → dynamic (dart:html, line 16065, col 44) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to (Event) → dynamic (dart:html, line 16071, col 47) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from ElementList to Iterable (dart:html, line 16215, col 44) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to Iterable (dart:html, line 18136, col 9) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Iterable to Iterable (dart:html, line 840, col 46) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 4632, col 31) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (dart:html, line 4877, col 21) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from (dynamic) → bool to (Element) → bool (dart:html, line 5273, col 41) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (dart:html, line 5896, col 21) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 7422, col 31) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 7724, col 26) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Future to Future (dart:html, line 8840, col 14) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 9761, col 28) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to Iterable (dart:html, line 11358, col 23) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 11440, col 32) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 11962, col 31) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 11970, col 53) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to (num) → void (dart:html, line 13027, col 35) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15201, col 32) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15204, col 32) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to List (dart:html, line 15257, col 20) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15291, col 32) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15293, col 32) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15323, col 32) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 15325, col 55) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from ElementList to Iterable (dart:html, line 15870, col 44) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Stream to Stream (dart:html, line 15948, col 41) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from Stream to Stream (dart:html, line 15972, col 41) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from StreamSubscription to StreamSubscription (dart:html, line 15987, col 12) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from StreamSubscription to StreamSubscription (dart:html, line 15996, col 12) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to (Event) → dynamic (dart:html, line 16066, col 44) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to (Event) → dynamic (dart:html, line 16072, col 47) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from ElementList to Iterable (dart:html, line 16216, col 44) warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to Iterable (dart:html, line 18137, col 9) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to Iterable (dart:html, line 18174, col 9) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to Iterable (dart:html, line 18138, col 9) warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to Iterable (dart:html, line 18175, col 9) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:html, line 18495, col 31) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:html, line 18509, col 28) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 18525, col 29) -warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:html, line 18540, col 20) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to Iterable (dart:html, line 18176, col 9) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:html, line 18496, col 31) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:html, line 18510, col 28) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from List to List (dart:html, line 18526, col 29) +warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from dynamic to E (dart:html, line 18541, col 20) warning: [DOWN_CAST_COMPOSITE] Unsound implicit cast from (String) → String to (Object) → String (dart:html_common/css_class_set.dart, line 148, col 44)