Version 1.21.0-dev.11.2
Cherry-pick 201c5b9297e5b701d4ee03ac42e6325629baf73c into dev
Cherry-pick ec81359fc0cfeebe4faf8e91db04ed4b4c7c9685 into dev
Cherry-pick 106c623a9f39cc56b4a16b166158e83cef12bd23 into dev
Cherry-pick 6bf86eacd7db5a4c183ec4ba006587c6d079c94d into dev
Cherry-pick 40bf5d321ea22fd9813d344ca2a0b06de5ec9784 into dev
Cherry-pick 2812738546a2ff499c2a1667e9c73786704b7732 into dev
Cherry-pick f2907070d87f2639b029730a8ca2a92b2ac26068 into dev
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32c3172..b90703a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
### Language
+* Support generic method syntax. Type arguments are not available at
+ runtime. For details, check the
+ [informal specification](https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c).
+* Support access to initializing formals, e.g., the use of `x` to initialize
+ `y` in `class C { var x, y; C(this.x): y = x; }`.
+ Please check the
+ [informal specification](https://gist.github.com/eernstg/cff159be9e34d5ea295d8c24b1a3e594)
+ for details.
* Don't warn about switch case fallthrough if the case ends in a `rethrow`
statement.
* Also don't warn if the entire switch case is wrapped in braces - as long as
diff --git a/pkg/compiler/lib/src/parser/parser.dart b/pkg/compiler/lib/src/parser/parser.dart
index 8d6f580..e39ce38 100644
--- a/pkg/compiler/lib/src/parser/parser.dart
+++ b/pkg/compiler/lib/src/parser/parser.dart
@@ -577,7 +577,7 @@
/// Returns token after match if [token] matches identifier ('.' identifier)?,
/// and otherwise returns null. Does not produce listener events.
Token tryParseQualified(Token token) {
- if (!identical(token.kind, IDENTIFIER_TOKEN)) return null;
+ if (!isValidTypeReference(token)) return null;
token = token.next;
if (!identical(token.kind, PERIOD_TOKEN)) return token;
token = token.next;
diff --git a/pkg/dev_compiler/lib/js/amd/dart_sdk.js b/pkg/dev_compiler/lib/js/amd/dart_sdk.js
index 9935e21..abb592c 100644
--- a/pkg/dev_compiler/lib/js/amd/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/amd/dart_sdk.js
@@ -1210,10 +1210,20 @@
dart.tagLazy = function(value, compute) {
dart.defineLazyProperty(value, dart._runtimeType, {get: compute});
};
+ dart._warn = function(arg) {
+ console.warn(arg);
+ };
const _jsTypeCallback = Symbol('_jsTypeCallback');
const _rawJSType = Symbol('_rawJSType');
+ const _dartName = Symbol('_dartName');
dart._isInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return true;
+ }
return dart.is(o, t[_rawJSType]);
}
if (o == null) return false;
@@ -1221,6 +1231,12 @@
};
dart._asInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return o;
+ }
return dart.as(o, t[_rawJSType]);
}
if (o == null) return null;
@@ -1255,6 +1271,9 @@
dart.LazyJSType.prototype.as = function as_T(object) {
return dart._asInstanceOfLazyJSType(object, this);
};
+ dart.LazyJSType.prototype._check = function check_T(object) {
+ return dart._asInstanceOfLazyJSType(object, this);
+ };
};
dart._functionType = function(definite, returnType, args, extra) {
if (args === void 0 && extra === void 0) {
@@ -2217,7 +2236,6 @@
return 'dynamic';
}
};
- const _dartName = Symbol('_dartName');
dart.LazyJSType = class LazyJSType extends core.Object {
new(jsTypeCallback, dartName) {
this[_jsTypeCallback] = jsTypeCallback;
@@ -5627,6 +5645,7 @@
});
_internal.POWERS_OF_TEN = dart.constList([1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0, 1e+21, 1e+22], core.double);
const _string = Symbol('_string');
+ const _filter = Symbol('_filter');
collection.ListMixin$ = dart.generic(E => {
let ListIteratorOfE = () => (ListIteratorOfE = dart.constFn(_internal.ListIterator$(E)))();
let VoidToE = () => (VoidToE = dart.constFn(dart.functionType(E, [])))();
@@ -5638,6 +5657,7 @@
let ListOfE = () => (ListOfE = dart.constFn(core.List$(E)))();
let SetOfE = () => (SetOfE = dart.constFn(core.Set$(E)))();
let IterableOfE = () => (IterableOfE = dart.constFn(core.Iterable$(E)))();
+ let JSArrayOfE = () => (JSArrayOfE = dart.constFn(_interceptors.JSArray$(E)))();
let ListMapViewOfE = () => (ListMapViewOfE = dart.constFn(_internal.ListMapView$(E)))();
let ReversedListIterableOfE = () => (ReversedListIterableOfE = dart.constFn(_internal.ReversedListIterable$(E)))();
let ETovoid = () => (ETovoid = dart.constFn(dart.functionType(dart.void, [E])))();
@@ -5919,13 +5939,14 @@
return false;
}
removeWhere(test) {
- collection.ListMixin._filter(this, test, false);
+ this[_filter](test, false);
}
retainWhere(test) {
- collection.ListMixin._filter(this, test, true);
+ this[_filter](test, true);
}
- static _filter(source, test, retainMatching) {
- let retained = [];
+ [_filter](test, retainMatching) {
+ let source = this;
+ let retained = JSArrayOfE().of([]);
let length = source[dartx.length];
for (let i = 0; i < dart.notNull(length); i++) {
let element = source[dartx._get](i);
@@ -6187,6 +6208,7 @@
remove: dart.definiteFunctionType(core.bool, [core.Object]),
removeWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
retainWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
+ [_filter]: dart.definiteFunctionType(dart.void, [dynamicTobool(), core.bool]),
clear: dart.definiteFunctionType(dart.void, []),
removeLast: dart.definiteFunctionType(E, []),
sort: dart.definiteFunctionType(dart.void, [], [EAndEToint()]),
@@ -6204,9 +6226,7 @@
removeAt: dart.definiteFunctionType(E, [core.int]),
insertAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()]),
setAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()])
- }),
- statics: () => ({_filter: dart.definiteFunctionType(dart.void, [core.List, dynamicTobool(), core.bool])}),
- names: ['_filter']
+ })
});
dart.defineExtensionMembers(ListMixin, [
'elementAt',
@@ -27090,7 +27110,6 @@
});
collection._DoubleLinkedQueueSentinel = _DoubleLinkedQueueSentinel();
const _sentinel = Symbol('_sentinel');
- const _filter = Symbol('_filter');
collection.DoubleLinkedQueue$ = dart.generic(E => {
let _DoubleLinkedQueueSentinelOfE = () => (_DoubleLinkedQueueSentinelOfE = dart.constFn(collection._DoubleLinkedQueueSentinel$(E)))();
let DoubleLinkedQueueOfE = () => (DoubleLinkedQueueOfE = dart.constFn(collection.DoubleLinkedQueue$(E)))();
diff --git a/pkg/dev_compiler/lib/js/common/dart_sdk.js b/pkg/dev_compiler/lib/js/common/dart_sdk.js
index c053cc4..e025ec5 100644
--- a/pkg/dev_compiler/lib/js/common/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/common/dart_sdk.js
@@ -1210,10 +1210,20 @@
dart.tagLazy = function(value, compute) {
dart.defineLazyProperty(value, dart._runtimeType, {get: compute});
};
+ dart._warn = function(arg) {
+ console.warn(arg);
+ };
const _jsTypeCallback = Symbol('_jsTypeCallback');
const _rawJSType = Symbol('_rawJSType');
+ const _dartName = Symbol('_dartName');
dart._isInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return true;
+ }
return dart.is(o, t[_rawJSType]);
}
if (o == null) return false;
@@ -1221,6 +1231,12 @@
};
dart._asInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return o;
+ }
return dart.as(o, t[_rawJSType]);
}
if (o == null) return null;
@@ -1255,6 +1271,9 @@
dart.LazyJSType.prototype.as = function as_T(object) {
return dart._asInstanceOfLazyJSType(object, this);
};
+ dart.LazyJSType.prototype._check = function check_T(object) {
+ return dart._asInstanceOfLazyJSType(object, this);
+ };
};
dart._functionType = function(definite, returnType, args, extra) {
if (args === void 0 && extra === void 0) {
@@ -2217,7 +2236,6 @@
return 'dynamic';
}
};
- const _dartName = Symbol('_dartName');
dart.LazyJSType = class LazyJSType extends core.Object {
new(jsTypeCallback, dartName) {
this[_jsTypeCallback] = jsTypeCallback;
@@ -5627,6 +5645,7 @@
});
_internal.POWERS_OF_TEN = dart.constList([1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0, 1e+21, 1e+22], core.double);
const _string = Symbol('_string');
+ const _filter = Symbol('_filter');
collection.ListMixin$ = dart.generic(E => {
let ListIteratorOfE = () => (ListIteratorOfE = dart.constFn(_internal.ListIterator$(E)))();
let VoidToE = () => (VoidToE = dart.constFn(dart.functionType(E, [])))();
@@ -5638,6 +5657,7 @@
let ListOfE = () => (ListOfE = dart.constFn(core.List$(E)))();
let SetOfE = () => (SetOfE = dart.constFn(core.Set$(E)))();
let IterableOfE = () => (IterableOfE = dart.constFn(core.Iterable$(E)))();
+ let JSArrayOfE = () => (JSArrayOfE = dart.constFn(_interceptors.JSArray$(E)))();
let ListMapViewOfE = () => (ListMapViewOfE = dart.constFn(_internal.ListMapView$(E)))();
let ReversedListIterableOfE = () => (ReversedListIterableOfE = dart.constFn(_internal.ReversedListIterable$(E)))();
let ETovoid = () => (ETovoid = dart.constFn(dart.functionType(dart.void, [E])))();
@@ -5919,13 +5939,14 @@
return false;
}
removeWhere(test) {
- collection.ListMixin._filter(this, test, false);
+ this[_filter](test, false);
}
retainWhere(test) {
- collection.ListMixin._filter(this, test, true);
+ this[_filter](test, true);
}
- static _filter(source, test, retainMatching) {
- let retained = [];
+ [_filter](test, retainMatching) {
+ let source = this;
+ let retained = JSArrayOfE().of([]);
let length = source[dartx.length];
for (let i = 0; i < dart.notNull(length); i++) {
let element = source[dartx._get](i);
@@ -6187,6 +6208,7 @@
remove: dart.definiteFunctionType(core.bool, [core.Object]),
removeWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
retainWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
+ [_filter]: dart.definiteFunctionType(dart.void, [dynamicTobool(), core.bool]),
clear: dart.definiteFunctionType(dart.void, []),
removeLast: dart.definiteFunctionType(E, []),
sort: dart.definiteFunctionType(dart.void, [], [EAndEToint()]),
@@ -6204,9 +6226,7 @@
removeAt: dart.definiteFunctionType(E, [core.int]),
insertAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()]),
setAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()])
- }),
- statics: () => ({_filter: dart.definiteFunctionType(dart.void, [core.List, dynamicTobool(), core.bool])}),
- names: ['_filter']
+ })
});
dart.defineExtensionMembers(ListMixin, [
'elementAt',
@@ -27090,7 +27110,6 @@
});
collection._DoubleLinkedQueueSentinel = _DoubleLinkedQueueSentinel();
const _sentinel = Symbol('_sentinel');
- const _filter = Symbol('_filter');
collection.DoubleLinkedQueue$ = dart.generic(E => {
let _DoubleLinkedQueueSentinelOfE = () => (_DoubleLinkedQueueSentinelOfE = dart.constFn(collection._DoubleLinkedQueueSentinel$(E)))();
let DoubleLinkedQueueOfE = () => (DoubleLinkedQueueOfE = dart.constFn(collection.DoubleLinkedQueue$(E)))();
diff --git a/pkg/dev_compiler/lib/js/es6/dart_sdk.js b/pkg/dev_compiler/lib/js/es6/dart_sdk.js
index 1092e10..658981b 100644
--- a/pkg/dev_compiler/lib/js/es6/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/es6/dart_sdk.js
@@ -1208,10 +1208,20 @@
dart.tagLazy = function(value, compute) {
dart.defineLazyProperty(value, dart._runtimeType, {get: compute});
};
+dart._warn = function(arg) {
+ console.warn(arg);
+};
const _jsTypeCallback = Symbol('_jsTypeCallback');
const _rawJSType = Symbol('_rawJSType');
+const _dartName = Symbol('_dartName');
dart._isInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return true;
+ }
return dart.is(o, t[_rawJSType]);
}
if (o == null) return false;
@@ -1219,6 +1229,12 @@
};
dart._asInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return o;
+ }
return dart.as(o, t[_rawJSType]);
}
if (o == null) return null;
@@ -1253,6 +1269,9 @@
dart.LazyJSType.prototype.as = function as_T(object) {
return dart._asInstanceOfLazyJSType(object, this);
};
+ dart.LazyJSType.prototype._check = function check_T(object) {
+ return dart._asInstanceOfLazyJSType(object, this);
+ };
};
dart._functionType = function(definite, returnType, args, extra) {
if (args === void 0 && extra === void 0) {
@@ -2215,7 +2234,6 @@
return 'dynamic';
}
};
-const _dartName = Symbol('_dartName');
dart.LazyJSType = class LazyJSType extends core.Object {
new(jsTypeCallback, dartName) {
this[_jsTypeCallback] = jsTypeCallback;
@@ -5625,6 +5643,7 @@
});
_internal.POWERS_OF_TEN = dart.constList([1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0, 1e+21, 1e+22], core.double);
const _string = Symbol('_string');
+const _filter = Symbol('_filter');
collection.ListMixin$ = dart.generic(E => {
let ListIteratorOfE = () => (ListIteratorOfE = dart.constFn(_internal.ListIterator$(E)))();
let VoidToE = () => (VoidToE = dart.constFn(dart.functionType(E, [])))();
@@ -5636,6 +5655,7 @@
let ListOfE = () => (ListOfE = dart.constFn(core.List$(E)))();
let SetOfE = () => (SetOfE = dart.constFn(core.Set$(E)))();
let IterableOfE = () => (IterableOfE = dart.constFn(core.Iterable$(E)))();
+ let JSArrayOfE = () => (JSArrayOfE = dart.constFn(_interceptors.JSArray$(E)))();
let ListMapViewOfE = () => (ListMapViewOfE = dart.constFn(_internal.ListMapView$(E)))();
let ReversedListIterableOfE = () => (ReversedListIterableOfE = dart.constFn(_internal.ReversedListIterable$(E)))();
let ETovoid = () => (ETovoid = dart.constFn(dart.functionType(dart.void, [E])))();
@@ -5917,13 +5937,14 @@
return false;
}
removeWhere(test) {
- collection.ListMixin._filter(this, test, false);
+ this[_filter](test, false);
}
retainWhere(test) {
- collection.ListMixin._filter(this, test, true);
+ this[_filter](test, true);
}
- static _filter(source, test, retainMatching) {
- let retained = [];
+ [_filter](test, retainMatching) {
+ let source = this;
+ let retained = JSArrayOfE().of([]);
let length = source[dartx.length];
for (let i = 0; i < dart.notNull(length); i++) {
let element = source[dartx._get](i);
@@ -6185,6 +6206,7 @@
remove: dart.definiteFunctionType(core.bool, [core.Object]),
removeWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
retainWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
+ [_filter]: dart.definiteFunctionType(dart.void, [dynamicTobool(), core.bool]),
clear: dart.definiteFunctionType(dart.void, []),
removeLast: dart.definiteFunctionType(E, []),
sort: dart.definiteFunctionType(dart.void, [], [EAndEToint()]),
@@ -6202,9 +6224,7 @@
removeAt: dart.definiteFunctionType(E, [core.int]),
insertAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()]),
setAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()])
- }),
- statics: () => ({_filter: dart.definiteFunctionType(dart.void, [core.List, dynamicTobool(), core.bool])}),
- names: ['_filter']
+ })
});
dart.defineExtensionMembers(ListMixin, [
'elementAt',
@@ -27088,7 +27108,6 @@
});
collection._DoubleLinkedQueueSentinel = _DoubleLinkedQueueSentinel();
const _sentinel = Symbol('_sentinel');
-const _filter = Symbol('_filter');
collection.DoubleLinkedQueue$ = dart.generic(E => {
let _DoubleLinkedQueueSentinelOfE = () => (_DoubleLinkedQueueSentinelOfE = dart.constFn(collection._DoubleLinkedQueueSentinel$(E)))();
let DoubleLinkedQueueOfE = () => (DoubleLinkedQueueOfE = dart.constFn(collection.DoubleLinkedQueue$(E)))();
diff --git a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
index 5a352a1..53d7785 100644
--- a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
@@ -1211,10 +1211,20 @@
dart.tagLazy = function(value, compute) {
dart.defineLazyProperty(value, dart._runtimeType, {get: compute});
};
+ dart._warn = function(arg) {
+ console.warn(arg);
+ };
const _jsTypeCallback = Symbol('_jsTypeCallback');
const _rawJSType = Symbol('_rawJSType');
+ const _dartName = Symbol('_dartName');
dart._isInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return true;
+ }
return dart.is(o, t[_rawJSType]);
}
if (o == null) return false;
@@ -1222,6 +1232,12 @@
};
dart._asInstanceOfLazyJSType = function(o, t) {
if (t[_jsTypeCallback] != null) {
+ if (t[_rawJSType] == null) {
+ let expected = t[_dartName];
+ let actual = dart.typeName(dart.getReifiedType(o));
+ dart._warn(dart.str`Cannot find native JavaScript type (${expected}) ` + dart.str`to type check ${actual}`);
+ return o;
+ }
return dart.as(o, t[_rawJSType]);
}
if (o == null) return null;
@@ -1256,6 +1272,9 @@
dart.LazyJSType.prototype.as = function as_T(object) {
return dart._asInstanceOfLazyJSType(object, this);
};
+ dart.LazyJSType.prototype._check = function check_T(object) {
+ return dart._asInstanceOfLazyJSType(object, this);
+ };
};
dart._functionType = function(definite, returnType, args, extra) {
if (args === void 0 && extra === void 0) {
@@ -2218,7 +2237,6 @@
return 'dynamic';
}
};
- const _dartName = Symbol('_dartName');
dart.LazyJSType = class LazyJSType extends core.Object {
new(jsTypeCallback, dartName) {
this[_jsTypeCallback] = jsTypeCallback;
@@ -5628,6 +5646,7 @@
});
_internal.POWERS_OF_TEN = dart.constList([1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0, 1e+21, 1e+22], core.double);
const _string = Symbol('_string');
+ const _filter = Symbol('_filter');
collection.ListMixin$ = dart.generic(E => {
let ListIteratorOfE = () => (ListIteratorOfE = dart.constFn(_internal.ListIterator$(E)))();
let VoidToE = () => (VoidToE = dart.constFn(dart.functionType(E, [])))();
@@ -5639,6 +5658,7 @@
let ListOfE = () => (ListOfE = dart.constFn(core.List$(E)))();
let SetOfE = () => (SetOfE = dart.constFn(core.Set$(E)))();
let IterableOfE = () => (IterableOfE = dart.constFn(core.Iterable$(E)))();
+ let JSArrayOfE = () => (JSArrayOfE = dart.constFn(_interceptors.JSArray$(E)))();
let ListMapViewOfE = () => (ListMapViewOfE = dart.constFn(_internal.ListMapView$(E)))();
let ReversedListIterableOfE = () => (ReversedListIterableOfE = dart.constFn(_internal.ReversedListIterable$(E)))();
let ETovoid = () => (ETovoid = dart.constFn(dart.functionType(dart.void, [E])))();
@@ -5920,13 +5940,14 @@
return false;
}
removeWhere(test) {
- collection.ListMixin._filter(this, test, false);
+ this[_filter](test, false);
}
retainWhere(test) {
- collection.ListMixin._filter(this, test, true);
+ this[_filter](test, true);
}
- static _filter(source, test, retainMatching) {
- let retained = [];
+ [_filter](test, retainMatching) {
+ let source = this;
+ let retained = JSArrayOfE().of([]);
let length = source[dartx.length];
for (let i = 0; i < dart.notNull(length); i++) {
let element = source[dartx._get](i);
@@ -6188,6 +6209,7 @@
remove: dart.definiteFunctionType(core.bool, [core.Object]),
removeWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
retainWhere: dart.definiteFunctionType(dart.void, [ETobool()]),
+ [_filter]: dart.definiteFunctionType(dart.void, [dynamicTobool(), core.bool]),
clear: dart.definiteFunctionType(dart.void, []),
removeLast: dart.definiteFunctionType(E, []),
sort: dart.definiteFunctionType(dart.void, [], [EAndEToint()]),
@@ -6205,9 +6227,7 @@
removeAt: dart.definiteFunctionType(E, [core.int]),
insertAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()]),
setAll: dart.definiteFunctionType(dart.void, [core.int, IterableOfE()])
- }),
- statics: () => ({_filter: dart.definiteFunctionType(dart.void, [core.List, dynamicTobool(), core.bool])}),
- names: ['_filter']
+ })
});
dart.defineExtensionMembers(ListMixin, [
'elementAt',
@@ -27091,7 +27111,6 @@
});
collection._DoubleLinkedQueueSentinel = _DoubleLinkedQueueSentinel();
const _sentinel = Symbol('_sentinel');
- const _filter = Symbol('_filter');
collection.DoubleLinkedQueue$ = dart.generic(E => {
let _DoubleLinkedQueueSentinelOfE = () => (_DoubleLinkedQueueSentinelOfE = dart.constFn(collection._DoubleLinkedQueueSentinel$(E)))();
let DoubleLinkedQueueOfE = () => (DoubleLinkedQueueOfE = dart.constFn(collection.DoubleLinkedQueue$(E)))();
diff --git a/pkg/dev_compiler/lib/sdk/ddc_sdk.sum b/pkg/dev_compiler/lib/sdk/ddc_sdk.sum
index 5c8c4f1..6286c3e 100644
--- a/pkg/dev_compiler/lib/sdk/ddc_sdk.sum
+++ b/pkg/dev_compiler/lib/sdk/ddc_sdk.sum
Binary files differ
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 0bbe9ed..1d36734 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -3395,7 +3395,7 @@
if (targetType is FunctionType) {
// Call methods on function types should be handled as regular function
// invocations.
- return _emitFunctionCall(node);
+ return _emitFunctionCall(node, node.target);
}
if (targetType.isDartCoreFunction || targetType.isDynamic) {
// TODO(vsm): Can a call method take generic type parameters?
@@ -3542,10 +3542,14 @@
/// Emits a function call, to a top-level function, local function, or
/// an expression.
- JS.Expression _emitFunctionCall(InvocationExpression node) {
- var fn = _visit(node.function);
+ JS.Expression _emitFunctionCall(InvocationExpression node,
+ [Expression function]) {
+ if (function == null) {
+ function = node.function;
+ }
+ var fn = _visit(function);
var args = _visit(node.argumentList) as List<JS.Expression>;
- if (isDynamicInvoke(node.function)) {
+ if (isDynamicInvoke(function)) {
return _emitDynamicInvoke(node, fn, args);
} else {
return new JS.Call(_applyInvokeTypeArguments(fn, node), args);
diff --git a/pkg/dev_compiler/test/browser/language_tests.js b/pkg/dev_compiler/test/browser/language_tests.js
index af33d47..6cf5f8f 100644
--- a/pkg/dev_compiler/test/browser/language_tests.js
+++ b/pkg/dev_compiler/test/browser/language_tests.js
@@ -402,6 +402,9 @@
'UC16_test': firefox_fail,
},
+ 'lib/collection': {
+ },
+
'lib/convert': {
'encoding_test': skip_timeout,
diff --git a/pkg/dev_compiler/test/codegen/language/call_function2_test.dart b/pkg/dev_compiler/test/codegen/language/call_function2_test.dart
new file mode 100644
index 0000000..f9a610d
--- /dev/null
+++ b/pkg/dev_compiler/test/codegen/language/call_function2_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+import "package:expect/expect.dart";
+
+typedef Object Func(Object x);
+
+class Bar {
+ int x = 42;
+
+ Object call(Object x) {
+ return 'Bar $x';
+ }
+}
+
+Object baz(Object x) => x;
+
+var map = <String, Func>{
+ 'baz': baz,
+ 'bar': new Bar()
+};
+
+Object test(String str, Object arg) {
+ return map[str].call(arg);
+}
+
+void main() {
+ Expect.equals(42, test('baz', 42));
+ Expect.equals('Bar 42', test('bar', 42));
+}
\ No newline at end of file
diff --git a/pkg/dev_compiler/test/codegen/lib/collection/list_test.dart b/pkg/dev_compiler/test/codegen/lib/collection/list_test.dart
new file mode 100644
index 0000000..76cd515
--- /dev/null
+++ b/pkg/dev_compiler/test/codegen/lib/collection/list_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+import 'dart:collection';
+import "package:expect/expect.dart";
+
+class MyList<E> extends Object with ListMixin<E> implements List<E> {
+ List<E> _list;
+
+ MyList(List<E> this._list);
+
+ int get length => _list.length;
+
+ void set length(int x) {
+ _list.length = x;
+ }
+
+ E operator[](int idx) => _list[idx];
+
+ void operator[]=(int idx, E value) {
+ _list[idx] = value;
+ }
+}
+
+void testRetainWhere() {
+ List<int> list = <int>[1, 2, 3];
+ list.retainWhere((x) => x % 2 == 0);
+ Expect.equals(1, list.length);
+ Expect.equals(2, list.first);
+
+ list = new MyList<int>([1, 2, 3]);
+ list.retainWhere((x) => x % 2 == 0);
+ Expect.equals(1, list.length);
+ Expect.equals(2, list.first);
+}
+
+void main() {
+ testRetainWhere();
+}
diff --git a/pkg/dev_compiler/test/codegen_test.dart b/pkg/dev_compiler/test/codegen_test.dart
index b0a74ae..4df5f64 100644
--- a/pkg/dev_compiler/test/codegen_test.dart
+++ b/pkg/dev_compiler/test/codegen_test.dart
@@ -85,6 +85,7 @@
'language',
'corelib',
path.join('corelib', 'regexp'),
+ path.join('lib', 'collection'),
path.join('lib', 'convert'),
path.join('lib', 'html'),
// TODO(vsm): Fix these - they import files from a different directory
diff --git a/pkg/dev_compiler/tool/input_sdk/lib/collection/list.dart b/pkg/dev_compiler/tool/input_sdk/lib/collection/list.dart
index 37fdf0a..f999447 100644
--- a/pkg/dev_compiler/tool/input_sdk/lib/collection/list.dart
+++ b/pkg/dev_compiler/tool/input_sdk/lib/collection/list.dart
@@ -267,17 +267,16 @@
}
void removeWhere(bool test(E element)) {
- _filter(this, test, false);
+ _filter(test, false);
}
void retainWhere(bool test(E element)) {
- _filter(this, test, true);
+ _filter(test, true);
}
- static void _filter(List source,
- bool test(var element),
- bool retainMatching) {
- List retained = [];
+ void _filter(bool test(var element), bool retainMatching) {
+ var source = this;
+ var retained = <E>[];
int length = source.length;
for (int i = 0; i < length; i++) {
var element = source[i];
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
index 91a4ea8..4d402db 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
@@ -77,8 +77,19 @@
toString() => _jsTypeCallback != null ? typeName(_rawJSType) : _dartName;
}
+void _warn(arg) {
+ JS('void', 'console.warn(#)', arg);
+}
+
_isInstanceOfLazyJSType(o, LazyJSType t) {
if (t._jsTypeCallback != null) {
+ if (t._rawJSType == null) {
+ var expected = t._dartName;
+ var actual = typeName(getReifiedType(o));
+ _warn('Cannot find native JavaScript type ($expected) '
+ 'to type check $actual');
+ return true;
+ }
return JS('bool', 'dart.is(#, #)', o, t._rawJSType);
}
if (o == null) return false;
@@ -88,6 +99,13 @@
_asInstanceOfLazyJSType(o, LazyJSType t) {
if (t._jsTypeCallback != null) {
+ if (t._rawJSType == null) {
+ var expected = t._dartName;
+ var actual = typeName(getReifiedType(o));
+ _warn('Cannot find native JavaScript type ($expected) '
+ 'to type check $actual');
+ return o;
+ }
return JS('bool', 'dart.as(#, #)', o, t._rawJSType);
}
// Anonymous case: allow any JS type.
@@ -134,6 +152,9 @@
$LazyJSType.prototype.as = function as_T(object) {
return $_asInstanceOfLazyJSType(object, this);
};
+ $LazyJSType.prototype._check = function check_T(object) {
+ return $_asInstanceOfLazyJSType(object, this);
+ };
})()''');
class Void extends TypeRep {
diff --git a/runtime/lib/developer.cc b/runtime/lib/developer.cc
index 5d6027b..e2f5a1b 100644
--- a/runtime/lib/developer.cc
+++ b/runtime/lib/developer.cc
@@ -172,4 +172,16 @@
#endif
}
+
+DEFINE_NATIVE_ENTRY(Developer_getIsolateIDFromSendPort, 1) {
+#if defined(PRODUCT)
+ return Object::null();
+#else
+ GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
+ int64_t port_id = port.Id();
+ return String::NewFormatted(ISOLATE_SERVICE_ID_FORMAT_STRING, port_id);
+#endif
+}
+
+
} // namespace dart
diff --git a/runtime/lib/developer.dart b/runtime/lib/developer.dart
index e9b90b9..78c1d6d 100644
--- a/runtime/lib/developer.dart
+++ b/runtime/lib/developer.dart
@@ -154,7 +154,10 @@
@patch int _getServiceMinorVersion() native "Developer_getServiceMinorVersion";
-@patch void _getServerInfo(SendPort sp) native "Developer_getServerInfo";
+@patch void _getServerInfo(SendPort sendPort) native "Developer_getServerInfo";
-@patch void _webServerControl(SendPort sp, bool enable)
- native "Developer_webServerControl";
\ No newline at end of file
+@patch void _webServerControl(SendPort sendPort, bool enable)
+ native "Developer_webServerControl";
+
+@patch String _getIsolateIDFromSendPort(SendPort sendPort)
+ native "Developer_getIsolateIDFromSendPort";
diff --git a/runtime/observatory/tests/service/developer_service_get_isolate_id_test.dart b/runtime/observatory/tests/service/developer_service_get_isolate_id_test.dart
new file mode 100644
index 0000000..f3a24b0
--- /dev/null
+++ b/runtime/observatory/tests/service/developer_service_get_isolate_id_test.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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.
+// VMOptions=--error_on_bad_type --error_on_bad_override
+
+import 'dart:async';
+import 'dart:developer' as dev;
+import 'dart:isolate' as Core;
+
+import 'package:observatory/service_io.dart' as Service;
+import 'package:unittest/unittest.dart';
+import 'service_test_common.dart';
+import 'test_helper.dart';
+
+
+// testee state.
+String selfId;
+Core.Isolate childIsolate;
+String childId;
+
+void spawnEntry(int i) {
+ dev.debugger();
+}
+
+Future testeeMain() async {
+ dev.debugger();
+ // Spawn an isolate.
+ childIsolate = await Core.Isolate.spawn(spawnEntry, 0);
+ // Assign the id for this isolate and it's child to strings so they can
+ // be read by the tester.
+ selfId = dev.Service.getIsolateID(Core.Isolate.current);
+ childId = dev.Service.getIsolateID(childIsolate);
+ dev.debugger();
+}
+
+// tester state:
+Service.Isolate initialIsolate;
+Service.Isolate localChildIsolate;
+
+var tests = [
+ (Service.VM vm) async {
+ // Sanity check.
+ expect(vm.isolates.length, 1);
+ initialIsolate = vm.isolates[0];
+ await hasStoppedAtBreakpoint(initialIsolate);
+ // Resume.
+ await initialIsolate.resume();
+ },
+ (Service.VM vm) async {
+ // Initial isolate has paused at second debugger call.
+ await hasStoppedAtBreakpoint(initialIsolate);
+ },
+ (Service.VM vm) async {
+ // Reload the VM.
+ await vm.reload();
+
+ // Grab the child isolate.
+ localChildIsolate =
+ vm.isolates.firstWhere(
+ (Service.Isolate i) => i != initialIsolate);
+ expect(localChildIsolate, isNotNull);
+
+ // Reload the initial isolate.
+ await initialIsolate.reload();
+
+ // Grab the root library.
+ Service.Library rootLbirary = await initialIsolate.rootLibrary.load();
+
+ // Grab self id.
+ Service.Instance localSelfId =
+ await initialIsolate.eval(rootLbirary, 'selfId');
+
+ // Check that the id reported from dart:developer matches the id reported
+ // from the service protocol.
+ expect(localSelfId.isString, true);
+ expect(initialIsolate.id, equals(localSelfId.valueAsString));
+
+ // Grab the child isolate's id.
+ Service.Instance localChildId =
+ await initialIsolate.eval(rootLbirary, 'childId');
+
+ // Check that the id reported from dart:developer matches the id reported
+ // from the service protocol.
+ expect(localChildId.isString, true);
+ expect(localChildIsolate.id, equals(localChildId.valueAsString));
+ }
+];
+
+main(args) async => runVMTests(args, tests,
+ testeeConcurrent: testeeMain);
diff --git a/runtime/observatory/tests/service/service_test_common.dart b/runtime/observatory/tests/service/service_test_common.dart
index 2a68a52..bf1d013 100644
--- a/runtime/observatory/tests/service/service_test_common.dart
+++ b/runtime/observatory/tests/service/service_test_common.dart
@@ -157,7 +157,7 @@
isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
var subscription;
subscription = stream.listen((ServiceEvent event) {
- if (event.kind == kind) {
+ if ((isolate == event.isolate) && (event.kind == kind)) {
if (completer != null) {
// Reload to update isolate.pauseEvent.
print('Paused with $kind');
diff --git a/runtime/vm/bootstrap_natives.h b/runtime/vm/bootstrap_natives.h
index 536299c..2086186 100644
--- a/runtime/vm/bootstrap_natives.h
+++ b/runtime/vm/bootstrap_natives.h
@@ -71,6 +71,7 @@
V(Bigint_getDigits, 1) \
V(Bigint_allocate, 4) \
V(Developer_debugger, 2) \
+ V(Developer_getIsolateIDFromSendPort, 1) \
V(Developer_getServerInfo, 1) \
V(Developer_getServiceMajorVersion, 0) \
V(Developer_getServiceMinorVersion, 0) \
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index e4cbfaf..aa851bf 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -1974,7 +1974,7 @@
}
JSONObject jsobj(stream);
jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate"));
- jsobj.AddFixedServiceId("isolates/%" Pd64 "",
+ jsobj.AddFixedServiceId(ISOLATE_SERVICE_ID_FORMAT_STRING,
static_cast<int64_t>(main_port()));
jsobj.AddProperty("name", debugger_name());
diff --git a/runtime/vm/service.h b/runtime/vm/service.h
index 8ee0c00..a1ee159 100644
--- a/runtime/vm/service.h
+++ b/runtime/vm/service.h
@@ -41,6 +41,7 @@
private:
};
+#define ISOLATE_SERVICE_ID_FORMAT_STRING "isolates/%" Pd64 ""
class RingServiceIdZone : public ServiceIdZone {
public:
diff --git a/sdk/lib/_internal/js_runtime/lib/developer_patch.dart b/sdk/lib/_internal/js_runtime/lib/developer_patch.dart
index b9e35b2..541658b 100644
--- a/sdk/lib/_internal/js_runtime/lib/developer_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/developer_patch.dart
@@ -117,11 +117,16 @@
}
@patch
-void _getServerInfo(SendPort sp) {
- sp.send(null);
+void _getServerInfo(SendPort sendPort) {
+ sendPort.send(null);
}
@patch
-void _webServerControl(SendPort sp, bool enable) {
- sp.send(null);
+void _webServerControl(SendPort sendPort, bool enable) {
+ sendPort.send(null);
}
+
+@patch
+String _getIsolateIDFromSendPort(SendPort sendPort) {
+ return null;
+}
\ No newline at end of file
diff --git a/sdk/lib/developer/developer.dart b/sdk/lib/developer/developer.dart
index 47ea5ba..aab137c 100644
--- a/sdk/lib/developer/developer.dart
+++ b/sdk/lib/developer/developer.dart
@@ -17,7 +17,7 @@
import 'dart:async';
import 'dart:convert';
-import 'dart:isolate' show RawReceivePort, SendPort;
+import 'dart:isolate' show Isolate, RawReceivePort, SendPort;
part 'extension.dart';
part 'profiler.dart';
diff --git a/sdk/lib/developer/service.dart b/sdk/lib/developer/service.dart
index 9ccf0dc..bbe954d 100644
--- a/sdk/lib/developer/service.dart
+++ b/sdk/lib/developer/service.dart
@@ -73,13 +73,26 @@
receivePort.close();
return new ServiceProtocolInfo(uri);
}
+
+ /// Returns a [String] token representing the ID of [isolate].
+ ///
+ /// Returns null if the running Dart environment does not support the service
+ /// protocol.
+ static String getIsolateID(Isolate isolate) {
+ if (isolate is! Isolate) {
+ throw new ArgumentError.value(isolate,
+ 'isolate',
+ 'Must be an Isolate');
+ }
+ return _getIsolateIDFromSendPort(isolate.controlPort);
+ }
}
-/// [sp] will receive a Uri or null.
-external void _getServerInfo(SendPort sp);
+/// [sendPort] will receive a Uri or null.
+external void _getServerInfo(SendPort sendPort);
-/// [sp] will receive a Uri or null.
-external void _webServerControl(SendPort sp, bool enable);
+/// [sendPort] will receive a Uri or null.
+external void _webServerControl(SendPort sendPort, bool enable);
/// Returns the major version of the service protocol.
external int _getServiceMajorVersion();
@@ -87,3 +100,5 @@
/// Returns the minor version of the service protocol.
external int _getServiceMinorVersion();
+/// Returns the service id for the isolate that owns [sendPort].
+external String _getIsolateIDFromSendPort(SendPort sendPort);
\ No newline at end of file
diff --git a/tests/compiler/dart2js/generic_method_type_usage_test.dart b/tests/compiler/dart2js/generic_method_type_usage_test.dart
index b1f0f22..bbaae78 100644
--- a/tests/compiler/dart2js/generic_method_type_usage_test.dart
+++ b/tests/compiler/dart2js/generic_method_type_usage_test.dart
@@ -69,6 +69,13 @@
aFunction<Set>();
}
''',
+
+ 'dynamic_as_type_argument.dart': '''
+main() {
+ method<dynamic>();
+}
+method<T>() {}
+''',
};
Future runTest(Uri main, {MessageKind warning, MessageKind info}) async {
@@ -84,7 +91,7 @@
outputProvider: output);
Expect.isFalse(output.hasExtraOutput);
- Expect.equals(0, diagnostics.errors.length);
+ Expect.equals(0, diagnostics.errors.length, "Unexpected errors.");
Expect.equals(warning != null ? 1 : 0, diagnostics.warnings.length);
if (warning != null) {
Expect.equals(warning, diagnostics.warnings.first.message.kind);
@@ -105,5 +112,7 @@
await runTest(Uri.parse('memory:cannot_new_function_type_variable.dart'),
warning: MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE);
+
+ await runTest(Uri.parse('memory:dynamic_as_type_argument.dart'));
});
}
diff --git a/tools/VERSION b/tools/VERSION
index 3432258..7b36926 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -29,4 +29,4 @@
MINOR 21
PATCH 0
PRERELEASE 11
-PRERELEASE_PATCH 1
+PRERELEASE_PATCH 2