diff --git a/DEPS b/DEPS index acf5a7b413a1..bd78007271c1 100644 --- a/DEPS +++ b/DEPS @@ -141,7 +141,7 @@ vars = { "markdown_rev": "19aaded4300d24bedcbf52ade792b203ddf030b0", "material_color_utilities_rev": "799b6ba2f3f1c28c67cc7e0b4f18e0c7d7f3c03e", # dart-native-interop-team@ is rolling breaking changes manually while the assets features are in experimental. - "native_rev": "d1d9aa5e62d239580b8bf17e36db6d47c308fc89", # disable tools/rev_sdk_deps.dart + "native_rev": "3ed5d3d07246cd792693584c2c42216739a634b7", # disable tools/rev_sdk_deps.dart "protobuf_rev": "b7dd58cdbd879beee4c3fbf8ee80fce8e97bad26", "pub_rev": "710265bae23ad5860f33287fba10b5c369f19a93", # disable tools/rev_sdk_deps.dart "shelf_rev": "bf799519cda2898a7c5af06dcfdd5fe6443afd79", diff --git a/pkg/_fe_analyzer_shared/lib/src/type_inference/shared_inference_log.dart b/pkg/_fe_analyzer_shared/lib/src/type_inference/shared_inference_log.dart index d1672260299b..7245459c2619 100644 --- a/pkg/_fe_analyzer_shared/lib/src/type_inference/shared_inference_log.dart +++ b/pkg/_fe_analyzer_shared/lib/src/type_inference/shared_inference_log.dart @@ -59,7 +59,7 @@ enum ConstraintGenerationSource { /// `GenericInferrer.constrainGenericFunctionInContext` method. genericFunctionInContext(description: 'GENERIC FUNCTION IN CONTEXT'), - /// The source of the constraint is the the context of the invocation whose + /// The source of the constraint is the context of the invocation whose /// type is being inferred, being matched against the return type in function /// or method being invoked. returnType(description: 'RETURN TYPE'); diff --git a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart index 992fa7565db0..f11c3fdd8a56 100644 --- a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart +++ b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart @@ -2568,7 +2568,7 @@ abstract class TypeAnalyzerErrors< /// Called for variable that is assigned more than once. /// - /// Returns an error object that is passed on the the caller. + /// Returns an error object that is passed on to the caller. Error duplicateAssignmentPatternVariable({ required Variable variable, required Pattern original, diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart index d8d51deba229..1f7f662ecf9f 100644 --- a/pkg/analysis_server/lib/src/analysis_server.dart +++ b/pkg/analysis_server/lib/src/analysis_server.dart @@ -1120,7 +1120,7 @@ abstract class CommonServerContextManagerCallbacks // If the removed file doesn't have an overlay, we need to clear any // previous results. if (!resourceProvider.hasOverlay(file)) { - // Clear the cached errors in the the notification manager so we don't + // Clear the cached errors in the notification manager so we don't // re-send stale results if a plugin sends an update and we merge it with // previous results. analysisServer.notificationManager.errors.clearResultsForFile(file); diff --git a/pkg/analysis_server/lib/src/analytics/percentile_calculator.dart b/pkg/analysis_server/lib/src/analytics/percentile_calculator.dart index 248c8ccca4c0..8480df775057 100644 --- a/pkg/analysis_server/lib/src/analytics/percentile_calculator.dart +++ b/pkg/analysis_server/lib/src/analytics/percentile_calculator.dart @@ -63,7 +63,7 @@ class PercentileCalculator { /// Return a map that can be encoded as JSON that represents the state of this /// calculator. Map toJson() { - // It's important the the encoded form of the list of percentile values be + // It's important that the encoded form of the list of percentile values be // less than 100 characters long. return { 'count': _valueCount, diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart index 41744154fba3..40d5369d8f30 100644 --- a/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart +++ b/pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart @@ -10,6 +10,7 @@ import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; import 'package:analyzer/src/dart/ast/extensions.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart'; import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; import 'package:meta/meta.dart'; @@ -67,7 +68,7 @@ abstract class CreateFieldOrGetter extends ResolvedCorrectionProducer { } var matchedType = objectPattern.type.typeOrThrow; - if (matchedType is! InterfaceType) { + if (matchedType is! InterfaceTypeImpl) { return; } diff --git a/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart b/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart index 821cb9d4dde5..ac716f1f096e 100644 --- a/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart +++ b/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart @@ -5,8 +5,8 @@ import 'package:analysis_server/src/services/correction/fix.dart'; import 'package:analysis_server_plugin/edit/dart/correction_producer.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/src/dart/ast/extensions.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart'; import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; import 'package:analyzer_plugin/utilities/range_factory.dart'; @@ -41,7 +41,7 @@ class MoveTypeArgumentsToClass extends ResolvedCorrectionProducer { } var type = namedType.typeOrThrow; - if (type is InterfaceType) { + if (type is InterfaceTypeImpl) { var element = type.element3; if (element.typeParameters2.length == typeArguments.arguments.length) { await builder.addDartFileEdit(file, (builder) { diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml index b2c4fa1f92da..e12691b19694 100644 --- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml +++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml @@ -847,7 +847,7 @@ CompileTimeErrorCode.INCONSISTENT_LANGUAGE_VERSION_OVERRIDE: CompileTimeErrorCode.INCONSISTENT_PATTERN_VARIABLE_LOGICAL_OR: status: noFix notes: |- - We cannot figure out the the user's intent here, and so cannot generate a + We cannot figure out the user's intent here, and so cannot generate a fix that would be right. CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD: status: needsFix diff --git a/pkg/analysis_server/lib/src/services/correction/fix/pubspec/fix_generator.dart b/pkg/analysis_server/lib/src/services/correction/fix/pubspec/fix_generator.dart index 597fcba090d6..28c0e131d49d 100644 --- a/pkg/analysis_server/lib/src/services/correction/fix/pubspec/fix_generator.dart +++ b/pkg/analysis_server/lib/src/services/correction/fix/pubspec/fix_generator.dart @@ -246,8 +246,8 @@ class PubspecFixGenerator { ? prevEntry.value.span.end.offset : (currentEntry.key as YamlNode).span.start.offset; // If nextEntry is null, this is the last entry in the - // dev_dependencies section, and also dev_dependencies is the the - // last section in the pubspec file. So delete till the end of the + // dev_dependencies section, and also dev_dependencies is the last + // section in the pubspec file. So delete till the end of the // section. var endOffset = nextEntry == null diff --git a/pkg/analysis_server/tool/lsp_spec/README.md b/pkg/analysis_server/tool/lsp_spec/README.md index f63c6458192e..2cb25396ab68 100644 --- a/pkg/analysis_server/tool/lsp_spec/README.md +++ b/pkg/analysis_server/tool/lsp_spec/README.md @@ -268,7 +268,7 @@ Direction: Client -> Server Params: `{ uri: Uri }` Returns: `{ content: string | undefined }` -Returns the content of the the virtual document with `uri`. This is intended for generated files (such as those generated by macros) and is not supported for 'file' URIs. +Returns the content of the virtual document with `uri`. This is intended for generated files (such as those generated by macros) and is not supported for 'file' URIs. ### dart/textDocumentContentDidChange Notification diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart index 61c4346ddbe2..1e5af8b60934 100644 --- a/pkg/analyzer/lib/src/dart/ast/ast.dart +++ b/pkg/analyzer/lib/src/dart/ast/ast.dart @@ -9022,7 +9022,7 @@ final class GenericFunctionTypeImpl extends TypeAnnotationImpl final Token? question; @override - DartType? type; + TypeImpl? type; /// The element associated with the function type, or `null` if the AST /// structure hasn't been resolved. @@ -12546,7 +12546,7 @@ final class NamedTypeImpl extends TypeAnnotationImpl implements NamedType { final Token? question; @override - DartType? type; + TypeImpl? type; /// Initializes a newly created type name. /// @@ -14860,7 +14860,7 @@ final class RecordTypeAnnotationImpl extends TypeAnnotationImpl final Token? question; @override - DartType? type; + TypeImpl? type; RecordTypeAnnotationImpl({ required this.leftParenthesis, @@ -17834,7 +17834,10 @@ sealed class TypeAnnotation implements AstNode { DartType? get type; } -sealed class TypeAnnotationImpl extends AstNodeImpl implements TypeAnnotation {} +sealed class TypeAnnotationImpl extends AstNodeImpl implements TypeAnnotation { + @override + TypeImpl? get type; +} /// A list of type arguments. /// diff --git a/pkg/analyzer/lib/src/dart/ast/extensions.dart b/pkg/analyzer/lib/src/dart/ast/extensions.dart index 254d8aa48fbe..b40317e86805 100644 --- a/pkg/analyzer/lib/src/dart/ast/extensions.dart +++ b/pkg/analyzer/lib/src/dart/ast/extensions.dart @@ -376,7 +376,16 @@ extension TypeAnnotationExtension on TypeAnnotation { /// This accessor should be used on expressions that are expected to /// be already resolved. Every such expression must have the type set, /// at least `dynamic`. - DartType get typeOrThrow { + TypeImpl get typeOrThrow => (this as TypeAnnotationImpl).typeOrThrow; +} + +extension TypeAnnotationImplExtension on TypeAnnotationImpl { + /// Return the static type of this type annotation. + /// + /// This accessor should be used on expressions that are expected to + /// be already resolved. Every such expression must have the type set, + /// at least `dynamic`. + TypeImpl get typeOrThrow { var type = this.type; if (type == null) { throw StateError('No type: $this'); diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart index 6569a0bda0af..141d88ae4c7d 100644 --- a/pkg/analyzer/lib/src/dart/element/element.dart +++ b/pkg/analyzer/lib/src/dart/element/element.dart @@ -7844,9 +7844,9 @@ class LocalVariableElementImpl2 extends PromotableElementImpl2 Metadata get metadata2 => wrappedElement.metadata2; @override - DartType get type => _wrappedElement.type; + TypeImpl get type => _wrappedElement.type; - set type(DartType type) => _wrappedElement.type = type; + set type(TypeImpl type) => _wrappedElement.type = type; LocalVariableElementImpl get wrappedElement { return _wrappedElement; @@ -9310,7 +9310,9 @@ class ParameterElementImpl extends VariableElementImpl nameOffset: -1, parameterKind: parameterKind, ); - element.type = type; + // TODO(paulberry): remove this cast by changing the type of the `type` + // parameter. + element.type = type as TypeImpl; element.isSynthetic = true; return element; } @@ -10357,7 +10359,7 @@ abstract class PropertyInducingElementImpl } @override - set type(DartType type) { + set type(TypeImpl type) { super.type = type; // Reset cached types of synthetic getters and setters. // TODO(scheglov): Consider not caching these types. @@ -10859,7 +10861,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl ElementLinkedData? linkedData; ElementImpl? _aliasedElement; - DartType? _aliasedType; + TypeImpl? _aliasedType; @override late TypeAliasElementImpl2 element; @@ -10878,13 +10880,15 @@ class TypeAliasElementImpl extends _ExistingElementImpl } @override - DartType get aliasedType { + TypeImpl get aliasedType { linkedData?.read(this); return _aliasedType!; } set aliasedType(DartType rawType) { - _aliasedType = rawType; + // TODO(paulberry): eliminate this cast by changing the type of the + // `rawType` parameter. + _aliasedType = rawType as TypeImpl; } /// The aliased type, might be `null` if not yet linked. @@ -10910,7 +10914,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl /// the constructor-tearoffs specification. bool get isProperRename { var aliasedType_ = aliasedType; - if (aliasedType_ is! InterfaceType) { + if (aliasedType_ is! InterfaceTypeImpl) { return false; } var aliasedClass = aliasedType_.element; @@ -11157,7 +11161,7 @@ class TypeAliasElementImpl2 extends TypeDefiningElementImpl2 } @override - DartType instantiate( + TypeImpl instantiate( {required List typeArguments, required NullabilitySuffix nullabilitySuffix}) => firstFragment.instantiate( @@ -11347,7 +11351,7 @@ class TypeParameterElementImpl extends ElementImpl } @override - TypeParameterType instantiate({ + TypeParameterTypeImpl instantiate({ required NullabilitySuffix nullabilitySuffix, }) { return TypeParameterTypeImpl( @@ -11628,10 +11632,8 @@ abstract class VariableElementImpl extends ElementImpl @override TypeImpl get type => _type!; - set type(DartType type) { - // TODO(paulberry): eliminate this cast by changing the setter parameter - // type to `TypeImpl`. - _type = type as TypeImpl; + set type(TypeImpl type) { + _type = type; } @override diff --git a/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart b/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart index 7d3d4d8c8333..30b102d302ba 100644 --- a/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart +++ b/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart @@ -58,7 +58,7 @@ class ReplacementVisitor required FunctionTypeBuilder type, required List? newTypeParameters, required List? newParameters, - required DartType? newReturnType, + required TypeImpl? newReturnType, required NullabilitySuffix? newNullability, }) { if (newNullability == null && @@ -311,13 +311,15 @@ class ReplacementVisitor } } - DartType? visitType(DartType? type) { + TypeImpl? visitType(DartType? type) { if (type == null) return null; var result = type.accept(this); if (substitution != null) { result = substitution.substituteType(result ?? type); } - return result; + // TODO(paulberry): eliminate this cast by changing `ReplacementVisitor` + // to implement `TypeVisitor`. + return result as TypeImpl?; } var newReturnType = visitType(node.returnType); diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index 74ca4f0ba92d..deb653bd758d 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -1536,7 +1536,7 @@ abstract class TypeImpl implements DartType { const TypeImpl({this.alias}); @override - DartType get extensionTypeErasure { + TypeImpl get extensionTypeErasure { return const ExtensionTypeErasure().perform(this); } diff --git a/pkg/analyzer/lib/src/dart/element/type_algebra.dart b/pkg/analyzer/lib/src/dart/element/type_algebra.dart index 66a9745adc92..33dc90d9bc07 100644 --- a/pkg/analyzer/lib/src/dart/element/type_algebra.dart +++ b/pkg/analyzer/lib/src/dart/element/type_algebra.dart @@ -168,7 +168,7 @@ class FreshTypeParameters { FreshTypeParameters(this.freshTypeParameters, this.substitution); - FunctionType applyToFunctionType(FunctionType type) { + FunctionTypeImpl applyToFunctionType(FunctionType type) { return FunctionTypeImpl( typeFormals: freshTypeParameters.map((e) => e.firstFragment).toList(), parameters: type.parameters.map((parameter) { @@ -554,7 +554,9 @@ abstract class _TypeSubstitutor inner.invertVariance(); - var returnType = type.returnType.accept(inner); + // TODO(paulberry): eliminate this cast by changing `_TypeSubstitutor` to + // implement `TypeVisitor`. + var returnType = type.returnType.accept(inner) as TypeImpl; if (useCounter == before) return type; diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart index 4cc0dbe6596d..46de54083b46 100644 --- a/pkg/analyzer/lib/src/dart/element/type_system.dart +++ b/pkg/analyzer/lib/src/dart/element/type_system.dart @@ -45,8 +45,10 @@ import 'package:meta/meta.dart'; class ExtensionTypeErasure extends ReplacementVisitor { const ExtensionTypeErasure(); - DartType perform(DartType type) { - return type.accept(this) ?? type; + TypeImpl perform(TypeImpl type) { + // TODO(paulberry): eliminate this cast by changing `ReplacementVisitor` so + // that it implements `TypeVisitor`. + return (type.accept(this) ?? type) as TypeImpl; } @override @@ -700,8 +702,8 @@ class TypeSystemImpl implements TypeSystem { } @override - InterfaceType instantiateInterfaceToBounds({ - required InterfaceElement element, + InterfaceTypeImpl instantiateInterfaceToBounds({ + required covariant InterfaceElementImpl element, required NullabilitySuffix nullabilitySuffix, }) { var typeParameters = element.typeParameters; @@ -746,8 +748,8 @@ class TypeSystemImpl implements TypeSystem { } @override - DartType instantiateTypeAliasToBounds({ - required TypeAliasElement element, + TypeImpl instantiateTypeAliasToBounds({ + required covariant TypeAliasElementImpl element, required NullabilitySuffix nullabilitySuffix, }) { var typeParameters = element.typeParameters; diff --git a/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart index 9a944414f0fa..8d7e283eb2c4 100644 --- a/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart @@ -9,6 +9,7 @@ import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/error/listener.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/dart/element/type_constraint_gatherer.dart'; import 'package:analyzer/src/dart/element/type_schema.dart'; import 'package:analyzer/src/dart/resolver/invocation_inference_helper.dart'; @@ -139,7 +140,10 @@ class AnnotationResolver { contextType: UnknownInferredType.instance, whyNotPromotedArguments: whyNotPromotedArguments, constructorName: constructorName) - .resolveInvocation(rawType: constructorRawType); + .resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `ConstructorElementToInfer.asType`. + rawType: constructorRawType as FunctionTypeImpl); } void _extensionGetter( diff --git a/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart b/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart index aee96f786ed4..efc51f39f6c5 100644 --- a/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart +++ b/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart @@ -11,6 +11,7 @@ import 'package:analyzer/error/listener.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; import 'package:analyzer/src/dart/ast/extensions.dart'; import 'package:analyzer/src/dart/ast/utilities.dart'; +import 'package:analyzer/src/dart/element/element.dart'; import 'package:analyzer/src/error/codes.dart'; /// Handles possible rewrites of AST. @@ -54,7 +55,7 @@ class AstRewriter { node: node, function: SimpleIdentifierImpl(typeNode.name2), ); - } else if (element is TypeAliasElement && + } else if (element is TypeAliasElementImpl && element.aliasedElement is GenericFunctionTypeElement) { return _toMethodInvocationOfAliasedTypeLiteral( node: node, @@ -77,7 +78,7 @@ class AstRewriter { identifier: SimpleIdentifierImpl(typeNode.name2), ), ); - } else if (element is TypeAliasElement && + } else if (element is TypeAliasElementImpl && element.aliasedElement is GenericFunctionTypeElement) { return _toMethodInvocationOfAliasedTypeLiteral( node: node, @@ -635,7 +636,7 @@ class AstRewriter { MethodInvocation _toMethodInvocationOfAliasedTypeLiteral({ required InstanceCreationExpressionImpl node, required Identifier function, - required TypeAliasElement element, + required TypeAliasElementImpl element, }) { var typeName = NamedTypeImpl( importPrefix: node.constructorName.type.importPrefix, diff --git a/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart index aa02df4f1dab..20c7fa737a10 100644 --- a/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/for_resolver.dart @@ -99,7 +99,7 @@ class ForResolver { /// a type for the elements being iterated over. Inference is based /// on the type of the iterator or stream over which the foreach loop /// is defined. - DartType _computeForEachElementType(Expression iterable, bool isAsync) { + TypeImpl _computeForEachElementType(ExpressionImpl iterable, bool isAsync) { var iterableType = iterable.staticType; if (iterableType == null) { return InvalidTypeImpl.instance; diff --git a/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart index 0d7c2d666dc3..568b3c7cfa68 100644 --- a/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart @@ -152,7 +152,10 @@ class FunctionExpressionInvocationResolver { argumentList: node.argumentList, whyNotPromotedArguments: whyNotPromotedArguments, contextType: contextType, - ).resolveInvocation(rawType: rawType); + ).resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `rawType`. + rawType: rawType as FunctionTypeImpl); node.recordStaticType(returnType, resolver: _resolver); } diff --git a/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart index 05f942b8fbd0..18b7fef1600f 100644 --- a/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/function_expression_resolver.dart @@ -80,7 +80,7 @@ class FunctionExpressionResolver { return; } - void inferType(ParameterElementImpl p, DartType inferredType) { + void inferType(ParameterElementImpl p, TypeImpl inferredType) { // Check that there is no declared type, and that we have not already // inferred a type in some fashion. if (p.hasImplicitType && p.type is DynamicType) { @@ -108,8 +108,11 @@ class FunctionExpressionResolver { Iterator fnPositional = contextType.parameters.where((p) => p.isPositional).iterator; while (positional.moveNext() && fnPositional.moveNext()) { - inferType(positional.current as ParameterElementImpl, - fnPositional.current.type); + inferType( + positional.current as ParameterElementImpl, + // TODO(paulberry): eliminate this cast by changing the type of + // `contextType` to `FunctionTypeImpl`. + fnPositional.current.type as TypeImpl); } } @@ -121,7 +124,11 @@ class FunctionExpressionResolver { if (!namedParameterTypes.containsKey(p.name)) { continue; } - inferType(p as ParameterElementImpl, namedParameterTypes[p.name]!); + inferType( + p as ParameterElementImpl, + // TODO(paulberry): eliminate this cast by changing the type of + // `contextType` to `FunctionTypeImpl`. + namedParameterTypes[p.name]! as TypeImpl); } } } diff --git a/pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart index 130d91f7b51c..a5a53f2a1c87 100644 --- a/pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart @@ -11,6 +11,7 @@ import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/error/listener.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; import 'package:analyzer/src/dart/ast/extensions.dart'; +import 'package:analyzer/src/dart/element/element.dart'; import 'package:analyzer/src/dart/element/inheritance_manager3.dart'; import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/dart/resolver/extension_member_resolver.dart'; @@ -318,7 +319,7 @@ class FunctionReferenceResolver { /// Resolves [node] as a [TypeLiteral] referencing an interface type directly /// (not through a type alias). void _resolveDirectTypeLiteral(FunctionReferenceImpl node, - IdentifierImpl name, InterfaceElement element) { + IdentifierImpl name, InterfaceElementImpl element) { var typeArguments = _checkTypeArguments( // `node.typeArguments`, coming from the parser, is never null. node.typeArguments!, name.name, element.typeParameters, @@ -622,13 +623,13 @@ class FunctionReferenceResolver { if (node.parent is PropertyAccess) { _resolveConstructorReference(node); return; - } else if (element is InterfaceElement) { + } else if (element is InterfaceElementImpl) { _resolver.analyzeExpression( node.function, _resolver.operations.unknownType); _resolver.popRewrite(); _resolveDirectTypeLiteral(node, prefix, element); return; - } else if (element is TypeAliasElement) { + } else if (element is TypeAliasElementImpl) { _resolver.analyzeExpression(prefix, _resolver.operations.unknownType); _resolver.popRewrite(); _resolveTypeAlias(node: node, element: element, typeAlias: prefix); @@ -743,7 +744,7 @@ class FunctionReferenceResolver { // `prefix.C.name` is initially represented as a [PropertyAccess] // with a [FunctionReference] target. if (node.parent is PropertyAccess) { - if (element is TypeAliasElement && + if (element is TypeAliasElementImpl && element.aliasedType is FunctionType) { function.staticElement = element; _resolveTypeAlias(node: node, element: element, typeAlias: function); @@ -751,11 +752,11 @@ class FunctionReferenceResolver { _resolveConstructorReference(node); } return; - } else if (element is InterfaceElement) { + } else if (element is InterfaceElementImpl) { function.staticElement = element; _resolveDirectTypeLiteral(node, function, element); return; - } else if (element is TypeAliasElement) { + } else if (element is TypeAliasElementImpl) { function.staticElement = element; _resolveTypeAlias(node: node, element: element, typeAlias: function); return; @@ -830,7 +831,7 @@ class FunctionReferenceResolver { void _resolveTypeAlias({ required FunctionReferenceImpl node, - required TypeAliasElement element, + required TypeAliasElementImpl element, required IdentifierImpl typeAlias, }) { var typeArguments = _checkTypeArguments( @@ -847,7 +848,7 @@ class FunctionReferenceResolver { void _resolveTypeLiteral({ required FunctionReferenceImpl node, - required DartType instantiatedType, + required TypeImpl instantiatedType, required IdentifierImpl name, }) { // TODO(srawlins): set the static element of [typeName]. diff --git a/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart index b5fa0957d7f4..1527d9d76e40 100644 --- a/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart @@ -67,7 +67,10 @@ class InstanceCreationExpressionResolver { argumentList: node.argumentList, contextType: contextType, whyNotPromotedArguments: whyNotPromotedArguments) - .resolveInvocation(rawType: elementToInfer?.asType); + .resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `ConstructorElementToInfer.asType`. + rawType: elementToInfer?.asType as FunctionTypeImpl?); node.recordStaticType(node.constructorName.type.type!, resolver: _resolver); _resolver.checkForArgumentTypesNotAssignableInList( node.argumentList, whyNotPromotedArguments); diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart index ec08d46cb40e..fbea7d8cf627 100644 --- a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart +++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart @@ -164,7 +164,10 @@ class InvocationInferenceHelper { argumentList: node.argumentList, contextType: contextType, whyNotPromotedArguments: whyNotPromotedArguments, - ).resolveInvocation(rawType: rawType); + ).resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `rawType`. + rawType: rawType as FunctionTypeImpl); node.recordStaticType(returnType, resolver: _resolver); } diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart index b8c07ed9d6e1..9967d5dad18b 100644 --- a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart +++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart @@ -156,7 +156,7 @@ abstract class FullInvocationInferrer CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD; @override - DartType resolveInvocation({required FunctionType? rawType}) { + DartType resolveInvocation({required FunctionTypeImpl? rawType}) { var typeArgumentList = _typeArguments; var originalType = rawType; @@ -280,7 +280,7 @@ abstract class FullInvocationInferrer if (inferrer != null) { typeArgumentTypes = inferrer.chooseFinalTypes(); } - FunctionType? invokeType = typeArgumentTypes != null + FunctionTypeImpl? invokeType = typeArgumentTypes != null ? originalType?.instantiate(typeArgumentTypes) : originalType; @@ -333,7 +333,7 @@ abstract class FullInvocationInferrer } List? _storeResult( - List? typeArgumentTypes, FunctionType? invokeType) { + List? typeArgumentTypes, FunctionTypeImpl? invokeType) { return invokeType?.parameters; } } @@ -390,7 +390,7 @@ class InstanceCreationInferrer @override List? _storeResult( - List? typeArgumentTypes, FunctionType? invokeType) { + List? typeArgumentTypes, FunctionTypeImpl? invokeType) { if (invokeType != null) { var constructedType = invokeType.returnType; node.constructorName.type.type = constructedType; @@ -426,7 +426,7 @@ abstract class InvocationExpressionInferrer< @override List? _storeResult( - List? typeArgumentTypes, FunctionType? invokeType) { + List? typeArgumentTypes, FunctionTypeImpl? invokeType) { node.typeArgumentTypes = typeArgumentTypes; node.staticInvokeType = invokeType ?? DynamicTypeImpl.instance; return super._storeResult(typeArgumentTypes, invokeType); @@ -461,7 +461,7 @@ class InvocationInferrer { /// Performs type inference on the invocation expression. [rawType] should be /// the type of the function the invocation is resolved to (with type /// arguments not applied yet). - void resolveInvocation({required FunctionType? rawType}) { + void resolveInvocation({required FunctionTypeImpl? rawType}) { var deferredFunctionLiterals = _visitArguments( parameterMap: _computeParameterMap(rawType?.parameters ?? const [])); if (deferredFunctionLiterals != null) { diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart index 3b6e73b75d1d..c22b7a027e4a 100644 --- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart @@ -492,7 +492,10 @@ class MethodInvocationResolver with ScopeHelpers { argumentList: node.argumentList, whyNotPromotedArguments: whyNotPromotedArguments, contextType: contextType) - .resolveInvocation(rawType: rawType); + .resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `rawType`. + rawType: rawType as FunctionTypeImpl?); } /// Resolves the method invocation, [node], as an instance invocation on an diff --git a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart index b7ff26d3fe2e..ef7c1b27b393 100644 --- a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart @@ -171,7 +171,7 @@ class NamedTypeResolver with ScopeHelpers { /// We are resolving the [NamedType] in a redirecting constructor of the /// [enclosingClass]. - InterfaceType _inferRedirectedConstructor(InterfaceElement element, + InterfaceTypeImpl _inferRedirectedConstructor(InterfaceElementImpl element, {required TypeConstraintGenerationDataForTesting? dataForTesting, required AstNodeImpl? nodeForTesting}) { if (element == enclosingClass) { @@ -202,13 +202,13 @@ class NamedTypeResolver with ScopeHelpers { } } - DartType _instantiateElement(NamedTypeImpl node, Element element, + TypeImpl _instantiateElement(NamedTypeImpl node, Element element, {required TypeConstraintGenerationDataForTesting? dataForTesting}) { var nullability = _getNullability(node); var argumentList = node.typeArguments; if (argumentList != null) { - if (element is InterfaceElement) { + if (element is InterfaceElementImpl) { var typeArguments = _buildTypeArguments( node, argumentList, @@ -218,7 +218,7 @@ class NamedTypeResolver with ScopeHelpers { typeArguments: typeArguments, nullabilitySuffix: nullability, ); - } else if (element is TypeAliasElement) { + } else if (element is TypeAliasElementImpl) { var typeArguments = _buildTypeArguments( node, argumentList, @@ -238,7 +238,7 @@ class NamedTypeResolver with ScopeHelpers { } else if (element is NeverElementImpl) { _buildTypeArguments(node, argumentList, 0); return _instantiateElementNever(nullability); - } else if (element is TypeParameterElement) { + } else if (element is TypeParameterElementImpl) { _buildTypeArguments(node, argumentList, 0); return element.instantiate( nullabilitySuffix: nullability, @@ -249,7 +249,7 @@ class NamedTypeResolver with ScopeHelpers { } } - if (element is InterfaceElement) { + if (element is InterfaceElementImpl) { if (identical(node, withClause_namedType)) { for (var mixin in enclosingClass!.mixins) { if (mixin.element == element) { @@ -267,7 +267,7 @@ class NamedTypeResolver with ScopeHelpers { element: element, nullabilitySuffix: nullability, ); - } else if (element is TypeAliasElement) { + } else if (element is TypeAliasElementImpl) { var type = typeSystem.instantiateTypeAliasToBounds( element: element, nullabilitySuffix: nullability, @@ -280,7 +280,7 @@ class NamedTypeResolver with ScopeHelpers { return DynamicTypeImpl.instance; } else if (element is NeverElementImpl) { return _instantiateElementNever(nullability); - } else if (element is TypeParameterElement) { + } else if (element is TypeParameterElementImpl) { return element.instantiate( nullabilitySuffix: nullability, ); @@ -290,7 +290,7 @@ class NamedTypeResolver with ScopeHelpers { } } - DartType _instantiateElementNever(NullabilitySuffix nullability) { + TypeImpl _instantiateElementNever(NullabilitySuffix nullability) { return NeverTypeImpl.instance.withNullability(nullability); } @@ -387,7 +387,7 @@ class NamedTypeResolver with ScopeHelpers { /// but the [type] is nullable (because the question mark was specified, /// or the type alias is nullable), report an error, and return the /// corresponding non-nullable type. - DartType _verifyNullability(NamedType node, DartType type) { + TypeImpl _verifyNullability(NamedType node, TypeImpl type) { if (identical(node, classHierarchy_namedType)) { if (type.nullabilitySuffix == NullabilitySuffix.question) { var parent = node.parent; @@ -412,17 +412,17 @@ class NamedTypeResolver with ScopeHelpers { CompileTimeErrorCode.NULLABLE_TYPE_IN_WITH_CLAUSE, ); } - return (type as TypeImpl).withNullability(NullabilitySuffix.none); + return type.withNullability(NullabilitySuffix.none); } } return type; } - DartType _verifyTypeAliasForContext( + TypeImpl _verifyTypeAliasForContext( NamedType node, TypeAliasElement element, - DartType type, + TypeImpl type, ) { // If a type alias that expands to a type parameter. if (element.aliasedType is TypeParameterType) { diff --git a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart index ede4d5179883..94005939f5dc 100644 --- a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart +++ b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart @@ -23,6 +23,7 @@ import 'package:analyzer/src/dart/element/element.dart'; import 'package:analyzer/src/dart/element/scope.dart'; import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/dart/element/type_constraint_gatherer.dart'; +import 'package:analyzer/src/dart/element/type_provider.dart'; import 'package:analyzer/src/dart/resolver/ast_rewrite.dart'; import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart'; import 'package:analyzer/src/dart/resolver/named_type_resolver.dart'; @@ -73,7 +74,7 @@ class ElementHolder { /// 5. Rewrite AST where resolution provides a more accurate understanding. class ResolutionVisitor extends RecursiveAstVisitor { final LibraryElementImpl _libraryElement; - final TypeProvider _typeProvider; + final TypeProviderImpl _typeProvider; final CompilationUnitElementImpl _unitElement; final ErrorReporter _errorReporter; final AstRewriter _astRewriter; @@ -177,7 +178,7 @@ class ResolutionVisitor extends RecursiveAstVisitor { this.dataForTesting, ); - DartType get _dynamicType => _typeProvider.dynamicType; + TypeImpl get _dynamicType => _typeProvider.dynamicType; @override void visitAnnotation(covariant AnnotationImpl node) { @@ -1402,7 +1403,7 @@ class ResolutionVisitor extends RecursiveAstVisitor { var localElement = node.declaredElement as LocalVariableElementImpl; element = localElement; - var varList = node.parent as VariableDeclarationList; + var varList = node.parent as VariableDeclarationListImpl; localElement.hasImplicitType = varList.type == null; localElement.hasInitializer = initializerNode != null; localElement.type = varList.type?.type ?? _dynamicType; diff --git a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart index e210d34c7a5f..d34c216ea72e 100644 --- a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart +++ b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart @@ -9,7 +9,6 @@ import 'package:analyzer/dart/analysis/features.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element2.dart'; -import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/error/error.dart'; import 'package:analyzer/error/listener.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; @@ -18,6 +17,7 @@ import 'package:analyzer/src/dart/element/element.dart' show JoinPatternVariableElementImpl2, MetadataImpl; import 'package:analyzer/src/dart/element/inheritance_manager3.dart'; import 'package:analyzer/src/dart/element/member.dart' show ExecutableMember; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/error/codes.dart'; import 'package:analyzer/src/utilities/extensions/object.dart'; import 'package:collection/collection.dart'; @@ -162,7 +162,7 @@ class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor { void visitGenericTypeAlias(GenericTypeAlias node) { if (!Identifier.isPrivateName(node.name.lexeme)) { var type = node.type.type; - if (type is InterfaceType) { + if (type is InterfaceTypeImpl) { for (var constructor in type.constructors2) { if (!Identifier.isPrivateName(constructor.name3!)) { usedElements.addElement(constructor); diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart index d6290c99d8fe..da786af82878 100644 --- a/pkg/analyzer/lib/src/generated/element_resolver.dart +++ b/pkg/analyzer/lib/src/generated/element_resolver.dart @@ -150,7 +150,7 @@ class ElementResolver { } if (type is DynamicType) { // Nothing to do. - } else if (type is InterfaceType) { + } else if (type is InterfaceTypeImpl) { // look up ConstructorElement ConstructorElement? constructor; var name = node.name; diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart index 3164d0151d2a..f3d80768e7b3 100644 --- a/pkg/analyzer/lib/src/generated/resolver.dart +++ b/pkg/analyzer/lib/src/generated/resolver.dart @@ -2063,7 +2063,10 @@ class ResolverVisitor extends ThrowingAstVisitor argumentList: node.arguments, contextType: contextType, whyNotPromotedArguments: whyNotPromotedArguments, - ).resolveInvocation(rawType: rawType); + ).resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `rawType`. + rawType: rawType as FunctionTypeImpl?); node.recordStaticType( augmentationTarget is ExecutableElementImpl @@ -3546,7 +3549,10 @@ class ResolverVisitor extends ThrowingAstVisitor argumentList: node.argumentList, contextType: UnknownInferredType.instance, whyNotPromotedArguments: whyNotPromotedArguments) - .resolveInvocation(rawType: node.staticElement?.type); + .resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `RedirectingConstructorInvocationImpl.staticElement`. + rawType: node.staticElement?.type as FunctionTypeImpl?); checkForArgumentTypesNotAssignableInList( node.argumentList, whyNotPromotedArguments); } @@ -3683,7 +3689,10 @@ class ResolverVisitor extends ThrowingAstVisitor argumentList: node.argumentList, contextType: UnknownInferredType.instance, whyNotPromotedArguments: whyNotPromotedArguments) - .resolveInvocation(rawType: node.staticElement?.type); + .resolveInvocation( + // TODO(paulberry): eliminate this cast by changing the type of + // `SuperConstructorInvocationImpl.staticElement`. + rawType: node.staticElement?.type as FunctionTypeImpl?); checkForArgumentTypesNotAssignableInList( node.argumentList, whyNotPromotedArguments); } diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart index 6c7aa909ff13..baaf8a34e01a 100644 --- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart +++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart @@ -120,7 +120,7 @@ class ElementFactory { static ConstructorElementImpl constructorElement( ClassElement definingClass, String? name, bool isConst, - [List argumentTypes = const []]) { + [List argumentTypes = const []]) { var offset = name == null ? -1 : 0; // A constructor declared as `C.new` is unnamed, and is modeled as such. var constructor = name == null || name == 'new' @@ -146,11 +146,11 @@ class ElementFactory { static ConstructorElementImpl constructorElement2( ClassElement definingClass, String? name, - [List argumentTypes = const []]) => + [List argumentTypes = const []]) => constructorElement(definingClass, name, false, argumentTypes); static FieldElementImpl fieldElement( - String name, bool isStatic, bool isFinal, bool isConst, DartType type, + String name, bool isStatic, bool isFinal, bool isConst, TypeImpl type, {ExpressionImpl? initializer}) { FieldElementImpl field = isConst ? ConstFieldElementImpl(name, 0) : FieldElementImpl(name, 0); @@ -184,7 +184,7 @@ class ElementFactory { } static PropertyAccessorElementImpl getterElement( - String name, bool isStatic, DartType type) { + String name, bool isStatic, TypeImpl type) { FieldElementImpl field = FieldElementImpl(name, -1); field.isStatic = isStatic; field.isSynthetic = true; @@ -227,7 +227,7 @@ class ElementFactory { LocalVariableElementImpl(name, 0); static MethodElementImpl methodElement(String methodName, DartType returnType, - [List argumentTypes = const []]) { + [List argumentTypes = const []]) { MethodElementImpl method = MethodElementImpl(methodName, 0); method.parameters = _requiredParameters(argumentTypes); method.returnType = returnType; @@ -276,7 +276,7 @@ class ElementFactory { ); } - static ParameterElementImpl namedParameter2(String name, DartType type) { + static ParameterElementImpl namedParameter2(String name, TypeImpl type) { var parameter = ParameterElementImpl( name: name, nameOffset: 0, @@ -294,7 +294,7 @@ class ElementFactory { ); } - static ParameterElementImpl positionalParameter2(String name, DartType type) { + static ParameterElementImpl positionalParameter2(String name, TypeImpl type) { var parameter = ParameterElementImpl( name: name, nameOffset: 0, @@ -314,7 +314,7 @@ class ElementFactory { ); } - static ParameterElementImpl requiredParameter2(String name, DartType type) { + static ParameterElementImpl requiredParameter2(String name, TypeImpl type) { var parameter = ParameterElementImpl( name: name, nameOffset: 0, @@ -325,7 +325,7 @@ class ElementFactory { } static PropertyAccessorElementImpl setterElement( - String name, bool isStatic, DartType type) { + String name, bool isStatic, TypeImpl type) { FieldElementImpl field = FieldElementImpl(name, -1); field.isStatic = isStatic; field.isSynthetic = true; @@ -367,7 +367,7 @@ class ElementFactory { } static List _requiredParameters( - List argumentTypes) { + List argumentTypes) { var parameters = argumentTypes.mapIndexed((index, type) { var parameter = ParameterElementImpl( name: 'a$index', diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart index 0e580a085e70..f5b8d122ccde 100644 --- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart +++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart @@ -7,7 +7,6 @@ import 'package:_fe_analyzer_shared/src/scanner/string_canonicalizer.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/element/element.dart'; -import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; import 'package:analyzer/src/dart/ast/token.dart'; import 'package:analyzer/src/dart/element/element.dart'; @@ -676,7 +675,7 @@ class AstBinaryReader { parameters: formalParameters, question: AstBinaryFlags.hasQuestion(flags) ? Tokens.question() : null, ); - var type = _reader.readRequiredType() as FunctionType; + var type = _reader.readRequiredType() as FunctionTypeImpl; node.type = type; var element = GenericFunctionTypeElementImpl.forOffset(-1); diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart index 16eaeeb221e4..3f630a0a1616 100644 --- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart +++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart @@ -2155,7 +2155,7 @@ class ResolutionReader { FunctionType? readOptionalFunctionType() { var type = readType(); - return type is FunctionType ? type : null; + return type is FunctionTypeImpl ? type : null; } T? readOptionalObject(T Function(SummaryDataReader reader) read) { @@ -2170,7 +2170,7 @@ class ResolutionReader { } } - DartType readRequiredType() { + TypeImpl readRequiredType() { return readType()!; } @@ -2188,7 +2188,7 @@ class ResolutionReader { return _reader.readStringReferenceList(); } - DartType? readType() { + TypeImpl? readType() { var tag = _reader.readByte(); if (tag == Tag.NullType) { return null; @@ -2209,13 +2209,13 @@ class ResolutionReader { ); return _readAliasElementArguments(type); } else if (tag == Tag.InterfaceType_noTypeArguments_none) { - var element = readElement() as InterfaceElement; + var element = readElement() as InterfaceElementImpl; var type = element.instantiate( typeArguments: const [], nullabilitySuffix: NullabilitySuffix.none); return _readAliasElementArguments(type); } else if (tag == Tag.InterfaceType_noTypeArguments_question) { - var element = readElement() as InterfaceElement; + var element = readElement() as InterfaceElementImpl; var type = element.instantiate( typeArguments: const [], nullabilitySuffix: NullabilitySuffix.question, @@ -2295,14 +2295,14 @@ class ResolutionReader { } } - DartType _readAliasElementArguments(DartType type) { + TypeImpl _readAliasElementArguments(TypeImpl type) { var aliasElement = _readRawElement(); if (aliasElement is TypeAliasElement) { var aliasArguments = _readTypeList(); - if (type is DynamicType) { + if (type is DynamicTypeImpl) { // TODO(scheglov): add support for `dynamic` aliasing return type; - } else if (type is FunctionType) { + } else if (type is FunctionTypeImpl) { return FunctionTypeImpl( typeFormals: type.typeFormals, parameters: type.parameters, @@ -2333,7 +2333,7 @@ class ResolutionReader { typeArguments: aliasArguments, ), ); - } else if (type is TypeParameterType) { + } else if (type is TypeParameterTypeImpl) { return TypeParameterTypeImpl( element: type.element, nullabilitySuffix: type.nullabilitySuffix, @@ -2342,7 +2342,7 @@ class ResolutionReader { typeArguments: aliasArguments, ), ); - } else if (type is VoidType) { + } else if (type is VoidTypeImpl) { // TODO(scheglov): add support for `void` aliasing return type; } else { @@ -2419,7 +2419,7 @@ class ResolutionReader { } // TODO(scheglov): Optimize for write/read of types without type parameters. - FunctionType _readFunctionType() { + FunctionTypeImpl _readFunctionType() { // TODO(scheglov): reuse for formal parameters var typeParameters = _readTypeParameters(null); var returnType = readRequiredType(); diff --git a/pkg/analyzer/lib/src/summary2/extension_type.dart b/pkg/analyzer/lib/src/summary2/extension_type.dart index 0721f5eb4b24..1e16b828bdd7 100644 --- a/pkg/analyzer/lib/src/summary2/extension_type.dart +++ b/pkg/analyzer/lib/src/summary2/extension_type.dart @@ -151,7 +151,7 @@ class _Node extends graph.Node<_Node> { _evaluateWithType(type); } - void _evaluateWithType(DartType type) { + void _evaluateWithType(TypeImpl type) { var typeSystem = element.library.typeSystem; element.representation.type = type; diff --git a/pkg/analyzer/lib/src/summary2/function_type_builder.dart b/pkg/analyzer/lib/src/summary2/function_type_builder.dart index 27b292cb90fe..91888f5cdc2a 100644 --- a/pkg/analyzer/lib/src/summary2/function_type_builder.dart +++ b/pkg/analyzer/lib/src/summary2/function_type_builder.dart @@ -23,7 +23,7 @@ class FunctionTypeBuilder extends TypeBuilder { final List typeFormals; final List parameters; - final DartType returnType; + final TypeImpl returnType; @override final NullabilitySuffix nullabilitySuffix; @@ -37,7 +37,7 @@ class FunctionTypeBuilder extends TypeBuilder { /// /// When [build] is called, the type is built, stored into this field, /// and set for the [node]. - FunctionType? _type; + FunctionTypeImpl? _type; FunctionTypeBuilder( this.typeFormals, @@ -71,7 +71,7 @@ class FunctionTypeBuilder extends TypeBuilder { } @override - DartType build() { + TypeImpl build() { var type = _type; if (type != null) { return type; @@ -98,7 +98,7 @@ class FunctionTypeBuilder extends TypeBuilder { ); var fresh = getFreshTypeParameters(typeFormals); - type = fresh.applyToFunctionType(type) as FunctionTypeImpl; + type = fresh.applyToFunctionType(type); _type = type; node?.type = type; @@ -153,7 +153,7 @@ class FunctionTypeBuilder extends TypeBuilder { } /// If the [type] is a [TypeBuilder], build it; otherwise return as is. - static DartType _buildType(DartType type) { + static TypeImpl _buildType(TypeImpl type) { if (type is TypeBuilder) { return type.build(); } else { @@ -162,7 +162,7 @@ class FunctionTypeBuilder extends TypeBuilder { } /// Return the type of the [node] as is, possibly a [TypeBuilder]. - static DartType _getNodeType(TypeAnnotation? node) { + static TypeImpl _getNodeType(TypeAnnotation? node) { if (node == null) { return _dynamicType; } else { diff --git a/pkg/analyzer/lib/src/summary2/instance_member_inferrer.dart b/pkg/analyzer/lib/src/summary2/instance_member_inferrer.dart index 9497b42be254..c25db8742473 100644 --- a/pkg/analyzer/lib/src/summary2/instance_member_inferrer.dart +++ b/pkg/analyzer/lib/src/summary2/instance_member_inferrer.dart @@ -127,7 +127,7 @@ class InstanceMemberInferrer { ); overriddenSetters ??= const []; - DartType combinedGetterType() { + TypeImpl combinedGetterType() { var combinedGetter = inheritance.combineSignatures( targetClass: currentInterfaceElement, candidates: overriddenGetters!, @@ -135,12 +135,14 @@ class InstanceMemberInferrer { name: getterName, ); if (combinedGetter != null) { - return combinedGetter.returnType; + // TODO(paulberry): eliminate this cast by changing the return type of + // `InheritanceManager3.combineSignatures`. + return combinedGetter.returnType as TypeImpl; } return DynamicTypeImpl.instance; } - DartType combinedSetterType() { + TypeImpl combinedSetterType() { var combinedSetter = inheritance.combineSignatures( targetClass: currentInterfaceElement, candidates: overriddenSetters!, @@ -150,7 +152,9 @@ class InstanceMemberInferrer { if (combinedSetter != null) { var parameters = combinedSetter.parameters; if (parameters.isNotEmpty) { - return parameters[0].type; + // TODO(paulberry): eliminate this cast by changing the return type of + // `InheritanceManager3.combineSignatures`. + return parameters[0].type as TypeImpl; } } return DynamicTypeImpl.instance; @@ -373,12 +377,16 @@ class InstanceMemberInferrer { if (parameter is FieldFormalParameterElementImpl) { var field = parameter.field; if (field != null) { - parameter.type = field.type; + // TODO(paulberry): eliminate this cast by changing the type of + // `FieldFormalParameterElementImpl.field`. + parameter.type = field.type as TypeImpl; } } else if (parameter is SuperFormalParameterElementImpl) { var superParameter = parameter.superConstructorParameter; if (superParameter != null) { - parameter.type = superParameter.type; + // TODO(paulberry): eliminate this cast by changing the type of + // `SuperFormalParameterElementImpl.superConstructorParameter`. + parameter.type = superParameter.type as TypeImpl; } else { parameter.type = DynamicTypeImpl.instance; } @@ -544,7 +552,9 @@ class InstanceMemberInferrer { combinedSignatureType.parameters, ); if (matchingParameter != null) { - parameter.type = matchingParameter.type; + // TODO(paulberry): eliminate this cast by changing the return type of + // `_getCorrespondingParameter`. + parameter.type = matchingParameter.type as TypeImpl; } else { parameter.type = DynamicTypeImpl.instance; } @@ -724,7 +734,7 @@ class InstanceMemberInferrer { return false; } - static void _setFieldType(FieldElementImpl field, DartType type) { + static void _setFieldType(FieldElementImpl field, TypeImpl type) { field.type = type; } } diff --git a/pkg/analyzer/lib/src/summary2/macro_declarations.dart b/pkg/analyzer/lib/src/summary2/macro_declarations.dart index 9010af8dd269..427d4c158bc4 100644 --- a/pkg/analyzer/lib/src/summary2/macro_declarations.dart +++ b/pkg/analyzer/lib/src/summary2/macro_declarations.dart @@ -349,11 +349,10 @@ class DeclarationBuilder { } } - DartType resolveType(macro.TypeAnnotationCode typeCode) { + TypeImpl resolveType(macro.TypeAnnotationCode typeCode) { switch (typeCode) { case macro.NullableTypeAnnotationCode(): var type = resolveType(typeCode.underlyingType); - type as TypeImpl; return type.withNullability(NullabilitySuffix.question); case macro.FunctionTypeAnnotationCode(): return _resolveTypeCodeFunction(typeCode); @@ -546,7 +545,7 @@ class DeclarationBuilder { ); } - DartType _resolveTypeCodeNamed(macro.NamedTypeAnnotationCode typeCode) { + TypeImpl _resolveTypeCodeNamed(macro.NamedTypeAnnotationCode typeCode) { var identifier = typeCode.name as IdentifierImpl; if (identifier is IdentifierImplVoid) { return VoidTypeImpl.instance; @@ -576,15 +575,19 @@ class DeclarationBuilder { } } - DartType _resolveTypeCodeOmitted(macro.OmittedTypeAnnotationCode typeCode) { + TypeImpl _resolveTypeCodeOmitted(macro.OmittedTypeAnnotationCode typeCode) { var omittedType = typeCode.typeAnnotation; switch (omittedType) { case OmittedTypeAnnotationDynamic(): return DynamicTypeImpl.instance; case OmittedTypeAnnotationFunctionReturnType(): - return omittedType.element.returnType; + // TODO(paulberry): eliminate this cast by changing the type of + // `macro.OmittedTypeAnnotationCode.typeAnnotation`. + return omittedType.element.returnType as TypeImpl; case OmittedTypeAnnotationVariable(): - return omittedType.element.type; + // TODO(paulberry): eliminate this cast by changing the type of + // `macro.OmittedTypeAnnotationCode.typeAnnotation`. + return omittedType.element.type as TypeImpl; default: throw UnimplementedError('${omittedType.runtimeType}'); } diff --git a/pkg/analyzer/lib/src/summary2/named_type_builder.dart b/pkg/analyzer/lib/src/summary2/named_type_builder.dart index f02830cb2334..c1724c6ff99f 100644 --- a/pkg/analyzer/lib/src/summary2/named_type_builder.dart +++ b/pkg/analyzer/lib/src/summary2/named_type_builder.dart @@ -46,7 +46,7 @@ class NamedTypeBuilder extends TypeBuilder { /// /// When [build] is called, the type is built, stored into this field, /// and set for the [node]. - DartType? _type; + TypeImpl? _type; NamedTypeBuilder(this.linker, this.typeSystem, this.element, this.arguments, this.nullabilitySuffix, @@ -90,13 +90,13 @@ class NamedTypeBuilder extends TypeBuilder { } @override - DartType build() { + TypeImpl build() { if (_type != null) { return _type!; } var element = this.element; - if (element is InterfaceElement) { + if (element is InterfaceElementImpl) { var parameters = element.typeParameters; var arguments = _buildArguments(parameters); _type = element.instantiate( diff --git a/pkg/analyzer/lib/src/summary2/type_builder.dart b/pkg/analyzer/lib/src/summary2/type_builder.dart index b9a0b930371d..5d69716865ee 100644 --- a/pkg/analyzer/lib/src/summary2/type_builder.dart +++ b/pkg/analyzer/lib/src/summary2/type_builder.dart @@ -11,7 +11,7 @@ abstract class TypeBuilder implements TypeImpl { /// Does nothing if the type has been already built. /// /// Return the built type. - DartType build(); + TypeImpl build(); @override dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); diff --git a/pkg/analyzer/lib/src/summary2/types_builder.dart b/pkg/analyzer/lib/src/summary2/types_builder.dart index b0cf03e20405..b233c4c2fb2e 100644 --- a/pkg/analyzer/lib/src/summary2/types_builder.dart +++ b/pkg/analyzer/lib/src/summary2/types_builder.dart @@ -97,7 +97,7 @@ class TypesBuilder { _MixinsInference(_toInferMixins).perform(); } - FunctionType _buildFunctionType( + FunctionTypeImpl _buildFunctionType( TypeParameterList? typeParameterList, TypeAnnotation? returnTypeNode, FormalParameterList parameterList, @@ -167,7 +167,7 @@ class TypesBuilder { _extensionDeclaration(node); } else if (node is ExtensionTypeDeclarationImpl) { _extensionTypeDeclaration(node); - } else if (node is FieldFormalParameter) { + } else if (node is FieldFormalParameterImpl) { _fieldFormalParameter(node); } else if (node is FunctionDeclaration) { var returnType = node.returnType?.type; @@ -203,14 +203,14 @@ class TypesBuilder { element.returnType = returnType; } else if (node is MixinDeclaration) { _mixinDeclaration(node); - } else if (node is SimpleFormalParameter) { + } else if (node is SimpleFormalParameterImpl) { var element = node.declaredElement as ParameterElementImpl; element.type = node.type?.type ?? _dynamicType; - } else if (node is SuperFormalParameter) { + } else if (node is SuperFormalParameterImpl) { _superFormalParameter(node); } else if (node is TypeParameterImpl) { _typeParameter(node); - } else if (node is VariableDeclarationList) { + } else if (node is VariableDeclarationListImpl) { var type = node.type?.type; if (type != null) { for (var variable in node.variables) { @@ -260,7 +260,7 @@ class TypesBuilder { _updatedAugmented(element); } - void _fieldFormalParameter(FieldFormalParameter node) { + void _fieldFormalParameter(FieldFormalParameterImpl node) { var element = node.declaredElement as FieldFormalParameterElementImpl; var parameterList = node.parameters; if (parameterList != null) { @@ -342,7 +342,7 @@ class TypesBuilder { } } - void _superFormalParameter(SuperFormalParameter node) { + void _superFormalParameter(SuperFormalParameterImpl node) { var element = node.declaredElement as SuperFormalParameterElementImpl; var parameterList = node.parameters; if (parameterList != null) { diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart index 20e089346ed3..6d04c6e65cb2 100644 --- a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart +++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart @@ -67,13 +67,13 @@ class _MockSdkElementsBuilder { ClassElementImpl? _symbolElement; ClassElementImpl? _typeElement; - InterfaceType? _boolType; - InterfaceType? _doubleType; - InterfaceType? _intType; - InterfaceType? _numType; - InterfaceType? _objectType; - InterfaceType? _stringType; - InterfaceType? _typeType; + InterfaceTypeImpl? _boolType; + InterfaceTypeImpl? _doubleType; + InterfaceTypeImpl? _intType; + InterfaceTypeImpl? _numType; + InterfaceTypeImpl? _objectType; + InterfaceTypeImpl? _stringType; + InterfaceTypeImpl? _typeType; late LibraryElementImpl _asyncLibrary; late CompilationUnitElementImpl _asyncUnit; @@ -109,7 +109,7 @@ class _MockSdkElementsBuilder { return boolElement; } - InterfaceType get boolType { + InterfaceTypeImpl get boolType { return _boolType ??= _interfaceType(boolElement); } @@ -238,7 +238,7 @@ class _MockSdkElementsBuilder { return doubleElement; } - InterfaceType get doubleType { + InterfaceTypeImpl get doubleType { return _doubleType ??= _interfaceType(doubleElement); } @@ -259,7 +259,7 @@ class _MockSdkElementsBuilder { return functionElement; } - InterfaceType get functionType { + InterfaceTypeImpl get functionType { return _interfaceType(functionElement); } @@ -380,7 +380,7 @@ class _MockSdkElementsBuilder { return intElement; } - InterfaceType get intType { + InterfaceTypeImpl get intType { return _intType ??= _interfaceType(intElement); } @@ -615,7 +615,7 @@ class _MockSdkElementsBuilder { return numElement; } - InterfaceType get numType { + InterfaceTypeImpl get numType { return _numType ??= _interfaceType(numElement); } @@ -651,7 +651,7 @@ class _MockSdkElementsBuilder { return objectElement; } - InterfaceType get objectType { + InterfaceTypeImpl get objectType { return _objectType ??= _interfaceType(objectElement); } @@ -686,7 +686,7 @@ class _MockSdkElementsBuilder { return recordElement; } - InterfaceType get recordType { + InterfaceTypeImpl get recordType { return _interfaceType(recordElement); } @@ -831,7 +831,7 @@ class _MockSdkElementsBuilder { return stringElement; } - InterfaceType get stringType { + InterfaceTypeImpl get stringType { return _stringType ??= _interfaceType(stringElement); } @@ -875,48 +875,48 @@ class _MockSdkElementsBuilder { return typeElement; } - InterfaceType get typeType { + InterfaceTypeImpl get typeType { return _typeType ??= _interfaceType(typeElement); } VoidTypeImpl get voidType => VoidTypeImpl.instance; - InterfaceType futureOrType(DartType elementType) { + InterfaceTypeImpl futureOrType(DartType elementType) { return _interfaceType( futureOrElement, typeArguments: [elementType], ); } - InterfaceType futureType(DartType elementType) { + InterfaceTypeImpl futureType(DartType elementType) { return _interfaceType( futureElement, typeArguments: [elementType], ); } - InterfaceType iterableType(DartType elementType) { + InterfaceTypeImpl iterableType(DartType elementType) { return _interfaceType( iterableElement, typeArguments: [elementType], ); } - InterfaceType iteratorType(DartType elementType) { + InterfaceTypeImpl iteratorType(DartType elementType) { return _interfaceType( iteratorElement, typeArguments: [elementType], ); } - InterfaceType listType(DartType elementType) { + InterfaceTypeImpl listType(DartType elementType) { return _interfaceType( listElement, typeArguments: [elementType], ); } - InterfaceType streamSubscriptionType(DartType valueType) { + InterfaceTypeImpl streamSubscriptionType(DartType valueType) { return _interfaceType( streamSubscriptionElement, typeArguments: [valueType], @@ -1007,7 +1007,7 @@ class _MockSdkElementsBuilder { FieldElementImpl _field( String name, - DartType type, { + TypeImpl type, { bool isConst = false, bool isFinal = false, bool isStatic = false, @@ -1029,7 +1029,7 @@ class _MockSdkElementsBuilder { return fragment; } - FunctionType _functionType({ + FunctionTypeImpl _functionType({ required DartType returnType, List typeFormals = const [], List parameters = const [], @@ -1044,7 +1044,7 @@ class _MockSdkElementsBuilder { PropertyAccessorElementImpl _getter( String name, - DartType type, { + TypeImpl type, { bool isStatic = false, }) { var field = FieldElementImpl(name, -1); @@ -1063,7 +1063,7 @@ class _MockSdkElementsBuilder { return getter; } - InterfaceType _interfaceType( + InterfaceTypeImpl _interfaceType( InterfaceElementImpl element, { List typeArguments = const [], }) { @@ -1086,7 +1086,7 @@ class _MockSdkElementsBuilder { ..typeParameters = typeFormals; } - ParameterElementImpl _namedParameter(String name, DartType type, + ParameterElementImpl _namedParameter(String name, TypeImpl type, {String? initializerCode}) { var parameter = DefaultParameterElementImpl( name: name, @@ -1167,7 +1167,7 @@ class _MockSdkElementsBuilder { _fillLibraryFromFragment(_coreLibrary, _coreUnit); } - ParameterElementImpl _positionalParameter(String name, DartType type) { + ParameterElementImpl _positionalParameter(String name, TypeImpl type) { var parameter = ParameterElementImpl( name: name, nameOffset: 0, @@ -1177,7 +1177,7 @@ class _MockSdkElementsBuilder { return parameter; } - ParameterElementImpl _requiredParameter(String name, DartType type) { + ParameterElementImpl _requiredParameter(String name, TypeImpl type) { var parameter = ParameterElementImpl( name: name, nameOffset: 0, @@ -1201,7 +1201,7 @@ class _MockSdkElementsBuilder { TopLevelVariableElementImpl _topLevelVariableConst( String name, - DartType type, + TypeImpl type, ) { var fragment = ConstTopLevelVariableElementImpl(name, -1) ..isConst = true @@ -1215,7 +1215,7 @@ class _MockSdkElementsBuilder { return TypeParameterElementImpl(name, 0); } - TypeParameterType _typeParameterType(TypeParameterElement element) { + TypeParameterTypeImpl _typeParameterType(TypeParameterElement element) { return TypeParameterTypeImpl( element: element, nullabilitySuffix: NullabilitySuffix.none, diff --git a/pkg/analyzer/test/generated/elements_types_mixin.dart b/pkg/analyzer/test/generated/elements_types_mixin.dart index 2c0dd91d294d..d845879d5ab1 100644 --- a/pkg/analyzer/test/generated/elements_types_mixin.dart +++ b/pkg/analyzer/test/generated/elements_types_mixin.dart @@ -204,7 +204,7 @@ mixin ElementsTypesMixin { ExtensionTypeElementImpl extensionType( String name, { String representationName = 'it', - required DartType representationType, + required TypeImpl representationType, List typeParameters = const [], List interfaces = const [], }) { @@ -438,7 +438,7 @@ mixin ElementsTypesMixin { ParameterElementImpl namedParameter({ required String name, - required DartType type, + required TypeImpl type, bool isCovariant = false, }) { var parameter = ParameterElementImpl( @@ -453,7 +453,7 @@ mixin ElementsTypesMixin { ParameterElementImpl namedRequiredParameter({ required String name, - required DartType type, + required TypeImpl type, bool isCovariant = false, }) { var parameter = ParameterElementImpl( @@ -468,7 +468,7 @@ mixin ElementsTypesMixin { ParameterElementImpl positionalParameter({ String? name, - required DartType type, + required TypeImpl type, bool isCovariant = false, String? defaultValueCode, }) { @@ -562,7 +562,7 @@ mixin ElementsTypesMixin { ParameterElementImpl requiredParameter({ String? name, - required DartType type, + required TypeImpl type, bool isCovariant = false, }) { var parameter = ParameterElementImpl( diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart index 2f8659697b31..04d62c985bcc 100644 --- a/pkg/analyzer/test/src/dart/element/element_test.dart +++ b/pkg/analyzer/test/src/dart/element/element_test.dart @@ -1222,7 +1222,7 @@ class InterfaceTypeImplTest extends AbstractTypeSystemTest with StringTypes { var AE = typeParameter('E'); var A = class_(name: 'A', typeParameters: [AE]); - DartType typeAE = typeParameterTypeNone(AE); + var typeAE = typeParameterTypeNone(AE); String getterName = "g"; PropertyAccessorElementImpl getterG = ElementFactory.getterElement(getterName, false, typeAE); @@ -1341,7 +1341,7 @@ A? // var E = typeParameter('E'); var A = class_(name: 'A', typeParameters: [E]); - DartType typeE = typeParameterTypeNone(E); + var typeE = typeParameterTypeNone(E); String methodName = "m"; MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]); @@ -1469,7 +1469,7 @@ A? // var E = typeParameter('E'); var A = class_(name: 'A', typeParameters: [E]); - DartType typeE = typeParameterTypeNone(E); + var typeE = typeParameterTypeNone(E); String setterName = "s"; PropertyAccessorElementImpl setterS = ElementFactory.setterElement(setterName, false, typeE); diff --git a/pkg/analyzer/test/src/dart/element/function_type_test.dart b/pkg/analyzer/test/src/dart/element/function_type_test.dart index 284e3f38abba..164ddc08607f 100644 --- a/pkg/analyzer/test/src/dart/element/function_type_test.dart +++ b/pkg/analyzer/test/src/dart/element/function_type_test.dart @@ -30,7 +30,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest { ClassElement get mapElement => typeProvider.mapElement; - InterfaceType get objectType => typeProvider.objectType; + InterfaceTypeImpl get objectType => typeProvider.objectType; void basicChecks(FunctionType f, {displayName = 'dynamic Function()', diff --git a/pkg/analyzer/test/src/dart/element/least_greatest_closure_test.dart b/pkg/analyzer/test/src/dart/element/least_greatest_closure_test.dart index 17e4694cac9c..7dafa59e62a1 100644 --- a/pkg/analyzer/test/src/dart/element/least_greatest_closure_test.dart +++ b/pkg/analyzer/test/src/dart/element/least_greatest_closure_test.dart @@ -6,6 +6,7 @@ import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/src/dart/element/element.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/utilities/extensions/element.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -21,7 +22,7 @@ main() { @reflectiveTest class GreatestClosureTest extends AbstractTypeSystemTest { late final TypeParameterElementImpl2 T; - late final TypeParameterType T_none; + late final TypeParameterTypeImpl T_none; late final TypeParameterType T_question; @override diff --git a/pkg/analyzer/test/src/dart/element/non_covariant_type_parameter_position_test.dart b/pkg/analyzer/test/src/dart/element/non_covariant_type_parameter_position_test.dart index e70f9263aeff..7e65d27df1da 100644 --- a/pkg/analyzer/test/src/dart/element/non_covariant_type_parameter_position_test.dart +++ b/pkg/analyzer/test/src/dart/element/non_covariant_type_parameter_position_test.dart @@ -5,6 +5,7 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/src/dart/element/non_covariant_type_parameter_position.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -22,7 +23,7 @@ class NonCovariantTypeParameterPositionVisitorTest late final T_element = typeParameter('T'); late final T = typeParameterTypeNone(T_element); - FunctionType get _contravariantT { + FunctionTypeImpl get _contravariantT { return functionTypeNone( returnType: voidNone, parameters: [ diff --git a/pkg/analyzer/test/src/dart/element/replace_top_bottom_test.dart b/pkg/analyzer/test/src/dart/element/replace_top_bottom_test.dart index 48e3048fc634..3a0c68e25f58 100644 --- a/pkg/analyzer/test/src/dart/element/replace_top_bottom_test.dart +++ b/pkg/analyzer/test/src/dart/element/replace_top_bottom_test.dart @@ -5,6 +5,7 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -22,7 +23,7 @@ class ReplaceTopBottomTest extends AbstractTypeSystemTest { // Not contravariant. _check(neverNone, 'Never'); - void checkContravariant(DartType type, String expectedStr) { + void checkContravariant(TypeImpl type, String expectedStr) { _check( functionTypeNone(returnType: intNone, parameters: [ requiredParameter(type: type), diff --git a/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart b/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart index 5c37bb73da34..a3b79883131f 100644 --- a/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart +++ b/pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart @@ -6,6 +6,7 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -55,8 +56,8 @@ class RuntimeTypeEqualityTypeTest extends AbstractTypeSystemTest { void checkRequiredParameter( - DartType T1_type, - DartType T2_type, + TypeImpl T1_type, + TypeImpl T2_type, bool expected, ) { check( diff --git a/pkg/analyzer/test/src/dart/element/type_references_any_test.dart b/pkg/analyzer/test/src/dart/element/type_references_any_test.dart index e841af2a80ae..c196d95cdeaa 100644 --- a/pkg/analyzer/test/src/dart/element/type_references_any_test.dart +++ b/pkg/analyzer/test/src/dart/element/type_references_any_test.dart @@ -21,7 +21,7 @@ main() { @reflectiveTest class TypeReferencesAnyTest extends AbstractTypeSystemTest { late TypeParameterElement T; - late TypeParameterType T_none; + late TypeParameterTypeImpl T_none; @override void setUp() { diff --git a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart index 1d613d1016ec..8c86953c7758 100644 --- a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart +++ b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart @@ -8,6 +8,7 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations. import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/dart/element/type_schema.dart'; import 'package:analyzer/src/dart/element/type_system.dart'; import 'package:test/test.dart'; @@ -505,9 +506,9 @@ class LowerBoundTest extends _BoundsTestBase { test_functionType2_parameters_named() { FunctionType build( - List requiredTypes, - Map namedMap, - Map namedRequiredMap, + List requiredTypes, + Map namedMap, + Map namedRequiredMap, ) { var parameters = []; @@ -608,8 +609,8 @@ class LowerBoundTest extends _BoundsTestBase { test_functionType2_parameters_positional() { FunctionType build( - List requiredTypes, - List positionalTypes, + List requiredTypes, + List positionalTypes, ) { var parameters = []; @@ -801,7 +802,7 @@ class LowerBoundTest extends _BoundsTestBase { } test_futureOr() { - InterfaceType futureOrFunction(DartType T, String str) { + InterfaceType futureOrFunction(TypeImpl T, String str) { var result = futureOrNone( functionTypeNone(returnType: voidNone, parameters: [ requiredParameter(type: T), @@ -1488,7 +1489,7 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase { } test_parameters_optionalNamed() { - FunctionType build(Map namedTypes) { + FunctionType build(Map namedTypes) { return functionTypeNone( returnType: voidNone, parameters: namedTypes.entries.map((entry) { @@ -1497,8 +1498,8 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase { ); } - void check(Map T1_named, Map T2_named, - Map expected_named) { + void check(Map T1_named, Map T2_named, + Map expected_named) { var T1 = build(T1_named); var T2 = build(T2_named); var expected = build(expected_named); @@ -1515,7 +1516,7 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase { } test_parameters_optionalPositional() { - FunctionType build(List positionalTypes) { + FunctionType build(List positionalTypes) { return functionTypeNone( returnType: voidNone, parameters: positionalTypes.map((type) { @@ -1524,7 +1525,7 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase { ); } - void check(List T1_positional, List T2_positional, + void check(List T1_positional, List T2_positional, DartType expected) { var T1 = build(T1_positional); var T2 = build(T2_positional); @@ -1663,7 +1664,7 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase { } test_parameters_requiredPositional() { - FunctionType build(List requiredTypes) { + FunctionType build(List requiredTypes) { return functionTypeNone( returnType: voidNone, parameters: requiredTypes.map((type) { @@ -1672,7 +1673,7 @@ class UpperBound_FunctionTypes_Test extends _BoundsTestBase { ); } - void check(List T1_required, List T2_required, + void check(List T1_required, List T2_required, DartType expected) { var T1 = build(T1_required); var T2 = build(T2_required); diff --git a/pkg/analyzer_plugin/CHANGELOG.md b/pkg/analyzer_plugin/CHANGELOG.md index 2368dbea9844..e6778fa839ba 100644 --- a/pkg/analyzer_plugin/CHANGELOG.md +++ b/pkg/analyzer_plugin/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.13.0-dev +## 0.13.0 - Remove `elementName()` from `RangeFactory`. Use `fragmentName()` instead. - Breaking changes to `DartFileEditBuilder` and `DartEditBuilder`. - Breaking changes to `AnalyzerConverter`. diff --git a/pkg/analyzer_plugin/pubspec.yaml b/pkg/analyzer_plugin/pubspec.yaml index 1f35acbc9441..8e3300afd6a8 100644 --- a/pkg/analyzer_plugin/pubspec.yaml +++ b/pkg/analyzer_plugin/pubspec.yaml @@ -1,13 +1,13 @@ name: analyzer_plugin description: A framework and support code for building plugins for the analysis server. -version: 0.13.0-dev +version: 0.13.0 repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer_plugin environment: sdk: '^3.0.0' dependencies: - analyzer: ^7.0.0 + analyzer: ^7.2.0 collection: ^1.15.0 dart_style: '>=2.3.7 <4.0.0' pub_semver: ^2.1.0 diff --git a/pkg/dart2wasm/lib/param_info.dart b/pkg/dart2wasm/lib/param_info.dart index 2aeb82b38246..f4a6b02d8f91 100644 --- a/pkg/dart2wasm/lib/param_info.dart +++ b/pkg/dart2wasm/lib/param_info.dart @@ -16,7 +16,7 @@ class ParameterInfo { final List positional; /// Default values of named parameters. Similar to [positional], `null` means - /// the the parameter is not optional. + /// the parameter is not optional. final Map named; final bool takesContextOrReceiver; diff --git a/pkg/dartdev/lib/src/commands/build.dart b/pkg/dartdev/lib/src/commands/build.dart index 25ce5ccaee7b..386c2188215c 100644 --- a/pkg/dartdev/lib/src/commands/build.dart +++ b/pkg/dartdev/lib/src/commands/build.dart @@ -10,14 +10,9 @@ import 'package:dartdev/src/commands/compile.dart'; import 'package:dartdev/src/experiments.dart'; import 'package:dartdev/src/native_assets_bundling.dart'; import 'package:dartdev/src/sdk.dart'; -import 'package:dartdev/src/utils.dart'; -import 'package:file/local.dart'; import 'package:front_end/src/api_prototype/compiler_options.dart' show Verbosity; -import 'package:native_assets_builder/native_assets_builder.dart'; import 'package:native_assets_cli/code_assets_builder.dart'; -import 'package:native_assets_cli/data_assets_builder.dart'; -import 'package:package_config/package_config.dart' as package_config; import 'package:path/path.dart' as path; import 'package:vm/target_os.dart'; // For possible --target-os values. @@ -132,61 +127,23 @@ class BuildCommand extends DartdevCommand { } await outputDir.create(recursive: true); - // Start native asset generation here. stdout.writeln('Building native assets.'); - final packageConfig = await findPackageConfigUri(sourceUri); - final runPackageName = await findRootPackageName(sourceUri); - final workingDirectory = Directory.current.uri; - final packageLayout = PackageLayout.fromPackageConfig( - LocalFileSystem(), - await package_config.loadPackageConfigUri(packageConfig!), - packageConfig, + final packageConfig = await DartNativeAssetsBuilder.ensurePackageConfig( + sourceUri, ); - final target = Target.current; - final macOSConfig = target.os == OS.macOS - ? MacOSConfig(targetVersion: minimumSupportedMacOSVersion) - : null; - final nativeAssetsBuildRunner = NativeAssetsBuildRunner( - fileSystem: const LocalFileSystem(), - dartExecutable: Uri.file(sdk.dart), - logger: logger(verbose), + final runPackageName = await DartNativeAssetsBuilder.findRootPackageName( + sourceUri, ); - - final cCompilerConfig = getCCompilerConfig(); - - final buildResult = await nativeAssetsBuildRunner.build( - inputCreator: () => BuildInputBuilder() - ..config.setupCode( - targetOS: target.os, - linkModePreference: LinkModePreference.dynamic, - targetArchitecture: target.architecture, - macOS: macOSConfig, - cCompiler: cCompilerConfig, - ), - inputValidator: (config) async => [ - ...await validateDataAssetBuildInput(config), - ...await validateCodeAssetBuildInput(config), - ], - workingDirectory: workingDirectory, - packageLayout: packageLayout, - runPackageName: runPackageName, - linkingEnabled: true, - buildAssetTypes: [ - CodeAsset.type, - ], - buildValidator: (config, output) async => [ - ...await validateDataAssetBuildOutput(config, output), - ...await validateCodeAssetBuildOutput(config, output), - ], - applicationAssetValidator: (assets) async => [ - ...await validateCodeAssetInApplication(assets), - ], + final builder = DartNativeAssetsBuilder( + packageConfigUri: packageConfig!, + runPackageName: runPackageName!, + verbose: verbose, ); + final buildResult = await builder.buildNativeAssetsAOT(); if (buildResult == null) { stderr.writeln('Native assets build failed.'); return 255; } - // End native asset generation here. final tempDir = Directory.systemTemp.createTempSync(); try { @@ -211,38 +168,10 @@ class BuildCommand extends DartdevCommand { recordedUsagesFile: recordedUsagesPath, ); - // Start linking here. - final linkResult = await nativeAssetsBuildRunner.link( - inputCreator: () => LinkInputBuilder() - ..config.setupCode( - targetOS: target.os, - targetArchitecture: target.architecture, - linkModePreference: LinkModePreference.dynamic, - macOS: macOSConfig, - cCompiler: cCompilerConfig, - ), - inputValidator: (config) async => [ - ...await validateDataAssetLinkInput(config), - ...await validateCodeAssetLinkInput(config), - ], - resourceIdentifiers: - recordUseEnabled ? Uri.file(recordedUsagesPath!) : null, - workingDirectory: workingDirectory, - runPackageName: runPackageName, - packageLayout: packageLayout, + final linkResult = await builder.linkNativeAssetsAOT( + recordedUsagesPath: recordedUsagesPath, buildResult: buildResult, - buildAssetTypes: [ - CodeAsset.type, - ], - linkValidator: (config, output) async => [ - ...await validateDataAssetLinkOutput(config, output), - ...await validateCodeAssetLinkOutput(config, output), - ], - applicationAssetValidator: (assets) async => [ - ...await validateCodeAssetInApplication(assets), - ], ); - if (linkResult == null) { stderr.writeln('Native assets link failed.'); return 255; @@ -265,7 +194,7 @@ Use linkMode as dynamic library instead."""); if (allAssets.isNotEmpty) { final kernelAssets = await bundleNativeAssets( allAssets, - target, + builder.target, outputUri, relocatable: true, verbose: true, diff --git a/pkg/dartdev/lib/src/commands/compile.dart b/pkg/dartdev/lib/src/commands/compile.dart index 75cb77e9b9ad..1deb16e7d90c 100644 --- a/pkg/dartdev/lib/src/commands/compile.dart +++ b/pkg/dartdev/lib/src/commands/compile.dart @@ -558,23 +558,35 @@ Remove debugging information from the output and save it separately to the speci return compileErrorExitCode; } - if (!nativeAssetsExperimentEnabled) { - if (await warnOnNativeAssets()) { - return 255; - } - } else { - final assets = await compileNativeAssetsJit( - verbose: verbose, - runPackageName: await findRootPackageName(Directory.current.uri), + final packageConfig = await DartNativeAssetsBuilder.ensurePackageConfig( + Directory.current.uri, + ); + if (packageConfig != null) { + final runPackageName = await DartNativeAssetsBuilder.findRootPackageName( + Directory.current.uri, ); - if (assets == null) { - stderr.writeln('Native assets build failed.'); - return 255; - } - if (assets.isNotEmpty) { - stderr.writeln( - "'dart compile' does currently not support native assets."); - return 255; + if (runPackageName != null) { + final builder = DartNativeAssetsBuilder( + packageConfigUri: packageConfig, + runPackageName: runPackageName, + verbose: verbose, + ); + if (!nativeAssetsExperimentEnabled) { + if (await builder.warnOnNativeAssets()) { + return 255; + } + } else { + final assets = await builder.compileNativeAssetsJit(); + if (assets == null) { + stderr.writeln('Native assets build failed.'); + return 255; + } + if (assets.isNotEmpty) { + stderr.writeln( + "'dart compile' does currently not support native assets."); + return 255; + } + } } } @@ -859,7 +871,7 @@ class CompileWasmCommand extends CompileSubcommandCommand { flags.removeWhere((option) => option == '--no-$name'); flags.removeWhere((option) => option == '--$name'); - // Explicitly use the the flag value, irrespective of -O settings. + // Explicitly use the flag value, irrespective of -O settings. value ? flags.add('--$name') : flags.add('--no-$name'); } diff --git a/pkg/dartdev/lib/src/commands/language_server.dart b/pkg/dartdev/lib/src/commands/language_server.dart index 1e0ff3b08923..65ec6280ead8 100644 --- a/pkg/dartdev/lib/src/commands/language_server.dart +++ b/pkg/dartdev/lib/src/commands/language_server.dart @@ -52,7 +52,7 @@ For more information about the server's capabilities and configuration, see: sdk.analysisServerSnapshot, args, packageConfigOverride: null, - useExecProcess : false, + useExecProcess: false, ); return 0; } catch (e, st) { diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index cb288823221f..74817db53913 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -371,22 +371,34 @@ class RunCommand extends DartdevCommand { } String? nativeAssets; - if (!nativeAssetsExperimentEnabled) { - if (await warnOnNativeAssets()) { - return errorExitCode; - } - } else { + final packageConfig = await DartNativeAssetsBuilder.ensurePackageConfig( + Directory.current.uri, + ); + if (packageConfig != null) { final runPackageName = getPackageForCommand(mainCommand) ?? - await findRootPackageName(Directory.current.uri); - final assetsYamlFileUri = await compileNativeAssetsJitYamlFile( - verbose: verbose, - runPackageName: runPackageName, - ); - if (assetsYamlFileUri == null) { - log.stderr('Error: Compiling native assets failed.'); - return errorExitCode; + await DartNativeAssetsBuilder.findRootPackageName( + Directory.current.uri, + ); + if (runPackageName != null) { + final builder = DartNativeAssetsBuilder( + packageConfigUri: packageConfig, + runPackageName: runPackageName, + verbose: verbose, + ); + if (!nativeAssetsExperimentEnabled) { + if (await builder.warnOnNativeAssets()) { + return errorExitCode; + } + } else { + final assetsYamlFileUri = + await builder.compileNativeAssetsJitYamlFile(); + if (assetsYamlFileUri == null) { + log.stderr('Error: Compiling native assets failed.'); + return errorExitCode; + } + nativeAssets = assetsYamlFileUri.toFilePath(); + } } - nativeAssets = assetsYamlFileUri.toFilePath(); } final String? residentCompilerInfoFileArg = diff --git a/pkg/dartdev/lib/src/commands/test.dart b/pkg/dartdev/lib/src/commands/test.dart index 7a2ea6267361..cfa73eeb9132 100644 --- a/pkg/dartdev/lib/src/commands/test.dart +++ b/pkg/dartdev/lib/src/commands/test.dart @@ -47,21 +47,33 @@ Run "${runner!.executableName} help" to see global options.'''); final args = argResults!; String? nativeAssets; - if (!nativeAssetsExperimentEnabled) { - if (await warnOnNativeAssets()) { - return DartdevCommand.errorExitCode; - } - } else { - final assetsYamlFileUri = - await compileNativeAssetsJitYamlFile( - verbose: verbose, - runPackageName: await findRootPackageName(Directory.current.uri), + final packageConfig = await DartNativeAssetsBuilder.ensurePackageConfig( + Directory.current.uri, + ); + if (packageConfig != null) { + final runPackageName = await DartNativeAssetsBuilder.findRootPackageName( + Directory.current.uri, ); - if (assetsYamlFileUri == null) { - log.stderr('Error: Compiling native assets failed.'); - return DartdevCommand.errorExitCode; + if (runPackageName != null) { + final builder = DartNativeAssetsBuilder( + packageConfigUri: packageConfig, + runPackageName: runPackageName, + verbose: verbose, + ); + if (!nativeAssetsExperimentEnabled) { + if (await builder.warnOnNativeAssets()) { + return DartdevCommand.errorExitCode; + } + } else { + final assetsYamlFileUri = + await builder.compileNativeAssetsJitYamlFile(); + if (assetsYamlFileUri == null) { + log.stderr('Error: Compiling native assets failed.'); + return DartdevCommand.errorExitCode; + } + nativeAssets = assetsYamlFileUri.toFilePath(); + } } - nativeAssets = assetsYamlFileUri.toFilePath(); } try { diff --git a/pkg/dartdev/lib/src/native_assets.dart b/pkg/dartdev/lib/src/native_assets.dart index ad6c371315b8..014e189cc81d 100644 --- a/pkg/dartdev/lib/src/native_assets.dart +++ b/pkg/dartdev/lib/src/native_assets.dart @@ -18,228 +18,304 @@ import 'package:package_config/package_config.dart' as package_config; import 'core.dart'; -/// Compiles all native assets for host OS in JIT mode. -/// -/// If provided, only native assets of all transitive dependencies of -/// [runPackageName] are built. -Future?> compileNativeAssetsJit({ - required bool verbose, - required String runPackageName, -}) async { - final workingDirectory = Directory.current.uri; - var packageConfig = await findPackageConfigUri(workingDirectory); - // TODO(https://github.com/dart-lang/package_config/issues/126): Use - // package config resolution from package:package_config. - if (packageConfig == null) { - final pubspecMaybe = await _findPubspec(workingDirectory); - if (pubspecMaybe != null) { - // Silently run `pub get`, this is what would happen in - // `getExecutableForCommand` later. - final result = await Process.run(sdk.dart, ['pub', 'get']); - if (result.exitCode != 0) { - return null; +class DartNativeAssetsBuilder { + final Uri packageConfigUri; + final String runPackageName; + final bool verbose; + + static const _fileSystem = LocalFileSystem(); + + late final Future _packageLayout = () async { + return PackageLayout.fromPackageConfig( + _fileSystem, + await package_config.loadPackageConfigUri(packageConfigUri), + packageConfigUri, + runPackageName, + ); + }(); + + late final _logger = Logger('') + ..onRecord.listen((LogRecord record) { + final levelValue = record.level.value; + if (levelValue >= Level.SEVERE.value) { + log.stderr(record.message); + } else if (levelValue >= Level.WARNING.value || + verbose && levelValue >= Level.INFO.value) { + log.stdout(record.message); + } else { + // Note, this is ignored by default. + log.trace(record.message); } - packageConfig = await findPackageConfigUri(workingDirectory); - } else { - return null; - } + }); + + late final Future _nativeAssetsBuildRunner = + () async { + return NativeAssetsBuildRunner( + // This always runs in JIT mode. + dartExecutable: Uri.file(sdk.dart), + logger: _logger, + fileSystem: const LocalFileSystem(), + packageLayout: await _packageLayout, + ); + }(); + + DartNativeAssetsBuilder({ + required this.packageConfigUri, + required this.runPackageName, + required this.verbose, + }); + + /// Compiles all native assets for host OS in JIT mode. + /// + /// If provided, only native assets of all transitive dependencies of + /// [runPackageName] are built. + Future?> compileNativeAssetsJit() async { + final buildResult = await _buildNativeAssetsShared(linkingEnabled: false); + if (buildResult == null) return null; + return buildResult.encodedAssets; } - final packageLayout = PackageLayout.fromPackageConfig( - LocalFileSystem(), - await package_config.loadPackageConfigUri(packageConfig!), - packageConfig, - ); - final nativeAssetsBuildRunner = NativeAssetsBuildRunner( - // This always runs in JIT mode. - dartExecutable: Uri.file(sdk.dart), - logger: logger(verbose), - fileSystem: const LocalFileSystem(), - ); - final target = Target.current; - final macOSConfig = target.os == OS.macOS - ? MacOSConfig(targetVersion: minimumSupportedMacOSVersion) - : null; - final cCompilerConfig = getCCompilerConfig(); - final buildResult = await nativeAssetsBuildRunner.build( - inputCreator: () => BuildInputBuilder() - ..config.setupCode( - targetOS: target.os, - targetArchitecture: target.architecture, - // When running in JIT mode, only dynamic libraries are supported. - linkModePreference: LinkModePreference.dynamic, - macOS: macOSConfig, - cCompiler: cCompilerConfig, - ), - inputValidator: (config) async => [ - ...await validateCodeAssetBuildInput(config), - ...await validateDataAssetBuildInput(config), - ], - workingDirectory: workingDirectory, - runPackageName: runPackageName, - packageLayout: packageLayout, - linkingEnabled: false, - buildAssetTypes: [ - CodeAsset.type, - ], - buildValidator: (config, output) async => [ - ...await validateDataAssetBuildOutput(config, output), - ...await validateCodeAssetBuildOutput(config, output), - ], - applicationAssetValidator: (assets) async => [ - ...await validateCodeAssetInApplication(assets), - ], - ); - if (buildResult == null) return null; - return buildResult.encodedAssets; -} -/// Compiles all native assets for host OS in JIT mode, and creates the -/// native assets yaml file. -/// -/// If provided, only native assets of all transitive dependencies of -/// [runPackageName] are built. -/// -/// Used in `dart run` and `dart test`. -Future compileNativeAssetsJitYamlFile({ - required bool verbose, - required String runPackageName, -}) async { - final assets = await compileNativeAssetsJit( - verbose: verbose, - runPackageName: runPackageName, - ); - if (assets == null) return null; - - final dartToolUri = Directory.current.uri.resolve('.dart_tool/'); - final outputUri = dartToolUri.resolve('native_assets/'); - await Directory.fromUri(outputUri).create(recursive: true); - - final kernelAssets = await bundleNativeAssets( - assets, - Target.current, - outputUri, - relocatable: false, - ); - - return await writeNativeAssetsYaml( - kernelAssets, - dartToolUri, - header: '''# Native assets mapping for host OS in JIT mode. + /// Compiles all native assets for host OS in JIT mode, and creates the + /// native assets yaml file. + /// + /// If provided, only native assets of all transitive dependencies of + /// [runPackageName] are built. + /// + /// Used in `dart run` and `dart test`. + Future compileNativeAssetsJitYamlFile() async { + final assets = await compileNativeAssetsJit(); + if (assets == null) return null; + + final dartToolUri = Directory.current.uri.resolve('.dart_tool/'); + final outputUri = dartToolUri.resolve('native_assets/'); + await Directory.fromUri(outputUri).create(recursive: true); + + final kernelAssets = await bundleNativeAssets( + assets, + Target.current, + outputUri, + relocatable: false, + ); + + return await writeNativeAssetsYaml( + kernelAssets, + dartToolUri, + header: '''# Native assets mapping for host OS in JIT mode. # Generated by dartdev and package:native_assets_builder. ''', - ); -} - -Future warnOnNativeAssets() async { - final workingDirectory = Directory.current.uri; - if (!await File.fromUri( - workingDirectory.resolve('.dart_tool/package_config.json')) - .exists()) { - // If `pub get` hasn't run, we can't know, so don't error. - return false; - } - try { - final packageLayout = - await PackageLayout.fromWorkingDirectory( - const LocalFileSystem(), - workingDirectory, ); - final packagesWithNativeAssets = [ - ...await packageLayout.packagesWithAssets(Hook.build), - ...await packageLayout.packagesWithAssets(Hook.link) - ]; - if (packagesWithNativeAssets.isEmpty) { - return false; + } + + Future warnOnNativeAssets() async { + final workingDirectory = Directory.current.uri; + + try { + final packageLayout = await PackageLayout.fromWorkingDirectory( + _fileSystem, + workingDirectory, + runPackageName, + ); + final packagesWithNativeAssets = [ + ...await packageLayout.packagesWithAssets(Hook.build), + ...await packageLayout.packagesWithAssets(Hook.link) + ]; + if (packagesWithNativeAssets.isEmpty) { + return false; + } + final packageNames = + packagesWithNativeAssets.map((p) => p.name).join(' '); + log.stderr( + 'Package(s) $packageNames require the native assets feature to be enabled. ' + 'Enable native assets with `--enable-experiment=native-assets`.', + ); + } on FormatException catch (e) { + // This can be thrown if the package_config.json is malformed or has + // duplicate entries. + log.stderr( + 'Error encountered while parsing package_config.json: ${e.message}', + ); } - final packageNames = packagesWithNativeAssets.map((p) => p.name).join(' '); - log.stderr( - 'Package(s) $packageNames require the native assets feature to be enabled. ' - 'Enable native assets with `--enable-experiment=native-assets`.', - ); - } on FormatException catch (e) { - // This can be thrown if the package_config.json is malformed or has - // duplicate entries. - log.stderr( - 'Error encountered while parsing package_config.json: ${e.message}', + return true; + } + + Future _buildNativeAssetsShared({ + required bool linkingEnabled, + }) async { + final buildResult = await (await _nativeAssetsBuildRunner).build( + inputCreator: () => BuildInputBuilder() + ..config.setupCode( + targetOS: target.os, + linkModePreference: LinkModePreference.dynamic, + targetArchitecture: target.architecture, + macOS: _macOSConfig, + cCompiler: _cCompilerConfig, + ), + inputValidator: (config) async => [ + ...await validateDataAssetBuildInput(config), + ...await validateCodeAssetBuildInput(config), + ], + linkingEnabled: linkingEnabled, + buildAssetTypes: [ + CodeAsset.type, + ], + buildValidator: (config, output) async => [ + ...await validateDataAssetBuildOutput(config, output), + ...await validateCodeAssetBuildOutput(config, output), + ], + applicationAssetValidator: (assets) async => [ + ...await validateCodeAssetInApplication(assets), + ], ); + return buildResult; } - return true; -} -Logger logger(bool verbose) => Logger('') - ..onRecord.listen((LogRecord record) { - final levelValue = record.level.value; - if (levelValue >= Level.SEVERE.value) { - log.stderr(record.message); - } else if (levelValue >= Level.WARNING.value || - verbose && levelValue >= Level.INFO.value) { - log.stdout(record.message); - } else { - // Note, this is ignored by default. - log.trace(record.message); - } - }); + Future buildNativeAssetsAOT() { + return _buildNativeAssetsShared(linkingEnabled: true); + } -CCompilerConfig? getCCompilerConfig() { - // Specifically for running our tests on Dart CI with the test runner, we - // recognize specific variables to setup the C Compiler configuration. - final env = Platform.environment; - final cc = env['DART_HOOK_TESTING_C_COMPILER__CC']; - final ar = env['DART_HOOK_TESTING_C_COMPILER__AR']; - final ld = env['DART_HOOK_TESTING_C_COMPILER__LD']; - final envScript = env['DART_HOOK_TESTING_C_COMPILER__ENV_SCRIPT']; - final envScriptArgs = - env['DART_HOOK_TESTING_C_COMPILER__ENV_SCRIPT_ARGUMENTS'] - ?.split(' ') - .map((arg) => arg.trim()) - .where((arg) => arg.isNotEmpty) - .toList(); - final hasEnvScriptArgs = envScriptArgs != null && envScriptArgs.isNotEmpty; - - if (cc != null && ar != null && ld != null) { - return CCompilerConfig( - archiver: Uri.file(ar), - compiler: Uri.file(cc), - envScript: envScript != null ? Uri.file(envScript) : null, - envScriptArgs: hasEnvScriptArgs ? envScriptArgs : null, - linker: Uri.file(ld), + Future linkNativeAssetsAOT({ + required String? recordedUsagesPath, + required BuildResult buildResult, + }) async { + final linkResult = await (await _nativeAssetsBuildRunner).link( + inputCreator: () => LinkInputBuilder() + ..config.setupCode( + targetOS: target.os, + targetArchitecture: target.architecture, + linkModePreference: LinkModePreference.dynamic, + macOS: _macOSConfig, + cCompiler: _cCompilerConfig, + ), + inputValidator: (config) async => [ + ...await validateDataAssetLinkInput(config), + ...await validateCodeAssetLinkInput(config), + ], + resourceIdentifiers: + recordedUsagesPath != null ? Uri.file(recordedUsagesPath) : null, + buildResult: buildResult, + buildAssetTypes: [ + CodeAsset.type, + ], + linkValidator: (config, output) async => [ + ...await validateDataAssetLinkOutput(config, output), + ...await validateCodeAssetLinkOutput(config, output), + ], + applicationAssetValidator: (assets) async => [ + ...await validateCodeAssetInApplication(assets), + ], ); + return linkResult; } - return null; -} -// TODO(https://github.com/dart-lang/package_config/issues/126): Expose this -// logic in package:package_config. -Future findPackageConfigUri(Uri uri) async { - while (true) { - final candidate = uri.resolve('.dart_tool/package_config.json'); - final file = File.fromUri(candidate); - if (await file.exists()) { - return file.uri; + /// Dart does not do cross compilation. Target is always host. + late final target = Target.current; + + late final _macOSConfig = target.os == OS.macOS + ? MacOSCodeConfig(targetVersion: minimumSupportedMacOSVersion) + : null; + + late final _cCompilerConfig = _getCCompilerConfig(target.os); + + CCompilerConfig? _getCCompilerConfig(OS targetOS) { + // Specifically for running our tests on Dart CI with the test runner, we + // recognize specific variables to setup the C Compiler configuration. + final env = Platform.environment; + final cc = env['DART_HOOK_TESTING_C_COMPILER__CC']; + final ar = env['DART_HOOK_TESTING_C_COMPILER__AR']; + final ld = env['DART_HOOK_TESTING_C_COMPILER__LD']; + final envScript = env['DART_HOOK_TESTING_C_COMPILER__ENV_SCRIPT']; + final envScriptArgs = + env['DART_HOOK_TESTING_C_COMPILER__ENV_SCRIPT_ARGUMENTS'] + ?.split(' ') + .map((arg) => arg.trim()) + .where((arg) => arg.isNotEmpty) + .toList(); + if (cc != null && ar != null && ld != null) { + return CCompilerConfig( + archiver: Uri.file(ar), + compiler: Uri.file(cc), + linker: Uri.file(ld), + windows: targetOS == OS.windows + ? WindowsCCompilerConfig( + developerCommandPrompt: envScript == null + ? null + : DeveloperCommandPrompt( + script: Uri.file(envScript), + arguments: envScriptArgs ?? [], + ), + ) + : null, + ); } - final parent = uri.resolve('..'); - if (parent == uri) { - return null; + return null; + } + + /// Runs `pub get` if no package config can be found. + /// + /// Returns `null` if no package config can be found, even after pub get. + static Future ensurePackageConfig(Uri uri) async { + var packageConfig = await _findPackageConfigUri(uri); + // TODO(https://github.com/dart-lang/package_config/issues/126): Use + // package config resolution from package:package_config. + if (packageConfig == null) { + final pubspecMaybe = await _findPubspec(uri); + if (pubspecMaybe != null) { + // Silently run `pub get`, this is what would happen in + // `getExecutableForCommand` later. + final result = await Process.run(sdk.dart, ['pub', 'get']); + if (result.exitCode != 0) { + return null; + } + packageConfig = await _findPackageConfigUri(uri); + } else { + return null; + } } - uri = parent; + return packageConfig; } -} -Future _findPubspec(Uri uri) async { - while (true) { - final candidate = uri.resolve('pubspec.yaml'); - if (await File.fromUri(candidate).exists()) { - return candidate; + /// Finds the package config uri. + /// + /// Returns `null` if no package config can be found. + // TODO(https://github.com/dart-lang/package_config/issues/126): Expose this + // logic in package:package_config. + static Future _findPackageConfigUri(Uri uri) async { + while (true) { + final candidate = uri.resolve('.dart_tool/package_config.json'); + final file = File.fromUri(candidate); + if (await file.exists()) { + return file.uri; + } + final parent = uri.resolve('..'); + if (parent == uri) { + return null; + } + uri = parent; } - final parent = uri.resolve('..'); - if (parent == uri) { - return null; + } + + static Future _findPubspec(Uri uri) async { + while (true) { + final candidate = uri.resolve('pubspec.yaml'); + if (await File.fromUri(candidate).exists()) { + return candidate; + } + final parent = uri.resolve('..'); + if (parent == uri) { + return null; + } + uri = parent; } - uri = parent; } -} -Future findRootPackageName(Uri uri) async { - final pubspec = await _findPubspec(uri); - return pubspec!.resolve('./').pathSegments.lastWhere((e) => e.isNotEmpty); + /// Tries to find the package name that [uri] is in. + /// + /// Returns `null` if package cannnot be determined. + static Future findRootPackageName(Uri uri) async { + final pubspec = await _findPubspec(uri); + if (pubspec == null) { + return null; + } + return pubspec.resolve('./').pathSegments.lastWhere((e) => e.isNotEmpty); + } } diff --git a/pkg/dartdev/lib/src/resident_frontend_utils.dart b/pkg/dartdev/lib/src/resident_frontend_utils.dart index 2e545c73a2b6..7fff6dbb17d9 100644 --- a/pkg/dartdev/lib/src/resident_frontend_utils.dart +++ b/pkg/dartdev/lib/src/resident_frontend_utils.dart @@ -89,7 +89,7 @@ Future isFileAppJitSnapshot(final File file) async { } Future isFileAotSnapshot(final File file) async { - // Check for any of the the magic numbers that can be found at the start of an + // Check for any of the magic numbers that can be found at the start of an // AOT snapshot. final bytes = await file.openRead(0, 4).expand((i) => i).toList(); diff --git a/pkg/dartdev/lib/src/vm_interop_handler.dart b/pkg/dartdev/lib/src/vm_interop_handler.dart index 79f705e5af0b..169c62adc0fc 100644 --- a/pkg/dartdev/lib/src/vm_interop_handler.dart +++ b/pkg/dartdev/lib/src/vm_interop_handler.dart @@ -54,7 +54,7 @@ abstract class VmInteropHandler { final port = _port; if (port == null) return; final message = [ - useExecProcess? _kResultRunExec : _kResultRun, + useExecProcess ? _kResultRunExec : _kResultRun, script, packageConfigOverride, markMainIsolateAsSystemIsolate, diff --git a/pkg/dds/lib/src/dap_handler.dart b/pkg/dds/lib/src/dap_handler.dart index 97e188b43ab2..32ce9e9e95b2 100644 --- a/pkg/dds/lib/src/dap_handler.dart +++ b/pkg/dds/lib/src/dap_handler.dart @@ -31,10 +31,10 @@ class DapHandler { final message = parameters['message'].asString; // TODO(dantup): If/when DAP needs to care about ordering (eg. it handles - // both requests and events), this will need to be changed to have the - // caller provide a "responseWriter" function so the the result can be - // written directly to the stream synchronously, to avoid future events - // being able to be inserted before the response (eg. initializedEvent). + // both requests and events), this will need to be changed to have the + // caller provide a "responseWriter" function so the result can be written + // directly to the stream synchronously, to avoid future events being able + // to be inserted before the response (eg. initializedEvent). final responseCompleter = Completer(); adapter.handleMessage(message, responseCompleter.complete); final result = await responseCompleter.future; @@ -70,7 +70,7 @@ class DapHandler { // Each DAP request has a `seq` number (essentially a message ID) which // should be unique. // - // We send a few requsets to initialize the adapter, but these are not + // We send a few requests to initialize the adapter, but these are not // visible to the DDS client so if we start at 1, the IDs will be // reused. // diff --git a/pkg/dtd_impl/dtd_protocol.md b/pkg/dtd_impl/dtd_protocol.md index 771100f8e0a2..be389706de1f 100644 --- a/pkg/dtd_impl/dtd_protocol.md +++ b/pkg/dtd_impl/dtd_protocol.md @@ -661,7 +661,7 @@ If _uri_ does not have a 'file' scheme, the 143 (File scheme expected on uri) ### IDE Workspace Roots -The IDE workspace roots are used to ensure the the `FileSystem` service methods +The IDE workspace roots are used to ensure the `FileSystem` service methods do not perform file operations in areas outside of the IDE workspace roots. When the Dart Tooling Daemon is started, a secret is generated and presented to diff --git a/pkg/front_end/testcases/incremental/change_entry_with_advanced_invalidation.yaml b/pkg/front_end/testcases/incremental/change_entry_with_advanced_invalidation.yaml index da61a2cff8bc..3374d00d2926 100644 --- a/pkg/front_end/testcases/incremental/change_entry_with_advanced_invalidation.yaml +++ b/pkg/front_end/testcases/incremental/change_entry_with_advanced_invalidation.yaml @@ -2,7 +2,7 @@ # 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. -# If changing the the entry and marking the previous entry as changed but where +# If changing the entry and marking the previous entry as changed but where # the previous entry is no longer used (and reference another library only that # one uses) we have come into a situation where we'll keep something we # shouldn't, which (on top of being bad in itself) can lead to problems if we diff --git a/pkg/front_end/tool/benchmarker.dart b/pkg/front_end/tool/benchmarker.dart index 770aea3c43c9..6ce70524191a 100644 --- a/pkg/front_end/tool/benchmarker.dart +++ b/pkg/front_end/tool/benchmarker.dart @@ -83,7 +83,7 @@ void main(List args) { } if (warnings.scalingInEffect) { - print("Be aware the the above was with scaling in effect."); + print("Be aware that the above was with scaling in effect."); print("As such the results are likely useless."); print("Possibly some other process is using the hardware counters."); print("Running this tool"); diff --git a/pkg/linter/lib/src/rules/invalid_runtime_check_with_js_interop_types.dart b/pkg/linter/lib/src/rules/invalid_runtime_check_with_js_interop_types.dart index 7bbc6a4e74f1..4eeadde9ff5c 100644 --- a/pkg/linter/lib/src/rules/invalid_runtime_check_with_js_interop_types.dart +++ b/pkg/linter/lib/src/rules/invalid_runtime_check_with_js_interop_types.dart @@ -85,9 +85,10 @@ bool _isWasmIncompatibleJsInterop(DartType type) { // what we want here. if (element.metadata2.hasJS) return true; return _sdkWebLibraries.any((uri) => element.isFromLibrary(uri)) || - // While a type test with types from this library is very rare, we should - // still ignore it for consistency. - element.isFromLibrary(_dartJsUri); + // While a type test with types from this library is very rare, we should + // still ignore it for consistency. + element + .isFromLibrary(_dartJsUri); } /// If [type] is a type declared using `@staticInterop` through @@ -137,7 +138,7 @@ class EraseNonJSInteropTypes extends ExtensionTypeErasure { final _visitedTypes = {}; @override - DartType perform(DartType type, {bool keepUserInteropTypes = false}) { + TypeImpl perform(TypeImpl type, {bool keepUserInteropTypes = false}) { _keepUserInteropTypes = keepUserInteropTypes; _visitedTypes.clear(); return super.perform(type); @@ -296,11 +297,14 @@ class _Visitor extends SimpleAstVisitor { }) { LintCode? lintCode; (DartType, DartType) eraseTypes(DartType left, DartType right) { + // Note: type casts are needed here because `EraseNonJSInteropTypes` + // extends the analyzer's private class `ExtensionTypeErasure`, which uses + // `TypeImpl` rather than `DartType`. DartType erasedLeft = typeSystem.promoteToNonNull( - eraseNonJsInteropTypes.perform(left), + eraseNonJsInteropTypes.perform(left as TypeImpl), ); DartType erasedRight = typeSystem.promoteToNonNull( - eraseNonJsInteropTypes.perform(right), + eraseNonJsInteropTypes.perform(right as TypeImpl), ); var leftIsInteropType = _isJsInteropType( erasedLeft, diff --git a/pkg/linter/messages.yaml b/pkg/linter/messages.yaml index 91e0b7f9dd74..f76d0fc3aa7b 100644 --- a/pkg/linter/messages.yaml +++ b/pkg/linter/messages.yaml @@ -286,7 +286,7 @@ LintCode: const int quux = 20; ``` - NOTE: Using the the `@optionalTypeArgs` annotation in the `meta` package, API + NOTE: Using the `@optionalTypeArgs` annotation in the `meta` package, API authors can special-case type parameters whose type needs to be dynamic but whose declaration should be treated as optional. For example, suppose you have a `Key` object whose type parameter you'd like to treat as optional. Using the @@ -4692,7 +4692,7 @@ LintCode: it's possible, or open an issue asking the package authors to make it part of the public API. deprecatedDetails: |- - From the the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files): + From the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files): **DON'T** import implementation files from another package. diff --git a/pkg/linter/tool/machine/rules.json b/pkg/linter/tool/machine/rules.json index b84502f028f7..23413cdf9df2 100644 --- a/pkg/linter/tool/machine/rules.json +++ b/pkg/linter/tool/machine/rules.json @@ -65,7 +65,7 @@ ], "sets": [], "fixStatus": "hasFix", - "details": "From the [style guide for the flutter repo](https://flutter.dev/style-guide/):\n\n**DO** specify type annotations.\n\nAvoid `var` when specifying that a type is unknown and short-hands that elide\ntype annotations. Use `dynamic` if you are being explicit that the type is\nunknown. Use `Object` if you are being explicit that you want an object that\nimplements `==` and `hashCode`.\n\n**BAD:**\n```dart\nvar foo = 10;\nfinal bar = Bar();\nconst quux = 20;\n```\n\n**GOOD:**\n```dart\nint foo = 10;\nfinal Bar bar = Bar();\nString baz = 'hello';\nconst int quux = 20;\n```\n\nNOTE: Using the the `@optionalTypeArgs` annotation in the `meta` package, API\nauthors can special-case type parameters whose type needs to be dynamic but whose\ndeclaration should be treated as optional. For example, suppose you have a\n`Key` object whose type parameter you'd like to treat as optional. Using the\n`@optionalTypeArgs` would look like this:\n\n```dart\nimport 'package:meta/meta.dart';\n\n@optionalTypeArgs\nclass Key {\n ...\n}\n\nvoid main() {\n Key s = Key(); // OK!\n}\n```", + "details": "From the [style guide for the flutter repo](https://flutter.dev/style-guide/):\n\n**DO** specify type annotations.\n\nAvoid `var` when specifying that a type is unknown and short-hands that elide\ntype annotations. Use `dynamic` if you are being explicit that the type is\nunknown. Use `Object` if you are being explicit that you want an object that\nimplements `==` and `hashCode`.\n\n**BAD:**\n```dart\nvar foo = 10;\nfinal bar = Bar();\nconst quux = 20;\n```\n\n**GOOD:**\n```dart\nint foo = 10;\nfinal Bar bar = Bar();\nString baz = 'hello';\nconst int quux = 20;\n```\n\nNOTE: Using the `@optionalTypeArgs` annotation in the `meta` package, API\nauthors can special-case type parameters whose type needs to be dynamic but whose\ndeclaration should be treated as optional. For example, suppose you have a\n`Key` object whose type parameter you'd like to treat as optional. Using the\n`@optionalTypeArgs` would look like this:\n\n```dart\nimport 'package:meta/meta.dart';\n\n@optionalTypeArgs\nclass Key {\n ...\n}\n\nvoid main() {\n Key s = Key(); // OK!\n}\n```", "sinceDartSdk": "2.0" }, { @@ -1117,7 +1117,7 @@ "incompatible": [], "sets": [], "fixStatus": "noFix", - "details": "From the the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files):\n\n**DON'T** import implementation files from another package.\n\nThe libraries inside `lib` are publicly visible: other packages are free to\nimport them. But much of a package's code is internal implementation libraries\nthat should only be imported and used by the package itself. Those go inside a\nsubdirectory of `lib` called `src`. You can create subdirectories in there if\nit helps you organize things.\n\nYou are free to import libraries that live in `lib/src` from within other Dart\ncode in the same package (like other libraries in `lib`, scripts in `bin`,\nand tests) but you should never import from another package's `lib/src`\ndirectory. Those files are not part of the package's public API, and they\nmight change in ways that could break your code.\n\n**BAD:**\n```dart\n// In 'road_runner'\nimport 'package:acme/src/internals.dart';\n```", + "details": "From the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files):\n\n**DON'T** import implementation files from another package.\n\nThe libraries inside `lib` are publicly visible: other packages are free to\nimport them. But much of a package's code is internal implementation libraries\nthat should only be imported and used by the package itself. Those go inside a\nsubdirectory of `lib` called `src`. You can create subdirectories in there if\nit helps you organize things.\n\nYou are free to import libraries that live in `lib/src` from within other Dart\ncode in the same package (like other libraries in `lib`, scripts in `bin`,\nand tests) but you should never import from another package's `lib/src`\ndirectory. Those files are not part of the package's public API, and they\nmight change in ways that could break your code.\n\n**BAD:**\n```dart\n// In 'road_runner'\nimport 'package:acme/src/internals.dart';\n```", "sinceDartSdk": "2.0" }, { @@ -3263,4 +3263,4 @@ "details": "**DON'T** assign to `void`.\n\n**BAD:**\n```dart\nclass A {\n T value;\n void test(T arg) { }\n}\n\nvoid main() {\n A a = A();\n a.value = 1; // LINT\n a.test(1); // LINT\n}\n```", "sinceDartSdk": "2.0" } -] \ No newline at end of file +] diff --git a/pkg/vm_service/example/vm_service_tester.dart b/pkg/vm_service/example/vm_service_tester.dart index 3311b7fa0d11..19c8edc57ce0 100644 --- a/pkg/vm_service/example/vm_service_tester.dart +++ b/pkg/vm_service/example/vm_service_tester.dart @@ -2,7 +2,7 @@ // 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. -/// An example of using the the libraries provided by `package:vm_service`. +/// An example of using the libraries provided by `package:vm_service`. library; import 'dart:async'; diff --git a/runtime/docs/contributing_to_dart_ffi.md b/runtime/docs/contributing_to_dart_ffi.md index 9128c8a319a9..b5c5cb5558b7 100644 --- a/runtime/docs/contributing_to_dart_ffi.md +++ b/runtime/docs/contributing_to_dart_ffi.md @@ -195,7 +195,7 @@ Running the CFE on a Dart file can be done with the following configuration. You can read more about kernel format in the [VM readme](https://github.com/dart-lang/sdk/blob/main/runtime/docs/README.md). -# Contributing to the the Dart FFI implementation in the VM +# Contributing to the Dart FFI implementation in the VM In order to be able to work on the VM implementation of Dart FFI, you first need to familiarize yourself with the Dart VM: diff --git a/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart b/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart index 6306569bce72..1d5823f0e0d9 100644 --- a/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart +++ b/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart @@ -973,7 +973,7 @@ rti.Rti getRtiForRecord(Object? record) { /// /// Care needs to taken to ensure that the runtime does not get caught telling /// lies. Generally, a class's `runtimeType` lies by returning an abstract -/// supertype of the class. Since both the the marker interface and `get +/// supertype of the class. Since both the marker interface and `get /// runtimeType` are inherited, there should be no way in which a user can /// extend the class or implement interface of the class. // TODO(48585): Move this class back to the dart:_rti library when old DDC diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart index e23914d68a56..cc4d44ea99d7 100644 --- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart +++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart @@ -3564,7 +3564,7 @@ void Function(T)? wrapZoneUnaryCallback(void Function(T)? callback) { /// /// Care needs to taken to ensure that the runtime does not get caught telling /// lies. Generally, a class's `runtimeType` lies by returning an abstract -/// supertype of the class. Since both the the marker interface and `get +/// supertype of the class. Since both the marker interface and `get /// runtimeType` are inherited, there should be no way in which a user can /// extend the class or implement interface of the class. // TODO(48585): Move this class back to the dart:_rti library when old DDC diff --git a/sdk/lib/developer/developer.dart b/sdk/lib/developer/developer.dart index 36d22057949d..7b6b890e6d24 100644 --- a/sdk/lib/developer/developer.dart +++ b/sdk/lib/developer/developer.dart @@ -28,7 +28,7 @@ /// final someInterestingValue = 1000; /// while (true) { /// if (counter == someInterestingValue) { -/// // Trigger a breakpoint in the the debugger. +/// // Trigger a breakpoint in the debugger. /// debugger(); /// } /// counter++; diff --git a/tests/lib/js/static_interop_test/js_array_impl_test.dart b/tests/lib/js/static_interop_test/js_array_impl_test.dart index 62a09f9179a3..ced151091f5c 100644 --- a/tests/lib/js/static_interop_test/js_array_impl_test.dart +++ b/tests/lib/js/static_interop_test/js_array_impl_test.dart @@ -472,7 +472,7 @@ void main() { runAllTests(); } -// Will swap the first and last items in a list, while leaving the the middle +// Will swap the first and last items in a list, while leaving the middle // elements in place because they will be swapped and then swapped back as // shuffle iterates through the list. class MockRandom implements Random { diff --git a/tests/lib/js/static_interop_test/js_types_test.dart b/tests/lib/js/static_interop_test/js_types_test.dart index 296913db7aee..385b170c8119 100644 --- a/tests/lib/js/static_interop_test/js_types_test.dart +++ b/tests/lib/js/static_interop_test/js_types_test.dart @@ -264,7 +264,7 @@ void syncTests() { dartArr = arr.toDart; dartArrN = arrN.toDart; if (isJSBackend) { - // A cast-list should not be introduced if the the array is already the + // A cast-list should not be introduced if the array is already the // right list type. expect(dartArr, listN); expect(dartArrN, listN); diff --git a/tools/VERSION b/tools/VERSION index e6722f1a86b5..80b9010929ae 100644 --- a/tools/VERSION +++ b/tools/VERSION @@ -27,5 +27,5 @@ CHANNEL dev MAJOR 3 MINOR 8 PATCH 0 -PRERELEASE 19 +PRERELEASE 20 PRERELEASE_PATCH 0