mirror of
https://github.com/dart-lang/sdk
synced 2024-10-01 19:19:16 +00:00
[dart2js] Moving 'legacyJavascript' flag to shipping.
This effectively enables ES6 language features in Dart2JS by default. Also adapts some tests to expect ES6 Method Definition syntax. Change-Id: Iec36fbf9d22afd1083f7560a16fa73fbf15fb85c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205741 Commit-Queue: Mark Zhou <markzipan@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com>
This commit is contained in:
parent
c7405b9d86
commit
4b858b95f8
57
CHANGELOG.md
57
CHANGELOG.md
|
@ -234,6 +234,63 @@ Updated the Linter to `1.7.0`, which includes changes that
|
|||
- Incremental compilation is now used for compilation of executables from
|
||||
dependencies when using `dart run <package>:<command>`.
|
||||
|
||||
#### Dart2JS
|
||||
|
||||
* **Breaking Change** [#46545][]: Dart2JS emits ES6+ JavaScript by default,
|
||||
thereby no longer supporting legacy browsers. Passing the
|
||||
`--legacy-javascript` flag will let you opt out of this update, but this
|
||||
flag will be removed in a future release. Modern browsers will not be
|
||||
affected, as Dart2JS continues to support [last two major releases][1] of
|
||||
Edge, Safari, Firefox, and Chrome.
|
||||
|
||||
[#46545]: https://github.com/dart-lang/sdk/issues/46545
|
||||
[1]: https://dart.dev/faq#q-what-browsers-do-you-support-as-javascript-compilation-targets
|
||||
|
||||
### Language
|
||||
|
||||
* Add an unsigned shift right operator `>>>`. Pad with zeroes, ignoring the
|
||||
sign bit. On the web platform `int.>>>` shifts the low 32 bits interpreted
|
||||
as an unsigned integer, so `a >>> b` gives the same result as
|
||||
`a.toUnsigned(32) >>> b` on the VM.
|
||||
|
||||
* Prior to Dart 2.14, metadata (annotations) were not permitted to be
|
||||
specified with generic type arguments. This restriction is lifted in Dart
|
||||
Dart 2.14.
|
||||
|
||||
```dart
|
||||
class C<T> {
|
||||
const C();
|
||||
}
|
||||
@C(); // Previously permitted.
|
||||
@C<int>(); // Previously an error, now permitted.
|
||||
```
|
||||
|
||||
* Prior to Dart 2.14, generic function types were not permitted as arguments
|
||||
to generic classes or functions, nor to be used as generic bounds. This
|
||||
restriction is lifted in Dart 2.14.
|
||||
|
||||
```dart
|
||||
T wrapWithLogging<T>(T f) {
|
||||
if (f is void Function<T>(T x)) {
|
||||
return <S>(S x) {
|
||||
print("Call: f<$S>($x)");
|
||||
var r = f<S>(x);
|
||||
print("Return: $x");
|
||||
return r;
|
||||
} as T;
|
||||
} // More cases here
|
||||
return f;
|
||||
}
|
||||
void foo<T>(T x) {
|
||||
print("Foo!");
|
||||
}
|
||||
void main() {
|
||||
// Previously an error, now permitted.
|
||||
var f = wrapWithLogging<void Function<T>(T)>(foo);
|
||||
f<int>(3);
|
||||
}
|
||||
```
|
||||
|
||||
## 2.13.4 - 2021-06-28
|
||||
|
||||
This is a patch release that fixes:
|
||||
|
|
|
@ -81,8 +81,8 @@ class FeatureOptions {
|
|||
|
||||
// Initialize feature lists.
|
||||
FeatureOptions() {
|
||||
shipping = [];
|
||||
canary = [legacyJavaScript, newHolders];
|
||||
shipping = [legacyJavaScript];
|
||||
canary = [newHolders];
|
||||
}
|
||||
|
||||
void parse(List<String> options) {
|
||||
|
|
|
@ -36,7 +36,7 @@ void main() {
|
|||
main() {
|
||||
// Make sure that class A, B and C are emitted in that order. For simplicity
|
||||
// we just verify that their members are in the correct order.
|
||||
RegExp regexp = new RegExp(r"foo\$0?:(.|\n)*bar\$0:(.|\n)*gee\$0:");
|
||||
RegExp regexp = new RegExp(r"foo\$0?\((.|\n)*bar\$0\((.|\n)*gee\$0\(");
|
||||
|
||||
runTests() async {
|
||||
String generated1 = await compileAll(TEST_ONE);
|
||||
|
|
|
@ -59,7 +59,7 @@ Future closureInvocation({bool minify, String prefix}) async {
|
|||
// the closure.
|
||||
Future closureBailout({bool minify, String prefix}) async {
|
||||
String generated = await compileAll(TEST_BAILOUT, minify: minify);
|
||||
RegExp regexp = new RegExp("$prefix\\\$0:${minify ? "" : " "}function");
|
||||
RegExp regexp = new RegExp("$prefix\\\$0\\(\\)${minify ? "" : " "}{");
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ main() {
|
|||
// Direct call through field.
|
||||
Expect.isTrue(generated1.contains(r'this._fun.call$1(zzz)'));
|
||||
// No stub.
|
||||
Expect.isFalse(generated1.contains(r'_fun$1:'));
|
||||
Expect.isFalse(generated1.contains(r'_fun$1(arg0) {'));
|
||||
// No call to stub.
|
||||
Expect.isFalse(generated1.contains(r'_fun$1('));
|
||||
|
||||
|
@ -55,7 +55,8 @@ main() {
|
|||
// Call through stub.
|
||||
Expect.isTrue(generated2.contains(r'this._fun$1(zzz)'));
|
||||
// Stub is generated.
|
||||
Expect.isTrue(generated2.contains(r'_fun$1:'));
|
||||
print(generated2);
|
||||
Expect.isTrue(generated2.contains(r'_fun$1(arg0) {'));
|
||||
// Call through getter (inside stub).
|
||||
Expect.isTrue(generated2.contains(r'get$_fun().call$1'));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ main() {
|
|||
main() {
|
||||
runTest() async {
|
||||
String generated = await compileAll(CODE);
|
||||
RegExp regexp = new RegExp(r'A\$0: function');
|
||||
RegExp regexp = new RegExp(r'A\$0\(\) {');
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ main() {
|
|||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
|
||||
RegExp regexp2 = RegExp(r'A\$\w+: function');
|
||||
RegExp regexp2 = RegExp(r'A\$\w+\(\w+\) {');
|
||||
Iterator<Match> matches2 = regexp2.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches2, 1);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ baz(a) {
|
|||
main() {
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
RegExp regexp = new RegExp('foo\\\$1\\\$a: function');
|
||||
RegExp regexp = new RegExp(r'foo\$1\$a\(\w+\) {');
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@ runTest() async {
|
|||
String mainOutput = collector.getOutput("", OutputType.js);
|
||||
String deferredOutput = collector.getOutput("out_1", OutputType.jsPart);
|
||||
|
||||
Expect.isTrue(mainOutput.contains("other_method_name:"));
|
||||
Expect.isFalse(mainOutput.contains("unique_method_name:"));
|
||||
Expect.isFalse(mainOutput.contains("unique_method_name_closure:"));
|
||||
Expect.isTrue(mainOutput.contains("other_method_name() {"));
|
||||
Expect.isFalse(mainOutput.contains("unique_method_name() {"));
|
||||
Expect.isFalse(mainOutput.contains("unique_method_name_closure() {"));
|
||||
Expect.isFalse(mainOutput.contains("unique-string"));
|
||||
|
||||
Expect.isFalse(deferredOutput.contains("other_method_name:"));
|
||||
Expect.isTrue(deferredOutput.contains("unique_method_name:"));
|
||||
Expect.isTrue(deferredOutput.contains("unique_method_name_closure:"));
|
||||
Expect.isFalse(deferredOutput.contains("other_method_name() {"));
|
||||
Expect.isTrue(deferredOutput.contains("unique_method_name() {"));
|
||||
Expect.isTrue(deferredOutput.contains("unique_method_name_closure() {"));
|
||||
Expect.isTrue(deferredOutput.contains("unique-string"));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
|
||||
/*two-frag.library:
|
||||
a_pre_fragments=[
|
||||
p1: {units: [1{libB}, 6{libA}], usedBy: [p2], needs: []},
|
||||
p2: {units: [5{libB, libC}, 4{libA, libC}, 2{libC}], usedBy: [p3], needs: [p1]},
|
||||
p3: {units: [3{libA, libB, libC}], usedBy: [], needs: [p2]}],
|
||||
p1: {units: [1{libB}, 6{libA}], usedBy: [p2, p3], needs: []},
|
||||
p2: {units: [4{libA, libC}, 2{libC}], usedBy: [p3], needs: [p1]},
|
||||
p3: {units: [3{libA, libB, libC}, 5{libB, libC}], usedBy: [], needs: [p2, p1]}],
|
||||
b_finalized_fragments=[
|
||||
f1: [1{libB}, 6{libA}],
|
||||
f2: [2{libC}],
|
||||
|
|
Loading…
Reference in a new issue