Skip to content

Commit 7f7c681

Browse files
committed
Fix a batch of DDC SDK compile errors.
[email protected], [email protected] Review-Url: https://codereview.chromium.org/2848703003 .
1 parent daa3994 commit 7f7c681

18 files changed

+110
-71
lines changed

pkg/dev_compiler/lib/js/amd/dart_sdk.js

Lines changed: 18 additions & 12 deletions
Large diffs are not rendered by default.

pkg/dev_compiler/lib/js/amd/dart_sdk.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dev_compiler/lib/js/common/dart_sdk.js

Lines changed: 18 additions & 12 deletions
Large diffs are not rendered by default.

pkg/dev_compiler/lib/js/common/dart_sdk.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dev_compiler/lib/js/es6/dart_sdk.js

Lines changed: 18 additions & 12 deletions
Large diffs are not rendered by default.

pkg/dev_compiler/lib/js/es6/dart_sdk.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dev_compiler/lib/js/legacy/dart_sdk.js

Lines changed: 18 additions & 12 deletions
Large diffs are not rendered by default.

pkg/dev_compiler/lib/js/legacy/dart_sdk.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/dev_compiler/lib/sdk/ddc_sdk.sum

152 Bytes
Binary file not shown.

pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import 'dart:_js_helper'
1010
patch,
1111
checkInt,
1212
getRuntimeType,
13+
getTraceFromException,
1314
jsonEncodeNative,
1415
JsLinkedHashMap,
1516
JSSyntaxRegExp,
16-
Primitives,
17-
stringJoinUnchecked,
17+
NoInline,
1818
objectHashCode,
19-
getTraceFromException;
19+
Primitives,
20+
stringJoinUnchecked;
2021

2122
import 'dart:_foreign_helper' show JS;
2223

@@ -131,6 +132,7 @@ class int {
131132

132133
@patch
133134
factory int.fromEnvironment(String name, {int defaultValue}) {
135+
// ignore: const_constructor_throws_exception
134136
throw new UnsupportedError(
135137
'int.fromEnvironment can only be used as a const constructor');
136138
}
@@ -391,6 +393,7 @@ class String {
391393

392394
@patch
393395
factory String.fromEnvironment(String name, {String defaultValue}) {
396+
// ignore: const_constructor_throws_exception
394397
throw new UnsupportedError(
395398
'String.fromEnvironment can only be used as a const constructor');
396399
}
@@ -445,6 +448,7 @@ class String {
445448
class bool {
446449
@patch
447450
factory bool.fromEnvironment(String name, {bool defaultValue: false}) {
451+
// ignore: const_constructor_throws_exception
448452
throw new UnsupportedError(
449453
'bool.fromEnvironment can only be used as a const constructor');
450454
}

pkg/dev_compiler/tool/input_sdk/private/annotations.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
part of dart._js_helper;
66

7+
/// Tells the optimizing compiler to always inline the annotated method.
8+
class ForceInline {
9+
const ForceInline();
10+
}
11+
712
/// Tells the optimizing compiler that the annotated method cannot throw.
813
/// Requires @NoInline() to function correctly.
914
class NoThrows {

pkg/dev_compiler/tool/sdk_expected_errors.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
[error] A value of type 'Future<Null>' can't be assigned to a variable of type '_Future'. (dart:async/future.dart, line 138, col 38)
21
[error] Couldn't infer type parameter 'T'.
32

43
Tried to infer '_ControllerEventSinkWrapper<dynamic>' for 'T' which doesn't work:
@@ -12,7 +11,6 @@ Consider passing explicit type argument(s) to the generic.
1211

1312
(dart:async/stream.dart, line 1322, col 16)
1413
[error] The argument type 'ZoneUnaryCallback(EventSink<T>) → dynamic' can't be assigned to the parameter type '(_ControllerEventSinkWrapper<dynamic>) → dynamic'. (dart:async/stream.dart, line 1322, col 32)
15-
[error] Type parameter bound types must be instantiated. (dart:collection/queue.dart, line 97, col 32)
1614
[error] Invalid override. The type of '_UnicodeSubsetEncoder.startChunkedConversion' ('(Sink<List<int>>) → StringConversionSink') isn't a subtype of 'ChunkedConverter<String, List<int>, String, List<int>>.startChunkedConversion' ('(dynamic) → dynamic'). (dart:convert/ascii.dart, line 106, col 3)
1715
[error] Invalid override. The type of '_UnicodeSubsetEncoder.bind' ('(Stream<String>) → Stream<List<int>>') isn't a subtype of 'ChunkedConverter<String, List<int>, String, List<int>>.bind' ('(dynamic) → dynamic'). (dart:convert/ascii.dart, line 114, col 3)
1816
[error] Invalid override. The type of '_UnicodeSubsetDecoder.startChunkedConversion' ('(Sink<String>) → ByteConversionSink') isn't a subtype of 'ChunkedConverter<List<int>, String, List<int>, String>.startChunkedConversion' ('(dynamic) → dynamic'). (dart:convert/ascii.dart, line 219, col 3)
@@ -40,22 +38,12 @@ Consider passing explicit type argument(s) to the generic.
4038
[error] Invalid override. The type of 'Utf8Encoder.bind' ('(Stream<String>) → Stream<List<int>>') isn't a subtype of 'ChunkedConverter<String, List<int>, String, List<int>>.bind' ('(dynamic) → dynamic'). (dart:convert/utf.dart, line 129, col 3)
4139
[error] Invalid override. The type of 'Utf8Decoder.startChunkedConversion' ('(Sink<String>) → ByteConversionSink') isn't a subtype of 'ChunkedConverter<List<int>, String, List<int>, String>.startChunkedConversion' ('(dynamic) → dynamic'). (dart:convert/utf.dart, line 357, col 3)
4240
[error] Invalid override. The type of 'Utf8Decoder.bind' ('(Stream<List<int>>) → Stream<String>') isn't a subtype of 'ChunkedConverter<List<int>, String, List<int>, String>.bind' ('(dynamic) → dynamic'). (dart:convert/utf.dart, line 368, col 3)
43-
[error] Only redirecting factory constructors can be declared to be 'const'. (dart:core/bool.dart, line 41, col 9)
44-
[error] Const constructors can't throw exceptions. (dart:core/bool.dart, line 42, col 5)
45-
[error] Only redirecting factory constructors can be declared to be 'const'. (dart:core/int.dart, line 33, col 9)
46-
[error] Const constructors can't throw exceptions. (dart:core/int.dart, line 34, col 5)
47-
[error] Annotation must be either a const variable reference or const constructor invocation. (dart:core/stacktrace.dart, line 43, col 3)
48-
[error] Only redirecting factory constructors can be declared to be 'const'. (dart:core/string.dart, line 156, col 9)
49-
[error] Const constructors can't throw exceptions. (dart:core/string.dart, line 157, col 5)
50-
[error] Annotation must be either a const variable reference or const constructor invocation. (dart:developer, line 39, col 1)
5141
[error] The getter 'value' isn't defined for the class 'num'. (dart:html, line 40486, col 21)
5242
[error] A value of type 'Dimension' can't be assigned to a variable of type 'num'. (dart:html, line 40486, col 44)
5343
[error] The getter 'value' isn't defined for the class 'num'. (dart:html, line 40506, col 20)
5444
[error] A value of type 'Dimension' can't be assigned to a variable of type 'num'. (dart:html, line 40506, col 42)
5545
[error] Base class introduces an invalid override. The type of 'Converter.bind' ('(Stream<List<int>>) → Stream<List<int>>') isn't a subtype of 'ChunkedConverter<List<int>, List<int>, List<int>, List<int>>.bind' ('(dynamic) → dynamic'). (dart:io/data_transformer.dart, line 295, col 19)
5646
[error] Invalid override. The type of 'ZLibEncoder.startChunkedConversion' ('(Sink<List<int>>) → ByteConversionSink') isn't a subtype of 'ChunkedConverter<List<int>, List<int>, List<int>, List<int>>.startChunkedConversion' ('(dynamic) → dynamic'). (dart:io/data_transformer.dart, line 388, col 3)
57-
[error] The argument type '(RandomAccessFile) → Future<RandomAccessFile>' can't be assigned to the parameter type '(RandomAccessFile) → FutureOr<File>'. (dart:io/file_impl.dart, line 202, col 30)
58-
[error] The return type 'Future<Object>' isn't a 'FutureOr<File>', as defined by the method ''. (dart:io/file_impl.dart, line 591, col 14)
5947
[error] Undefined name 'lineMode'. (dart:io/stdio.dart, line 57, col 10)
6048
[error] The name 'echoMode=' is already defined. (dart:io/stdio.dart, line 122, col 12)
6149
[error] The name 'lineMode=' is already defined. (dart:io/stdio.dart, line 143, col 12)

sdk/lib/async/future.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ abstract class FutureOr<T> {
135135
*/
136136
abstract class Future<T> {
137137
// The `_nullFuture` is a completed Future with the value `null`.
138-
static final _Future _nullFuture = new Future.value(null);
138+
static final _Future<Null> _nullFuture = new Future.value(null);
139139

140140
/**
141141
* Creates a future containing the result of calling [computation]

sdk/lib/collection/queue.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ abstract class Queue<E> implements EfficientLengthIterable<E> {
9494
void clear();
9595
}
9696

97-
class _DoubleLink<Link extends _DoubleLink> {
97+
class _DoubleLink<Link extends _DoubleLink<Link>> {
9898
Link _previousLink;
9999
Link _nextLink;
100100

sdk/lib/core/bool.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class bool {
3838
*
3939
* const isLoggingOn = (const String.fromEnvironment("logging") == "on");
4040
*/
41+
// The .fromEnvironment() constructors are special in that we do not want
42+
// users to call them using "new". We prohibit that by giving them bodies
43+
// that throw, even though const constructors are not allowed to have bodies.
44+
// Disable those static errors.
45+
//ignore: const_constructor_with_body
46+
//ignore: const_factory
4147
external const factory bool.fromEnvironment(String name,
4248
{bool defaultValue: false});
4349

sdk/lib/core/int.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ abstract class int extends num {
3030
*
3131
* const int.fromEnvironment("defaultPort", defaultValue: 80)
3232
*/
33+
// The .fromEnvironment() constructors are special in that we do not want
34+
// users to call them using "new". We prohibit that by giving them bodies
35+
// that throw, even though const constructors are not allowed to have bodies.
36+
// Disable those static errors.
37+
//ignore: const_constructor_with_body
38+
//ignore: const_factory
3339
external const factory int.fromEnvironment(String name, {int defaultValue});
3440

3541
/**

sdk/lib/core/string.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ abstract class String implements Comparable<String>, Pattern {
143143
*
144144
* var isDeclared = const String.fromEnvironment("maybeDeclared") != null;
145145
*/
146+
// The .fromEnvironment() constructors are special in that we do not want
147+
// users to call them using "new". We prohibit that by giving them bodies
148+
// that throw, even though const constructors are not allowed to have bodies.
149+
// Disable those static errors.
150+
//ignore: const_constructor_with_body
151+
//ignore: const_factory
146152
external const factory String.fromEnvironment(String name,
147153
{String defaultValue});
148154

sdk/lib/io/file_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class _FileStreamConsumer extends StreamConsumer<List<int>> {
199199
}
200200

201201
Future<File> close() =>
202-
_openFuture.then<File>((openedFile) => openedFile.close());
202+
_openFuture.then((openedFile) => openedFile.close()).then((_) => _file);
203203
}
204204

205205
// Class for encapsulating the native implementation of files.
@@ -556,7 +556,7 @@ class _File extends FileSystemEntity implements File {
556556
Future<File> writeAsBytes(List<int> bytes,
557557
{FileMode mode: FileMode.WRITE, bool flush: false}) {
558558
return open(mode: mode).then((file) {
559-
return file.writeFrom(bytes, 0, bytes.length).then((_) {
559+
return file.writeFrom(bytes, 0, bytes.length).then<File>((_) {
560560
if (flush) return file.flush().then((_) => this);
561561
return this;
562562
}).whenComplete(file.close);

0 commit comments

Comments
 (0)