[dart2js] Assorted TODO cleanup, bump pubspecs to 3.3.0

Change-Id: I621ac252c5d6f3b157a2f194b7f0b7ad85874e4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352990
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
This commit is contained in:
Mayank Patke
2024-02-21 00:02:13 +00:00
committed by Commit Queue
parent e9678f72de
commit 69df740ea9
38 changed files with 98 additions and 218 deletions
@@ -229,8 +229,6 @@ ConstructedConstantValue createSymbol(
InterfaceType type = commonElements.symbolImplementationType;
FieldEntity field = commonElements.symbolField;
ConstantValue argument = createString(text);
// TODO(johnniwinther): Use type arguments when all uses no longer expect
// a [FieldElement].
var fields = <FieldEntity, ConstantValue>{field: argument};
return ConstructedConstantValue(type, fields);
}
+6 -23
View File
@@ -174,21 +174,19 @@ abstract class FunctionEntity extends MemberEntity {
}
/// Enum for the synchronous/asynchronous function body modifiers.
class AsyncMarker {
enum AsyncMarker {
/// The default function body marker.
static const AsyncMarker SYNC = AsyncMarker._(AsyncModifier.Sync);
SYNC._(AsyncModifier.Sync),
/// The `sync*` function body marker.
static const AsyncMarker SYNC_STAR =
AsyncMarker._(AsyncModifier.SyncStar, isYielding: true);
SYNC_STAR._(AsyncModifier.SyncStar, isYielding: true),
/// The `async` function body marker.
static const AsyncMarker ASYNC =
AsyncMarker._(AsyncModifier.Async, isAsync: true);
ASYNC._(AsyncModifier.Async, isAsync: true),
/// The `async*` function body marker.
static const AsyncMarker ASYNC_STAR =
AsyncMarker._(AsyncModifier.AsyncStar, isAsync: true, isYielding: true);
ASYNC_STAR._(AsyncModifier.AsyncStar, isAsync: true, isYielding: true),
;
/// Is `true` if this marker defines the function body to have an
/// asynchronous result, that is, either a [Future] or a [Stream].
@@ -207,21 +205,6 @@ class AsyncMarker {
String toString() {
return '${isAsync ? 'async' : 'sync'}${isYielding ? '*' : ''}';
}
/// Canonical list of marker values.
///
/// Added to make [AsyncMarker] enum-like.
static const List<AsyncMarker> values = <AsyncMarker>[
SYNC,
SYNC_STAR,
ASYNC,
ASYNC_STAR
];
/// Index to this marker within [values].
///
/// Added to make [AsyncMarker] enum-like.
int get index => values.indexOf(this);
}
/// Stripped down super interface for constructor like entities.
+2 -2
View File
@@ -1624,7 +1624,7 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
// internal notion. The language specification does not define a '*' token
// in the type language, and no such token should be surfaced to users.
// For debugging, pass `--debug-print-legacy-stars` to emit the '*'.
if (_options == null || _options!.printLegacyStars) {
if (_options == null || _options.printLegacyStars) {
_token('*');
}
}
@@ -1712,7 +1712,7 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
needsComma = _comma(needsComma);
_visit(typeVariable);
DartType bound = typeVariable.bound;
if (_dartTypes == null || !_dartTypes!.isTopType(bound)) {
if (_dartTypes == null || !_dartTypes.isTopType(bound)) {
_token(' extends ');
_visit(bound);
}
@@ -73,7 +73,7 @@ class AbstractBool {
@override
String toString() =>
'AbstractBool.${_value == null ? 'Maybe' : (_value! ? 'True' : 'False')}';
'AbstractBool.${_value == null ? 'Maybe' : (_value ? 'True' : 'False')}';
}
/// A value in an abstraction of runtime values.
@@ -296,12 +296,6 @@ mixin AbstractValueDomain {
/// subtypes of [cls] or `null` at runtime.
AbstractBool containsOnlyType(covariant AbstractValue value, ClassEntity cls);
/// Returns an [AbstractBool] that describes whether [value] is an instance of
/// [cls] or `null` at runtime.
// TODO(johnniwinther): Merge this with [isInstanceOf].
AbstractBool isInstanceOfOrNull(
covariant AbstractValue value, ClassEntity cls);
/// Returns an [AbstractBool] that describes whether [value] is known to be an
/// instance of [cls] at runtime.
AbstractBool isInstanceOf(AbstractValue value, ClassEntity cls);
+1 -2
View File
@@ -1598,8 +1598,7 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault<TypeInformation?>
@override
TypeInformation visitLoadLibrary(ir.LoadLibrary node) {
// TODO(johnniwinther): Improve this by returning a Future type instead.
return _types.dynamicType;
return _types.asyncFutureType;
}
@override
@@ -238,11 +238,6 @@ class ComputableAbstractValueDomain with AbstractValueDomain {
covariant ComputableAbstractValue value, ClassEntity cls) =>
_wrappedDomain.containsOnlyType(_unwrap(value), cls);
@override
AbstractBool isInstanceOfOrNull(
covariant ComputableAbstractValue value, ClassEntity cls) =>
_wrappedDomain.isInstanceOfOrNull(_unwrap(value), cls);
@override
AbstractBool isInstanceOf(
covariant ComputableAbstractValue value, ClassEntity cls) =>
@@ -114,8 +114,6 @@ class InferrerEngine {
closedWorld.abstractValueDomain;
CommonElements get commonElements => closedWorld.commonElements;
// TODO(johnniwinther): This should be part of [ClosedWorld] or
// [ClosureWorldRefiner].
NoSuchMethodData get noSuchMethodData => closedWorld.noSuchMethodData;
final MemberHierarchyBuilder memberHierarchyBuilder;
@@ -606,13 +606,6 @@ class PowersetDomain with AbstractValueDomain {
_powersetBitsDomain.isInstanceOf(value._powersetBits, cls),
_abstractValueDomain.isInstanceOf(value._abstractValue, cls));
@override
AbstractBool isInstanceOfOrNull(
covariant PowersetValue value, ClassEntity cls) =>
AbstractBool.strengthen(
_powersetBitsDomain.isInstanceOfOrNull(value._powersetBits, cls),
_abstractValueDomain.isInstanceOfOrNull(value._abstractValue, cls));
@override
AbstractBool containsOnlyType(
covariant PowersetValue value, ClassEntity cls) =>
@@ -323,10 +323,6 @@ class TrivialAbstractValueDomain with AbstractValueDomain {
AbstractBool isInstanceOf(AbstractValue value, ClassEntity cls) =>
AbstractBool.Maybe;
@override
AbstractBool isInstanceOfOrNull(AbstractValue value, ClassEntity cls) =>
AbstractBool.Maybe;
@override
AbstractBool containsOnlyType(AbstractValue value, ClassEntity cls) =>
AbstractBool.Maybe;
@@ -413,7 +413,7 @@ class TypeSystem {
bool isTypedArray =
_closedWorld.classHierarchy.isInstantiated(typedDataClass) &&
_abstractValueDomain
.isInstanceOfOrNull(type.type, typedDataClass)
.isInstanceOf(type.type, typedDataClass)
.isDefinitelyTrue;
bool isConst = (type.type == _abstractValueDomain.constListType);
bool isFixed = (type.type == _abstractValueDomain.fixedListType) ||
@@ -176,7 +176,6 @@ class CommonMasks with AbstractValueDomain {
late final TypeMask asyncStarStreamType =
TypeMask.nonNullExact(commonElements.controllerStream, _closedWorld);
// TODO(johnniwinther): Assert that the null type has been resolved.
@override
late final TypeMask nullType = TypeMask.empty();
@@ -409,10 +408,6 @@ class CommonMasks with AbstractValueDomain {
typeMask.containsOnly(cls);
}
@override
AbstractBool isInstanceOfOrNull(TypeMask typeMask, ClassEntity cls) =>
AbstractBool.trueOrMaybe(_isInstanceOfOrNull(typeMask, cls));
bool _isInstanceOfOrNull(TypeMask typeMask, ClassEntity cls) {
return _closedWorld.isImplemented(cls) &&
typeMask.satisfies(cls, _closedWorld);
@@ -450,11 +450,6 @@ class WrappedAbstractValueDomain with AbstractValueDomain {
covariant WrappedAbstractValue value, ClassEntity cls) =>
_abstractValueDomain.isInstanceOf(value._abstractValue, cls);
@override
AbstractBool isInstanceOfOrNull(
covariant WrappedAbstractValue value, ClassEntity cls) =>
_abstractValueDomain.isInstanceOfOrNull(value._abstractValue, cls);
@override
AbstractBool containsOnlyType(
covariant WrappedAbstractValue value, ClassEntity cls) =>
@@ -191,7 +191,7 @@ class CustomElementsAnalysisJoin {
}
if (_backendUsageBuilder != null) {
escapingConstructors
.forEach(_backendUsageBuilder!.registerGlobalFunctionDependency);
.forEach(_backendUsageBuilder.registerGlobalFunctionDependency);
}
// Force the generation of the type constant that is the key to an entry
// in the generated table.
@@ -425,10 +425,6 @@ class Namer extends ModularNamer {
case SelectorKind.SPECIAL:
return specialSelectorName(selector);
default:
throw failedAt(CURRENT_ELEMENT_SPANNABLE,
'Unexpected selector kind: ${selector.kind}');
}
}
@@ -4,7 +4,7 @@
import '../common.dart';
import '../common/elements.dart' show CommonElements;
import '../common/names.dart' show Identifiers, Selectors;
import '../common/names.dart' show Identifiers;
import '../elements/entities.dart';
import '../inferrer/types.dart' show GlobalTypeInferenceResults;
import '../js_model/elements.dart' show JFunction;
@@ -30,12 +30,7 @@ import '../serialization/serialization.dart';
///
/// noSuchMethod(x) => throw 'not implemented'
///
/// Implementations in category C are not applicable, for example:
///
/// noSuchMethod() { /* missing parameter */ }
/// noSuchMethod(a, b) { /* too many parameters */ }
///
/// Implementations that do not fall into category A, B or C are in category D.
/// Implementations that do not fall into category A or B are in category C.
/// They are the only category of implementation that are considered during type
/// inference.
///
@@ -49,7 +44,7 @@ import '../serialization/serialization.dart';
/// implementations to avoid warnings.
/// Registry for collecting `noSuchMethod` implementations and categorizing them
/// into categories `A`, `B`, `C`, `D`.
/// into categories `A`, `B`, `C`.
class NoSuchMethodRegistry {
/// The implementations that fall into category A, described above.
final Set<FunctionEntity> _defaultImpls = {};
@@ -58,11 +53,6 @@ class NoSuchMethodRegistry {
final Set<FunctionEntity> _throwingImpls = {};
/// The implementations that fall into category C, described above.
// TODO(johnniwinther): Remove this category when Dart 1 is no longer
// supported.
final Set<FunctionEntity> _notApplicableImpls = {};
/// The implementations that fall into category D, described above.
final Set<FunctionEntity> _otherImpls = {};
/// The implementations that have not yet been categorized.
@@ -82,7 +72,7 @@ class NoSuchMethodRegistry {
/// `true` if a category `B` method has been seen so far.
bool get hasThrowingNoSuchMethod => _throwingImpls.isNotEmpty;
/// `true` if a category `D` method has been seen so far.
/// `true` if a category `C` method has been seen so far.
bool get hasComplexNoSuchMethod => _otherImpls.isNotEmpty;
Iterable<FunctionEntity> get defaultImpls => _defaultImpls;
@@ -114,13 +104,6 @@ class NoSuchMethodRegistry {
if (_otherImpls.contains(element)) {
return NsmCategory.OTHER;
}
if (_notApplicableImpls.contains(element)) {
return NsmCategory.NOT_APPLICABLE;
}
if (!Selectors.noSuchMethod_.signatureApplies(element)) {
_notApplicableImpls.add(element);
return NsmCategory.NOT_APPLICABLE;
}
if (_commonElements.isDefaultNoSuchMethodImplementation(element)) {
_defaultImpls.add(element);
return NsmCategory.DEFAULT;
@@ -140,12 +123,6 @@ class NoSuchMethodRegistry {
case NsmCategory.OTHER:
_otherImpls.add(element);
break;
case NsmCategory.NOT_APPLICABLE:
// If the super method is not applicable, the call is redirected to
// `Object.noSuchMethod`.
_defaultImpls.add(element);
category = NsmCategory.DEFAULT;
break;
}
return category;
} else if (_resolver.hasThrowingSyntax(element)) {
@@ -166,8 +143,8 @@ class NoSuchMethodRegistry {
/// Data object used during type inference.
///
/// Post inference collected category `D` methods are into subcategories `D1`
/// and `D2`.
/// Post inference collected category `C` methods are into subcategories `C1`
/// and `C2`.
class NoSuchMethodData {
/// Tag used for identifying serialized [NoSuchMethodData] objects in a
/// debugging data stream.
@@ -176,13 +153,13 @@ class NoSuchMethodData {
/// The implementations that fall into category B, described above.
final Set<FunctionEntity> _throwingImpls;
/// The implementations that fall into category D, described above.
/// The implementations that fall into category C, described above.
final Set<FunctionEntity> _otherImpls;
/// The implementations that fall into category D1
/// The implementations that fall into category C1
final Set<FunctionEntity> _complexNoReturnImpls = {};
/// The implementations that fall into category D2
/// The implementations that fall into category C2
final Set<FunctionEntity> _complexReturningImpls = {};
final Set<FunctionEntity> _forwardingSyntaxImpls;
@@ -230,8 +207,8 @@ class NoSuchMethodData {
Iterable<FunctionEntity> get complexReturningImpls => _complexReturningImpls;
/// Now that type inference is complete, split category D into two
/// subcategories: D1, those that have no return type, and D2, those
/// Now that type inference is complete, split category C into two
/// subcategories: C1, those that have no return type, and C2, those
/// that have a return type.
void categorizeComplexImplementations(GlobalTypeInferenceResults results) {
_otherImpls.forEach((FunctionEntity element) {
@@ -243,7 +220,7 @@ class NoSuchMethodData {
});
}
/// Emits a diagnostic about methods in categories `B`, `D1` and `D2`.
/// Emits a diagnostic about methods in categories `B`, `C1` and `C2`.
void emitDiagnostic(DiagnosticReporter reporter) {
_throwingImpls.forEach((e) {
if (!_forwardingSyntaxImpls.contains(e)) {
@@ -264,7 +241,7 @@ class NoSuchMethodData {
/// Returns [true] if the given element is a complex [noSuchMethod]
/// implementation. An implementation is complex if it falls into
/// category D, as described above.
/// category C, as described above.
bool isComplex(FunctionEntity element) {
assert(element.name == Identifiers.noSuchMethod_);
return _otherImpls.contains(element);
@@ -274,6 +251,5 @@ class NoSuchMethodData {
enum NsmCategory {
DEFAULT,
THROWING,
NOT_APPLICABLE,
OTHER,
}
@@ -618,8 +618,7 @@ var ${startupMetricsGlobal} =
});
output.add('\n');
output.add(js
.createCodeBuffer(epilogue, _options,
_sourceInformationStrategy as JavaScriptSourceInformationStrategy)
.createCodeBuffer(epilogue, _options, _sourceInformationStrategy)
.getText());
// Add semi-colon to separate from other fragments in the same part.
output.add(';');
+1 -1
View File
@@ -881,7 +881,7 @@ class JsClosureClassInfo extends JsScopeInfo
@override
Local? getClosureEntity(KernelToLocalsMap localsMap) {
return _closureEntityVariable != null
? localsMap.getLocalVariable(_closureEntityVariable!)
? localsMap.getLocalVariable(_closureEntityVariable)
: _closureEntity;
}
}
@@ -2201,8 +2201,6 @@ class JsElementEnvironment extends ElementEnvironment
return elementMap.getDartType(
getFunctionNode(elementMap, function)!.emittedValueType!);
}
throw failedAt(
CURRENT_ELEMENT_SPANNABLE, 'Unexpected marker ${asyncMarker}');
}
@override
@@ -533,13 +533,13 @@ class _Substitution extends DartTypeSubstitutionVisitor<Null> {
// Returns `null` if not bound.
DartType? _lookupTypeVariableType(TypeVariableType type) {
if (_variables != null) {
int index = _variables!.indexOf(type);
int index = _variables.indexOf(type);
if (index >= 0) return _replacements![index];
}
if (_classEnvironment == null) return null;
if (_classEnvironment!.element == _classValue?.element) {
int index = _classEnvironment!.typeArguments.indexOf(type);
if (_classEnvironment.element == _classValue?.element) {
int index = _classEnvironment.typeArguments.indexOf(type);
if (index >= 0) return _classValue!.typeArguments[index];
return null;
}
@@ -1283,8 +1283,7 @@ class KernelToElementMap implements IrToElementMap {
Name name = getName(node.name);
bool isStatic = node.isStatic;
bool isExternal = node.isExternal;
// TODO(johnniwinther): Remove `&& !node.isExternal` when #31233 is fixed.
bool isAbstract = node.isAbstract && !node.isExternal;
bool isAbstract = node.isAbstract;
AsyncMarker asyncMarker = getAsyncMarker(node.function);
switch (node.kind) {
case ir.ProcedureKind.Factory:
@@ -1901,9 +1900,8 @@ class KernelNativeMemberResolver {
NativeBehavior fieldStoreBehavior =
_computeNativeFieldStoreBehavior(field);
_nativeDataBuilder!
.setNativeFieldLoadBehavior(field, fieldLoadBehavior);
_nativeDataBuilder!
.setNativeFieldStoreBehavior(field, fieldStoreBehavior);
..setNativeFieldLoadBehavior(field, fieldLoadBehavior)
..setNativeFieldStoreBehavior(field, fieldStoreBehavior);
}
}
}
@@ -71,8 +71,7 @@ class BinaryDataSink implements DataSink {
}
@override
void writeEnum(dynamic value) {
// ignore: avoid_dynamic_calls
void writeEnum<E extends Enum>(E value) {
writeInt(value.index);
}
@@ -46,7 +46,7 @@ class BinaryDataSource implements DataSource {
_byteOffset += bytes.length;
String string = utf8.decode(bytes);
if (_stringInterner == null) return string;
return _stringInterner!.internString(string);
return _stringInterner.internString(string);
}
@override
@@ -68,7 +68,7 @@ class BinaryDataSource implements DataSource {
}
@override
E readEnum<E>(List<E> values) {
E readEnum<E extends Enum>(List<E> values) {
int index = readInt();
assert(
0 <= index && index < values.length,
@@ -26,7 +26,7 @@ class ObjectDataSink implements DataSink {
}
@override
void writeEnum(dynamic value) {
void writeEnum<E extends Enum>(E value) {
_data!.add(value);
}
@@ -45,7 +45,7 @@ class ObjectDataSource implements DataSource {
String readString() => _read();
@override
E readEnum<E>(List<E> values) => _read();
E readEnum<E extends Enum>(List<E> values) => _read();
@override
int readInt() => _read();
+2 -6
View File
@@ -15,7 +15,7 @@ abstract class DataSink {
void writeInt(int value);
/// Serialization of an enum value.
void writeEnum(dynamic value);
void writeEnum<E extends Enum>(E value);
/// Serialization of a String value.
void writeString(String value);
@@ -287,11 +287,7 @@ class DataSinkWriter {
}
/// Writes the enum value [value] to this data sink.
// TODO(johnniwinther): Change the signature to
// `void writeEnum<E extends Enum<E>>(E value);` when an interface for enums
// is added to the language.
void writeEnum(dynamic value) {
void writeEnum<E extends Enum>(E value) {
_writeDataKind(DataKind.enumValue);
_sinkWriter.writeEnum(value);
}
@@ -22,7 +22,7 @@ abstract class DataSource {
int readInt();
/// Deserialization of an enum value in [values].
E readEnum<E>(List<E> values);
E readEnum<E extends Enum>(List<E> values);
/// Returns the offset for a deferred entity and skips it in the read queue.
/// The offset can later be passed to [readAtOffset] to get the value.
@@ -390,7 +390,7 @@ class DataSourceReader {
/// ...
/// Foo foo = source.readEnum(Foo.values);
///
E readEnum<E>(List<E> values) {
E readEnum<E extends Enum>(List<E> values) {
_checkDataKind(DataKind.enumValue);
return _sourceReader.readEnum(values);
}
+2 -2
View File
@@ -674,11 +674,11 @@ class SsaInstructionSimplifier extends HBaseVisitor<HInstruction>
AbstractValue resultType = _abstractValueDomain.positiveIntType;
// If we already have computed a more specific type, keep that type.
if (_abstractValueDomain
.isInstanceOfOrNull(actualType, commonElements.jsUInt31Class)
.isInstanceOf(actualType, commonElements.jsUInt31Class)
.isDefinitelyTrue) {
resultType = _abstractValueDomain.uint31Type;
} else if (_abstractValueDomain
.isInstanceOfOrNull(actualType, commonElements.jsUInt32Class)
.isInstanceOf(actualType, commonElements.jsUInt32Class)
.isDefinitelyTrue) {
resultType = _abstractValueDomain.uint32Type;
}
+10 -22
View File
@@ -15,32 +15,20 @@ import '../serialization/serialization.dart';
import '../util/util.dart' show Hashing;
import 'call_structure.dart' show CallStructure;
class SelectorKind {
enum SelectorKind {
GETTER('getter'),
SETTER('setter'),
CALL('call'),
OPERATOR('operator'),
INDEX('index'),
SPECIAL('special'),
;
final String name;
final int index;
const SelectorKind(this.name, this.index);
static const SelectorKind GETTER = SelectorKind('getter', 0);
static const SelectorKind SETTER = SelectorKind('setter', 1);
static const SelectorKind CALL = SelectorKind('call', 2);
static const SelectorKind OPERATOR = SelectorKind('operator', 3);
static const SelectorKind INDEX = SelectorKind('index', 4);
static const SelectorKind SPECIAL = SelectorKind('special', 5);
@override
int get hashCode => index;
const SelectorKind(this.name);
@override
String toString() => name;
static const List<SelectorKind> values = [
GETTER,
SETTER,
CALL,
OPERATOR,
INDEX,
SPECIAL
];
}
class Selector {
+1 -1
View File
@@ -4,7 +4,7 @@ name: compiler
# This package is not intended for consumption on pub.dev. DO NOT publish.
publish_to: none
environment:
sdk: '>=3.0.0 <4.0.0'
sdk: '>=3.3.0 <4.0.0'
# Use 'any' constraints here; we get our versions from the DEPS file.
dependencies:
@@ -89,7 +89,7 @@ class DynamicVisitor extends ir.RecursiveVisitor {
void run({bool verbose = false, bool generate = false}) {
if (!generate && _allowedListPath != null) {
File file = File(_allowedListPath!);
File file = File(_allowedListPath);
if (file.existsSync()) {
try {
_expectedJson = json.jsonDecode(file.readAsStringSync());
@@ -111,7 +111,7 @@ class DynamicVisitor extends ir.RecursiveVisitor {
actualJson[uri] = map;
});
File(_allowedListPath!).writeAsStringSync(
File(_allowedListPath).writeAsStringSync(
json.JsonEncoder.withIndent(' ').convert(actualJson));
return;
}
@@ -13,8 +13,7 @@ const MEMORY_SOURCE_FILES = const {
'main.dart': '''
main() {
print(12300000);
// TODO(efortuna): Uncomment below when issue 33160 is fixed.
// print(0xffffffff00000000);
print(0xffffffff00000000);
print(double.maxFinite);
print(-22230000);
}'''
@@ -44,9 +43,8 @@ Future test({required bool minify}) async {
Expect.isTrue(jsOutput.contains('12300000'));
Expect.isTrue(jsOutput.contains('-22230000'));
}
// TODO(efortuna): Uncomment when issue 33160 is fixed.
//Expect.isTrue(jsOutput.contains('18446744069414584e3'));
//Expect.isFalse(jsOutput.contains('-4294967296'));
Expect.isTrue(jsOutput.contains('18446744069414584e3'));
Expect.isFalse(jsOutput.contains('-4294967296'));
Expect.isTrue(jsOutput.contains('17976931348623157e292'));
Expect.isFalse(jsOutput.contains('1234567890123456789012345'));
// The decimal expansion of double.maxFinite has 308 digits. We only check
+7 -8
View File
@@ -158,7 +158,7 @@ class GenericListView<D> extends View {
// rather than tracking it ourselves.
_select(findIndex(_lastSelectedItem), false);
_select(findIndex(_selectedItem!.value), true);
_lastSelectedItem = _selectedItem!.value;
_lastSelectedItem = _selectedItem.value;
}
@override
@@ -221,7 +221,7 @@ class GenericListView<D> extends View {
: 1);
scroller!.onContentMoved.listen((e) => renderVisibleItems(false));
if (_pages != null) {
watch(_pages!.target, (s) => _onPageSelected());
watch(_pages.target, (s) => _onPageSelected());
}
if (_snapToItems) {
@@ -258,7 +258,7 @@ class GenericListView<D> extends View {
}
if (_selectedItem != null) {
watch(_selectedItem!, (EventSummary summary) => onSelectedItemChange());
watch(_selectedItem, (EventSummary summary) => onSelectedItemChange());
}
}
@@ -348,7 +348,7 @@ class GenericListView<D> extends View {
} else {
// Update the target page only after we are all done animating.
if (_pages != null) {
_pages!.target.value = _layout.getPage(targetIndex, _viewLength);
_pages.target.value = _layout.getPage(targetIndex, _viewLength);
}
}
}
@@ -368,7 +368,7 @@ class GenericListView<D> extends View {
void _onPageSelected() {
if (_pages!.target != _layout.getPage(_activeInterval.start, _viewLength)) {
_throwTo(_layout.getOffset(
_layout.getPageStartIndex(_pages!.target.value, _viewLength)));
_layout.getPageStartIndex(_pages.target.value, _viewLength)));
}
}
@@ -393,11 +393,10 @@ class GenericListView<D> extends View {
}
if (_pages != null) {
_pages!.current.value =
_layout.getPage(targetInterval.start, _viewLength);
_pages.current.value = _layout.getPage(targetInterval.start, _viewLength);
}
if (_pages != null) {
_pages!.length.value = _data.isNotEmpty
_pages.length.value = _data.isNotEmpty
? _layout.getPage(_data.length - 1, _viewLength) + 1
: 0;
}
@@ -9,5 +9,5 @@ main() {
callLoadLibrary();
}
/*member: callLoadLibrary:[null|subclass=Object]*/
/*member: callLoadLibrary:[exact=_Future]*/
callLoadLibrary() => expect.loadLibrary();
+3 -5
View File
@@ -15,12 +15,11 @@ import '../helpers/type_test_helper.dart';
void main() {
asyncTest(() async {
// TODO(johnniwinther): Remove code for Dart 1 tests.
await runTests(strongMode: true);
await runTests();
});
}
runTests({bool strongMode = false}) async {
runTests() async {
var env = await TypeEnvironment.create(r"""
/// A
/// / \
@@ -93,6 +92,5 @@ runTests({bool strongMode = false}) async {
checkClass(G, [G]);
checkClass(H, [H, I]);
checkClass(I, [I]);
checkClass(Function_, strongMode ? [] : [A, B, C, D, E, F, G],
checkSubset: true);
checkClass(Function_, [], checkSubset: true);
}
@@ -7,13 +7,13 @@ class Class1 {
Class1.foo();
}
// TODO(johnniwinther): Uncomment this when #34965 is fixed:
//class Class2 {
// var bar;
// factory Class2.bar() => null;
//}
class Class2 {
var bar;
factory Class2.bar() => Class2._();
Class2._();
}
main() {
Class1.foo().foo;
//new Class2.bar().bar;
Class2.bar().bar;
}
+4 -8
View File
@@ -75,10 +75,7 @@ abstract class DataSink {
{bool allowNull = false});
/// Writes the enum value [value] to this data sink.
// TODO(johnniwinther): Change the signature to
// `void writeEnum<E extends Enum<E>>(E value);` when an interface for enums
// is added to the language.
void writeEnum(dynamic value);
void writeEnum<E extends Enum>(E value);
/// Writes the URI [value] to this data sink.
void writeUri(Uri value);
@@ -194,7 +191,7 @@ abstract class AbstractDataSink extends DataSinkMixin implements DataSink {
}
@override
void writeEnum(dynamic value) {
void writeEnum<E extends Enum>(E value) {
_writeEnumInternal(value);
}
@@ -238,7 +235,7 @@ abstract class AbstractDataSink extends DataSinkMixin implements DataSink {
void _writeIntInternal(int value);
/// Actual serialization of an enum value, implemented by subclasses.
void _writeEnumInternal(dynamic value);
void _writeEnumInternal<E extends Enum>(E value);
}
/// [DataSink] that writes data as a sequence of bytes.
@@ -282,8 +279,7 @@ class BinarySink extends AbstractDataSink {
}
@override
void _writeEnumInternal(dynamic value) {
// ignore: avoid_dynamic_calls
void _writeEnumInternal<E extends Enum>(E value) {
_writeIntInternal(value.index);
}
+16 -23
View File
@@ -990,9 +990,8 @@ class While extends Loop {
class Do extends Loop {
final Expression condition;
Do(Statement body, this.condition,
{JavaScriptNodeSourceInformation? sourceInformation})
: super(body) {
Do(super.body, this.condition,
{JavaScriptNodeSourceInformation? sourceInformation}) {
_sourceInformation = sourceInformation;
}
@@ -1249,7 +1248,7 @@ class Case extends SwitchClause {
}
class Default extends SwitchClause {
Default(Block body) : super(body);
Default(super.body);
@override
T accept<T>(NodeVisitor<T> visitor) => visitor.visitDefault(this);
@@ -1728,7 +1727,7 @@ class Call extends Expression {
}
class New extends Call {
New(Expression cls, List<Expression> arguments) : super(cls, arguments);
New(super.cls, super.arguments);
@override
T accept<T>(NodeVisitor<T> visitor) => visitor.visitNew(this);
@@ -1906,7 +1905,7 @@ abstract class VariableReference extends Expression {
}
class VariableUse extends VariableReference {
VariableUse(String name) : super(name);
VariableUse(super.name);
@override
T accept<T>(NodeVisitor<T> visitor) => visitor.visitVariableUse(this);
@@ -1925,7 +1924,7 @@ class VariableUse extends VariableReference {
class VariableDeclaration extends VariableReference implements Declaration {
final bool allowRename;
VariableDeclaration(String name, {this.allowRename = true}) : super(name);
VariableDeclaration(super.name, {this.allowRename = true});
@override
T accept<T>(NodeVisitor<T> visitor) => visitor.visitVariableDeclaration(this);
@@ -1939,7 +1938,7 @@ class VariableDeclaration extends VariableReference implements Declaration {
}
class Parameter extends VariableDeclaration {
Parameter(String name) : super(name);
Parameter(super.name);
@override
T accept<T>(NodeVisitor<T> visitor) => visitor.visitParameter(this);
@@ -2086,26 +2085,20 @@ class ArrowFunction extends FunctionExpression {
int get precedenceLevel => ASSIGNMENT;
}
class AsyncModifier {
final int index;
enum AsyncModifier {
sync('sync', isAsync: false, isYielding: false),
async('async', isAsync: true, isYielding: false),
asyncStar('async*', isAsync: true, isYielding: true),
syncStar('sync*', isAsync: false, isYielding: true),
;
final bool isAsync;
final bool isYielding;
final String description;
const AsyncModifier(this.index, this.description,
const AsyncModifier(this.description,
{required this.isAsync, required this.isYielding});
static const AsyncModifier sync =
AsyncModifier(0, 'sync', isAsync: false, isYielding: false);
static const AsyncModifier async =
AsyncModifier(1, 'async', isAsync: true, isYielding: false);
static const AsyncModifier asyncStar =
AsyncModifier(2, 'async*', isAsync: true, isYielding: true);
static const AsyncModifier syncStar =
AsyncModifier(3, 'sync*', isAsync: false, isYielding: true);
static const List<AsyncModifier> values = [sync, async, asyncStar, syncStar];
@override
String toString() => description;
}
@@ -2510,7 +2503,7 @@ class MethodDefinition extends Node implements Property {
}
/// Tag class for all interpolated positions.
abstract class InterpolatedNode implements Node {
mixin InterpolatedNode implements Node {
dynamic get nameOrPosition;
bool get isNamed => nameOrPosition is String;
+1 -1
View File
@@ -3,7 +3,7 @@ name: js_ast
publish_to: none
environment:
sdk: '>=2.16.0 <3.0.0'
sdk: '>=3.3.0 <4.0.0'
# Use 'any' constraints here; we get our versions from the DEPS file.
dev_dependencies: