@@ -43,11 +43,11 @@ const _Patch patch = _Patch();
4343// https://github.com/dart-lang/sdk/issues/28320
4444class DartIterator <E > implements Iterator <E > {
4545 final _jsIterator;
46- E _current;
46+ E ? _current;
4747
4848 DartIterator (this ._jsIterator);
4949
50- E get current => _current;
50+ E get current => _current as E ;
5151
5252 bool moveNext () {
5353 final ret = JS ('' , '#.next()' , _jsIterator);
@@ -69,17 +69,18 @@ class SyncIterable<E> extends IterableBase<E> {
6969
7070class Primitives {
7171 @NoInline ()
72- static int ? _parseIntError (String source, int ? handleError (String source)? ) {
72+ static int ? _parseIntError (
73+ String source, int ? Function (String )? handleError) {
7374 if (handleError == null ) throw FormatException (source);
7475 return handleError (source);
7576 }
7677
77- static int ? parseInt (
78- @nullCheck String source, int ? _radix, int ? handleError (String source) ? ) {
78+ static int ? parseInt (@nullCheck String source, int ? _radix,
79+ int ? Function (String ) ? handleError ) {
7980 var re = JS ('' , r'/^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i' );
8081 // TODO(jmesserly): this isn't reified List<String>, but it's safe to use as
8182 // long as we use it locally and don't expose it to user code.
82- List <String > match = JS ('' , '#.exec(#)' , re, source);
83+ List <String >? match = JS ('' , '#.exec(#)' , re, source);
8384 int digitsIndex = 1 ;
8485 int hexIndex = 2 ;
8586 int decimalIndex = 3 ;
@@ -89,7 +90,7 @@ class Primitives {
8990 // again.
9091 return _parseIntError (source, handleError);
9192 }
92- String decimalMatch = match[decimalIndex];
93+ String ? decimalMatch = match[decimalIndex];
9394 if (_radix == null ) {
9495 if (decimalMatch != null ) {
9596 // Cannot fail because we know that the digits are all decimal.
@@ -147,15 +148,15 @@ class Primitives {
147148
148149 @NoInline ()
149150 static double ? _parseDoubleError (
150- String source, double ? handleError (String source) ? ) {
151+ String source, double ? Function (String ) ? handleError ) {
151152 if (handleError == null ) {
152153 throw FormatException ('Invalid double' , source);
153154 }
154155 return handleError (source);
155156 }
156157
157158 static double ? parseDouble (
158- @nullCheck String source, double ? handleError (String source) ? ) {
159+ @nullCheck String source, double ? Function (String ) ? handleError ) {
159160 // Notice that JS parseFloat accepts garbage at the end of the string.
160161 // Accept only:
161162 // - [+/-]NaN
@@ -169,7 +170,7 @@ class Primitives {
169170 source)) {
170171 return _parseDoubleError (source, handleError);
171172 }
172- num result = JS ('!' , r'parseFloat(#)' , source);
173+ double result = JS ('!' , r'parseFloat(#)' , source);
173174 if (result.isNaN) {
174175 var trimmed = source.trim ();
175176 if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN' ) {
@@ -186,7 +187,7 @@ class Primitives {
186187 static int dateNow () => JS <int >('!' , r'Date.now()' );
187188
188189 static void initTicker () {
189- if (timerFrequency != null ) return ;
190+ if (timerFrequency != 0 ) return ;
190191 // Start with low-resolution. We overwrite the fields if we find better.
191192 timerFrequency = 1000 ;
192193 timerTicks = dateNow;
@@ -200,8 +201,9 @@ class Primitives {
200201 timerTicks = () => (1000 * JS <num >('!' , '#.now()' , performance)).floor ();
201202 }
202203
203- static int timerFrequency;
204- static int Function () timerTicks;
204+ /// 0 frequency indicates the default uninitialized state.
205+ static int timerFrequency = 0 ;
206+ static late int Function () timerTicks;
205207
206208 static bool get isD8 {
207209 return JS (
@@ -266,7 +268,7 @@ class Primitives {
266268 }
267269
268270 @notNull
269- static String stringFromCharCodes (List <int > charCodes) {
271+ static String stringFromCharCodes (JSArray <int > charCodes) {
270272 for (@nullCheck var i in charCodes) {
271273 if (i < 0 ) throw argumentErrorValue (i);
272274 if (i > 0xffff ) return stringFromCodePoints (charCodes);
@@ -325,7 +327,7 @@ class Primitives {
325327 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
326328 // We extract this name using a regexp.
327329 var d = lazyAsJsDate (receiver);
328- List match = JS ('JSArray|Null' , r'/\((.*)\)/.exec(#.toString())' , d);
330+ List ? match = JS ('JSArray|Null' , r'/\((.*)\)/.exec(#.toString())' , d);
329331 if (match != null ) return match[1 ];
330332
331333 // Internet Explorer 10+ emits the zone name without parenthesis:
@@ -360,7 +362,7 @@ class Primitives {
360362 return - JS <int >('!' , r'#.getTimezoneOffset()' , lazyAsJsDate (receiver));
361363 }
362364
363- static int valueFromDecomposedDate (
365+ static int ? valueFromDecomposedDate (
364366 @nullCheck int years,
365367 @nullCheck int month,
366368 @nullCheck int day,
@@ -371,7 +373,7 @@ class Primitives {
371373 @nullCheck bool isUtc) {
372374 final int MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000 ;
373375 var jsMonth = month - 1 ;
374- num value;
376+ int value;
375377 if (isUtc) {
376378 value = JS <int >('!' , r'Date.UTC(#, #, #, #, #, #, #)' , years, jsMonth,
377379 day, hours, minutes, seconds, milliseconds);
@@ -504,7 +506,7 @@ Error diagnoseIndexError(indexable, int index) {
504506 * describes the problem.
505507 */
506508@NoInline ()
507- Error diagnoseRangeError (int start, int end, int length) {
509+ Error diagnoseRangeError (int ? start, int ? end, int length) {
508510 if (start == null ) {
509511 return ArgumentError .value (start, 'start' );
510512 }
@@ -553,9 +555,9 @@ throwConcurrentModificationError(collection) {
553555}
554556
555557class JsNoSuchMethodError extends Error implements NoSuchMethodError {
556- final String _message;
557- final String _method;
558- final String _receiver;
558+ final String ? _message;
559+ final String ? _method;
560+ final String ? _receiver;
559561
560562 JsNoSuchMethodError (this ._message, match)
561563 : _method = match == null ? null : JS ('String|Null' , '#.method' , match),
@@ -597,11 +599,11 @@ fillLiteralMap(keyValuePairs, Map result) {
597599 return result;
598600}
599601
600- bool jsHasOwnProperty (var jsObject, String property) {
602+ bool jsHasOwnProperty (jsObject, String property) {
601603 return JS <bool >('!' , r'#.hasOwnProperty(#)' , jsObject, property);
602604}
603605
604- jsPropertyAccess (var jsObject, String property) {
606+ jsPropertyAccess (jsObject, String property) {
605607 return JS ('var' , r'#[#]' , jsObject, property);
606608}
607609
@@ -738,12 +740,12 @@ class RuntimeError extends Error {
738740
739741/// Error thrown by DDC when an `assert()` fails (with or without a message).
740742class AssertionErrorImpl extends AssertionError {
741- final String _fileUri;
742- final int _line;
743- final int _column;
744- final String _conditionSource;
743+ final String ? _fileUri;
744+ final int ? _line;
745+ final int ? _column;
746+ final String ? _conditionSource;
745747
746- AssertionErrorImpl (Object message,
748+ AssertionErrorImpl (Object ? message,
747749 [this ._fileUri, this ._line, this ._column, this ._conditionSource])
748750 : super (message);
749751
@@ -809,7 +811,7 @@ class PrivateSymbol implements Symbol {
809811
810812 static String getName (Symbol symbol) => (symbol as PrivateSymbol )._name;
811813
812- static Object getNativeSymbol (Symbol symbol) {
814+ static Object ? getNativeSymbol (Symbol symbol) {
813815 if (symbol is PrivateSymbol ) return symbol._nativeSymbol;
814816 return null ;
815817 }
0 commit comments