[cfe] Rename LibraryBuilder getters to [libraryBuilder]
Change-Id: I13ebe337ee3c032b02c6a4e437762ccc2ddfedde Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237692 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
committed by
Commit Bot
parent
a4929aed29
commit
c4eb880cac
@@ -197,7 +197,7 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
|
||||
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
|
||||
{bool isSetter: false}) {
|
||||
if (accessingLibrary.nameOriginBuilder.origin !=
|
||||
library.nameOriginBuilder.origin &&
|
||||
libraryBuilder.nameOriginBuilder.origin &&
|
||||
name.startsWith("_")) {
|
||||
return null;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
|
||||
MemberBuilder? findConstructorOrFactory(
|
||||
String name, int charOffset, Uri uri, LibraryBuilder accessingLibrary) {
|
||||
if (accessingLibrary.nameOriginBuilder.origin !=
|
||||
library.nameOriginBuilder.origin &&
|
||||
libraryBuilder.nameOriginBuilder.origin &&
|
||||
name.startsWith("_")) {
|
||||
return null;
|
||||
}
|
||||
@@ -270,8 +270,8 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
|
||||
|
||||
@override
|
||||
InterfaceType get thisType {
|
||||
return _thisType ??= new InterfaceType(cls, library.nonNullable,
|
||||
getAsTypeArguments(cls.typeParameters, library.library));
|
||||
return _thisType ??= new InterfaceType(cls, libraryBuilder.nonNullable,
|
||||
getAsTypeArguments(cls.typeParameters, libraryBuilder.library));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -406,7 +406,7 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
|
||||
: hierarchy.getInterfaceMember(instanceClass, name, setter: isSetter);
|
||||
if (isSuper && target == null) {
|
||||
if (cls.isMixinDeclaration ||
|
||||
(library.loader.target.backendTarget.enableSuperMixins &&
|
||||
(libraryBuilder.loader.target.backendTarget.enableSuperMixins &&
|
||||
this.isAbstract)) {
|
||||
target =
|
||||
hierarchy.getInterfaceMember(instanceClass, name, setter: isSetter);
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'type_declaration_builder.dart';
|
||||
abstract class DeclarationBuilder implements TypeDeclarationBuilder {
|
||||
Scope get scope;
|
||||
|
||||
LibraryBuilder get library;
|
||||
LibraryBuilder get libraryBuilder;
|
||||
|
||||
/// Lookup a member accessed statically through this declaration.
|
||||
Builder? findStaticBuilder(
|
||||
@@ -54,7 +54,7 @@ abstract class DeclarationBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
super(metadata, modifiers, name, parent, charOffset);
|
||||
|
||||
@override
|
||||
LibraryBuilder get library {
|
||||
LibraryBuilder get libraryBuilder {
|
||||
LibraryBuilder library = parent as LibraryBuilder;
|
||||
return library.partOfLibrary ?? library;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ abstract class DeclarationBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
@override
|
||||
void addProblem(Message message, int charOffset, int length,
|
||||
{bool wasHandled: false, List<LocatedMessage>? context}) {
|
||||
library.addProblem(message, charOffset, length, fileUri,
|
||||
libraryBuilder.addProblem(message, charOffset, length, fileUri,
|
||||
wasHandled: wasHandled, context: context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ abstract class ExtensionBuilderImpl extends DeclarationBuilderImpl
|
||||
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
|
||||
{bool isSetter: false}) {
|
||||
if (accessingLibrary.nameOriginBuilder.origin !=
|
||||
library.nameOriginBuilder.origin &&
|
||||
libraryBuilder.nameOriginBuilder.origin &&
|
||||
name.startsWith("_")) {
|
||||
return null;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ abstract class ExtensionBuilderImpl extends DeclarationBuilderImpl
|
||||
}
|
||||
}
|
||||
if (builder != null) {
|
||||
if (name.isPrivate && library.library != name.library) {
|
||||
if (name.isPrivate && libraryBuilder.library != name.library) {
|
||||
builder = null;
|
||||
} else if (builder is FieldBuilder &&
|
||||
!builder.isStatic &&
|
||||
|
||||
@@ -23,7 +23,7 @@ abstract class MemberBuilder implements ModifierBuilder {
|
||||
|
||||
void set parent(Builder? value);
|
||||
|
||||
LibraryBuilder get library;
|
||||
LibraryBuilder get libraryBuilder;
|
||||
|
||||
/// The [Member] built by this builder;
|
||||
Member get member;
|
||||
@@ -108,16 +108,16 @@ abstract class MemberBuilderImpl extends ModifierBuilderImpl
|
||||
parent is ClassBuilder ? parent as ClassBuilder : null;
|
||||
|
||||
@override
|
||||
LibraryBuilder get library {
|
||||
LibraryBuilder get libraryBuilder {
|
||||
if (parent is LibraryBuilder) {
|
||||
LibraryBuilder library = parent as LibraryBuilder;
|
||||
return library.partOfLibrary ?? library;
|
||||
} else if (parent is ExtensionBuilder) {
|
||||
ExtensionBuilder extension = parent as ExtensionBuilder;
|
||||
return extension.library;
|
||||
return extension.libraryBuilder;
|
||||
} else {
|
||||
ClassBuilder cls = parent as ClassBuilder;
|
||||
return cls.library;
|
||||
return cls.libraryBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ abstract class TypeAliasBuilder implements TypeDeclarationBuilder {
|
||||
@override
|
||||
LibraryBuilder get parent;
|
||||
|
||||
LibraryBuilder get library;
|
||||
LibraryBuilder get libraryBuilder;
|
||||
|
||||
@override
|
||||
Uri get fileUri;
|
||||
@@ -149,7 +149,7 @@ abstract class TypeAliasBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
LibraryBuilder get parent => super.parent as LibraryBuilder;
|
||||
|
||||
@override
|
||||
LibraryBuilder get library => super.parent as LibraryBuilder;
|
||||
LibraryBuilder get libraryBuilder => super.parent as LibraryBuilder;
|
||||
|
||||
/// [arguments] have already been built.
|
||||
@override
|
||||
@@ -280,7 +280,7 @@ abstract class TypeAliasBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
}
|
||||
if (builders.contains(current)) {
|
||||
// Cyclic type alias.
|
||||
currentAliasBuilder.library.addProblem(
|
||||
currentAliasBuilder.libraryBuilder.addProblem(
|
||||
templateCyclicTypedef.withArguments(this.name),
|
||||
charOffset,
|
||||
noLength,
|
||||
@@ -303,7 +303,7 @@ abstract class TypeAliasBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
if (typeVariables != null)
|
||||
for (TypeVariableBuilder typeVariable in typeVariables!)
|
||||
new NamedTypeBuilder.fromTypeDeclarationBuilder(
|
||||
typeVariable, library.nonNullableBuilder,
|
||||
typeVariable, libraryBuilder.nonNullableBuilder,
|
||||
arguments: const [],
|
||||
fileUri: fileUri,
|
||||
charOffset: charOffset,
|
||||
@@ -320,7 +320,7 @@ abstract class TypeAliasBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
messageTypedefTypeVariableNotConstructor,
|
||||
usedAsClassCharOffset ?? TreeNode.noOffset,
|
||||
noLength,
|
||||
@@ -383,7 +383,7 @@ abstract class TypeAliasBuilderImpl extends TypeDeclarationBuilderImpl
|
||||
if ((currentAliasBuilder.typeVariables?.length ?? 0) !=
|
||||
currentTypeArguments.length) {
|
||||
if (previousAliasBuilder != null) {
|
||||
previousAliasBuilder.library.addProblem(
|
||||
previousAliasBuilder.libraryBuilder.addProblem(
|
||||
templateTypeArgumentMismatch.withArguments(
|
||||
currentAliasBuilder.typeVariables?.length ?? 0),
|
||||
previousAliasBuilder.charOffset,
|
||||
|
||||
@@ -53,7 +53,8 @@ class DillClassBuilder extends ClassBuilderImpl {
|
||||
DillClassBuilder get origin => this;
|
||||
|
||||
@override
|
||||
DillLibraryBuilder get library => super.library as DillLibraryBuilder;
|
||||
DillLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as DillLibraryBuilder;
|
||||
|
||||
@override
|
||||
bool get isMacro => cls.isMacro;
|
||||
@@ -66,7 +67,7 @@ class DillClassBuilder extends ClassBuilderImpl {
|
||||
List<TypeVariableBuilder>? typeVariables = super.typeVariables;
|
||||
if (typeVariables == null && cls.typeParameters.isNotEmpty) {
|
||||
typeVariables = super.typeVariables =
|
||||
computeTypeVariableBuilders(library, cls.typeParameters);
|
||||
computeTypeVariableBuilders(libraryBuilder, cls.typeParameters);
|
||||
}
|
||||
return typeVariables;
|
||||
}
|
||||
@@ -81,7 +82,7 @@ class DillClassBuilder extends ClassBuilderImpl {
|
||||
Supertype? targetSupertype = cls.supertype;
|
||||
if (targetSupertype == null) return null;
|
||||
super.supertypeBuilder =
|
||||
supertype = computeTypeBuilder(library, targetSupertype);
|
||||
supertype = computeTypeBuilder(libraryBuilder, targetSupertype);
|
||||
}
|
||||
return supertype;
|
||||
}
|
||||
@@ -160,7 +161,7 @@ class DillClassBuilder extends ClassBuilderImpl {
|
||||
|
||||
@override
|
||||
TypeBuilder? get mixedInTypeBuilder {
|
||||
return computeTypeBuilder(library, cls.mixedInType);
|
||||
return computeTypeBuilder(libraryBuilder, cls.mixedInType);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -174,7 +175,8 @@ class DillClassBuilder extends ClassBuilderImpl {
|
||||
if (super.interfaceBuilders == null) {
|
||||
List<TypeBuilder> result = new List<TypeBuilder>.generate(
|
||||
cls.implementedTypes.length,
|
||||
(int i) => computeTypeBuilder(library, cls.implementedTypes[i])!,
|
||||
(int i) =>
|
||||
computeTypeBuilder(libraryBuilder, cls.implementedTypes[i])!,
|
||||
growable: false);
|
||||
super.interfaceBuilders = result;
|
||||
}
|
||||
|
||||
@@ -101,14 +101,15 @@ class DillExtensionBuilder extends ExtensionBuilderImpl {
|
||||
List<TypeVariableBuilder>? get typeParameters {
|
||||
if (_typeParameters == null && extension.typeParameters.isNotEmpty) {
|
||||
_typeParameters =
|
||||
computeTypeVariableBuilders(library, extension.typeParameters);
|
||||
computeTypeVariableBuilders(libraryBuilder, extension.typeParameters);
|
||||
}
|
||||
return _typeParameters;
|
||||
}
|
||||
|
||||
@override
|
||||
TypeBuilder get onType {
|
||||
return _onType ??= library.loader.computeTypeBuilder(extension.onType);
|
||||
return _onType ??=
|
||||
libraryBuilder.loader.computeTypeBuilder(extension.onType);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -42,7 +42,7 @@ class DillTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
List<TypeVariableBuilder>? get typeVariables {
|
||||
if (_typeVariables == null && typedef.typeParameters.isNotEmpty) {
|
||||
_typeVariables =
|
||||
computeTypeVariableBuilders(library, typedef.typeParameters);
|
||||
computeTypeVariableBuilders(libraryBuilder, typedef.typeParameters);
|
||||
}
|
||||
return _typeVariables;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class DillTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
@override
|
||||
TypeBuilder? get type {
|
||||
if (_type == null && typedef.type is! InvalidType) {
|
||||
_type = library.loader.computeTypeBuilder(typedef.type!);
|
||||
_type = libraryBuilder.loader.computeTypeBuilder(typedef.type!);
|
||||
}
|
||||
// TODO(johnniwinther): Support TypeBuilder for InvalidType.
|
||||
return _type;
|
||||
|
||||
@@ -390,7 +390,8 @@ class BodyBuilder extends StackListenerImpl
|
||||
: this(
|
||||
libraryBuilder: part,
|
||||
member: field,
|
||||
enclosingScope: declarationBuilder?.scope ?? field.library.scope,
|
||||
enclosingScope:
|
||||
declarationBuilder?.scope ?? field.libraryBuilder.scope,
|
||||
formalParameterScope: null,
|
||||
hierarchy: part.loader.hierarchy,
|
||||
coreTypes: part.loader.coreTypes,
|
||||
@@ -5502,8 +5503,8 @@ class BodyBuilder extends StackListenerImpl
|
||||
// No type arguments provided to unaliased class, use defaults.
|
||||
List<DartType> result = new List<DartType>.generate(
|
||||
cls.typeVariables!.length,
|
||||
(int i) =>
|
||||
cls.typeVariables![i].defaultType!.build(cls.library),
|
||||
(int i) => cls.typeVariables![i].defaultType!
|
||||
.build(cls.libraryBuilder),
|
||||
growable: true);
|
||||
forest.argumentsSetTypeArguments(arguments, result);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,8 @@ abstract class CombinedMemberSignatureBase<T> {
|
||||
if (members.length == 1) {
|
||||
bestSoFarIndex = 0;
|
||||
} else {
|
||||
bool isNonNullableByDefault = classBuilder.library.isNonNullableByDefault;
|
||||
bool isNonNullableByDefault =
|
||||
classBuilder.libraryBuilder.isNonNullableByDefault;
|
||||
|
||||
DartType? bestTypeSoFar;
|
||||
for (int candidateIndex = members.length - 1;
|
||||
@@ -269,7 +270,7 @@ abstract class CombinedMemberSignatureBase<T> {
|
||||
/// The this type of [classBuilder].
|
||||
InterfaceType get thisType {
|
||||
return _thisType ??= _coreTypes.thisInterfaceType(
|
||||
classBuilder.cls, classBuilder.library.nonNullable);
|
||||
classBuilder.cls, classBuilder.libraryBuilder.nonNullable);
|
||||
}
|
||||
|
||||
/// Returns `true` if the canonical member is declared in [classBuilder].
|
||||
@@ -295,7 +296,7 @@ abstract class CombinedMemberSignatureBase<T> {
|
||||
assert(target != null,
|
||||
"No member computed for index ${index} in ${members}");
|
||||
candidateType = _computeMemberType(thisType, target);
|
||||
if (!classBuilder.library.isNonNullableByDefault) {
|
||||
if (!classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
DartType? legacyErasure;
|
||||
if (target == hierarchy.coreTypes.objectEquals) {
|
||||
// In legacy code we special case `Object.==` to infer `dynamic`
|
||||
@@ -318,7 +319,7 @@ abstract class CombinedMemberSignatureBase<T> {
|
||||
|
||||
DartType getMemberTypeForTarget(Member target) {
|
||||
DartType candidateType = _computeMemberType(thisType, target);
|
||||
if (!classBuilder.library.isNonNullableByDefault) {
|
||||
if (!classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
DartType? legacyErasure;
|
||||
if (target == hierarchy.coreTypes.objectEquals) {
|
||||
// In legacy code we special case `Object.==` to infer `dynamic`
|
||||
@@ -341,7 +342,7 @@ abstract class CombinedMemberSignatureBase<T> {
|
||||
if (_canonicalMemberIndex == null) {
|
||||
return null;
|
||||
}
|
||||
if (classBuilder.library.isNonNullableByDefault) {
|
||||
if (classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
DartType canonicalMemberType = _combinedMemberSignatureType =
|
||||
getMemberType(_canonicalMemberIndex!);
|
||||
_containsNnbdTypes =
|
||||
@@ -717,7 +718,7 @@ abstract class CombinedMemberSignatureBase<T> {
|
||||
return type;
|
||||
}
|
||||
InterfaceType? instance = hierarchy.getTypeAsInstanceOf(
|
||||
thisType, member.enclosingClass!, classBuilder.library.library);
|
||||
thisType, member.enclosingClass!, classBuilder.libraryBuilder.library);
|
||||
assert(
|
||||
instance != null,
|
||||
"No instance of $thisType as ${member.enclosingClass} found for "
|
||||
|
||||
@@ -3267,8 +3267,10 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
|
||||
allowPotentiallyConstantType: true);
|
||||
}
|
||||
if (isGenericTypedefTearOff) {
|
||||
if (isProperRenameForClass(_helper.typeEnvironment,
|
||||
aliasBuilder!.typedef, aliasBuilder.library.library)) {
|
||||
if (isProperRenameForClass(
|
||||
_helper.typeEnvironment,
|
||||
aliasBuilder!.typedef,
|
||||
aliasBuilder.libraryBuilder.library)) {
|
||||
return tearOffExpression;
|
||||
}
|
||||
Procedure? tearOffLowering =
|
||||
|
||||
@@ -239,7 +239,7 @@ class ForwardingNode {
|
||||
parameter.type,
|
||||
superParameterType,
|
||||
_combinedMemberSignature
|
||||
.classBuilder.library.isNonNullableByDefault
|
||||
.classBuilder.libraryBuilder.isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities)) {
|
||||
expression = new AsExpression(expression, superParameterType)
|
||||
@@ -268,7 +268,7 @@ class ForwardingNode {
|
||||
parameter.type,
|
||||
superParameterType,
|
||||
_combinedMemberSignature
|
||||
.classBuilder.library.isNonNullableByDefault
|
||||
.classBuilder.libraryBuilder.isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities)) {
|
||||
expression = new AsExpression(expression, superParameterType)
|
||||
@@ -307,7 +307,7 @@ class ForwardingNode {
|
||||
parameter.type,
|
||||
superParameterType,
|
||||
_combinedMemberSignature
|
||||
.classBuilder.library.isNonNullableByDefault
|
||||
.classBuilder.libraryBuilder.isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities)) {
|
||||
expression = new AsExpression(expression, superParameterType)
|
||||
|
||||
@@ -318,7 +318,7 @@ class SynthesizedInterfaceMember extends SynthesizedMember {
|
||||
if (_member != null) {
|
||||
return;
|
||||
}
|
||||
if (classBuilder.library is! SourceLibraryBuilder) {
|
||||
if (classBuilder.libraryBuilder is! SourceLibraryBuilder) {
|
||||
if (_canonicalMember != null) {
|
||||
_member = _canonicalMember!.getMember(membersBuilder);
|
||||
_covariance = _canonicalMember!.getCovariance(membersBuilder);
|
||||
@@ -384,7 +384,7 @@ class SynthesizedInterfaceMember extends SynthesizedMember {
|
||||
assert(stub != canonicalMember);
|
||||
classBuilder.cls.addProcedure(stub);
|
||||
SourceLibraryBuilder library =
|
||||
classBuilder.library as SourceLibraryBuilder;
|
||||
classBuilder.libraryBuilder as SourceLibraryBuilder;
|
||||
if (canonicalMember is Procedure) {
|
||||
library.forwardersOrigins
|
||||
..add(stub)
|
||||
|
||||
@@ -69,7 +69,9 @@ class ClassHierarchyNodeBuilder {
|
||||
superclasses = new List<Supertype>.filled(
|
||||
supernode.superclasses.length + 1, dummySupertype);
|
||||
Supertype? supertype = classBuilder.supertypeBuilder!.buildSupertype(
|
||||
classBuilder.library, classBuilder.charOffset, classBuilder.fileUri);
|
||||
classBuilder.libraryBuilder,
|
||||
classBuilder.charOffset,
|
||||
classBuilder.fileUri);
|
||||
if (supertype == null) {
|
||||
// If the superclass is not an interface type we use Object instead.
|
||||
// A similar normalization is performed on [supernode] above.
|
||||
@@ -79,8 +81,8 @@ class ClassHierarchyNodeBuilder {
|
||||
superclasses.setRange(0, superclasses.length - 1,
|
||||
substSupertypes(supertype, supernode.superclasses));
|
||||
superclasses[superclasses.length - 1] = supertype;
|
||||
if (!classBuilder.library.isNonNullableByDefault &&
|
||||
supernode.classBuilder.library.isNonNullableByDefault) {
|
||||
if (!classBuilder.libraryBuilder.isNonNullableByDefault &&
|
||||
supernode.classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
for (int i = 0; i < superclasses.length; i++) {
|
||||
superclasses[i] = legacyErasureSupertype(superclasses[i]);
|
||||
}
|
||||
@@ -115,8 +117,8 @@ class ClassHierarchyNodeBuilder {
|
||||
|
||||
for (int i = 0; i < directInterfaceBuilders.length; i++) {
|
||||
Supertype? directInterface = directInterfaceBuilders[i]
|
||||
.buildSupertype(classBuilder.library, classBuilder.charOffset,
|
||||
classBuilder.fileUri);
|
||||
.buildSupertype(classBuilder.libraryBuilder,
|
||||
classBuilder.charOffset, classBuilder.fileUri);
|
||||
if (directInterface != null) {
|
||||
addInterface(interfaces, superclasses, directInterface);
|
||||
ClassHierarchyNode interfaceNode =
|
||||
@@ -143,8 +145,8 @@ class ClassHierarchyNodeBuilder {
|
||||
}
|
||||
interfacesList = interfaces.values.toList();
|
||||
} else if (superclassInterfaces.isNotEmpty &&
|
||||
!classBuilder.library.isNonNullableByDefault &&
|
||||
supernode.classBuilder.library.isNonNullableByDefault) {
|
||||
!classBuilder.libraryBuilder.isNonNullableByDefault &&
|
||||
supernode.classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
Map<Class, Supertype> interfaces = {};
|
||||
for (int i = 0; i < superclassInterfaces.length; i++) {
|
||||
addInterface(interfaces, superclasses, superclassInterfaces[i]);
|
||||
@@ -227,7 +229,7 @@ class ClassHierarchyNodeBuilder {
|
||||
List<Supertype> superclasses, Supertype type) {
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (type == null) return null;
|
||||
if (!classBuilder.library.isNonNullableByDefault) {
|
||||
if (!classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
type = legacyErasureSupertype(type);
|
||||
}
|
||||
ClassHierarchyNode node = hierarchy.getNodeFromClass(type.classNode);
|
||||
@@ -238,7 +240,7 @@ class ClassHierarchyNodeBuilder {
|
||||
Supertype? superclass = depth < myDepth ? superclasses[depth] : null;
|
||||
if (superclass != null && superclass.classNode == type.classNode) {
|
||||
// This is a potential conflict.
|
||||
if (classBuilder.library.isNonNullableByDefault) {
|
||||
if (classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
superclass = nnbdTopMergeSupertype(
|
||||
hierarchy.coreTypes,
|
||||
normSupertype(hierarchy.coreTypes, superclass),
|
||||
@@ -257,7 +259,7 @@ class ClassHierarchyNodeBuilder {
|
||||
Supertype? interface = interfaces[type.classNode];
|
||||
if (interface != null) {
|
||||
// This is a potential conflict.
|
||||
if (classBuilder.library.isNonNullableByDefault) {
|
||||
if (classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
interface = nnbdTopMergeSupertype(
|
||||
hierarchy.coreTypes,
|
||||
normSupertype(hierarchy.coreTypes, interface),
|
||||
|
||||
@@ -70,7 +70,7 @@ class ClassMembersNodeBuilder {
|
||||
ClassBuilder get classBuilder => _hierarchyNode.classBuilder;
|
||||
|
||||
bool get shouldModifyKernel =>
|
||||
classBuilder.library.loader == hierarchy.loader;
|
||||
classBuilder.libraryBuilder.loader == hierarchy.loader;
|
||||
|
||||
ClassMember? checkInheritanceConflict(ClassMember a, ClassMember b) {
|
||||
if (a.isStatic || a.isProperty != b.isProperty) {
|
||||
@@ -373,7 +373,7 @@ class ClassMembersNodeBuilder {
|
||||
ClassBuilder classBuilder,
|
||||
DartType? inferredType,
|
||||
DartType inheritedType) {
|
||||
if (classBuilder.library.isNonNullableByDefault) {
|
||||
if (classBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
if (inferredType == null) {
|
||||
return inheritedType;
|
||||
} else {
|
||||
@@ -531,7 +531,7 @@ class ClassMembersNodeBuilder {
|
||||
staticMember = b;
|
||||
instanceMember = a;
|
||||
}
|
||||
classBuilder.library.addProblem(messageStaticAndInstanceConflict,
|
||||
classBuilder.libraryBuilder.addProblem(messageStaticAndInstanceConflict,
|
||||
staticMember.charOffset, name.length, staticMember.fileUri,
|
||||
context: <LocatedMessage>[
|
||||
messageStaticAndInstanceConflictCause.withLocation(
|
||||
@@ -553,7 +553,7 @@ class ClassMembersNodeBuilder {
|
||||
existing = b;
|
||||
duplicate = a;
|
||||
}
|
||||
classBuilder.library.addProblem(
|
||||
classBuilder.libraryBuilder.addProblem(
|
||||
templateDuplicatedDeclaration.withArguments(name),
|
||||
duplicate.charOffset,
|
||||
name.length,
|
||||
@@ -937,8 +937,8 @@ class ClassMembersNodeBuilder {
|
||||
/// }
|
||||
///
|
||||
bool needsMemberSignatureFor(ClassMember classMember) {
|
||||
return !classBuilder.library.isNonNullableByDefault &&
|
||||
classMember.classBuilder.library.isNonNullableByDefault;
|
||||
return !classBuilder.libraryBuilder.isNonNullableByDefault &&
|
||||
classMember.classBuilder.libraryBuilder.isNonNullableByDefault;
|
||||
}
|
||||
|
||||
memberMap.forEach((Name name, Tuple tuple) {
|
||||
@@ -2338,7 +2338,7 @@ class ClassMembersNodeBuilder {
|
||||
void reportMissingMembers(List<ClassMember> abstractMembers) {
|
||||
Map<String, LocatedMessage> contextMap = <String, LocatedMessage>{};
|
||||
for (ClassMember declaration in unfoldDeclarations(abstractMembers)) {
|
||||
if (isNameVisibleIn(declaration.name, classBuilder.library)) {
|
||||
if (isNameVisibleIn(declaration.name, classBuilder.libraryBuilder)) {
|
||||
String name = declaration.fullNameForErrors;
|
||||
String className = declaration.classBuilder.fullNameForErrors;
|
||||
String displayName =
|
||||
|
||||
@@ -107,7 +107,7 @@ class _ImplicitFieldTypeRoot extends ImplicitFieldType {
|
||||
@override
|
||||
DartType computeType() {
|
||||
if (isStarted) {
|
||||
fieldBuilder.library.addProblem(
|
||||
fieldBuilder.libraryBuilder.addProblem(
|
||||
templateCantInferTypeDueToCircularity
|
||||
.withArguments(fieldBuilder.name),
|
||||
fieldBuilder.charOffset,
|
||||
@@ -121,7 +121,7 @@ class _ImplicitFieldTypeRoot extends ImplicitFieldType {
|
||||
if (_overriddenFields != null) {
|
||||
for (ImplicitFieldType overridden in _overriddenFields!) {
|
||||
DartType overriddenType = overridden.inferType();
|
||||
if (!fieldBuilder.library.isNonNullableByDefault) {
|
||||
if (!fieldBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
overriddenType = legacyErasure(overriddenType);
|
||||
}
|
||||
if (inferredType == null) {
|
||||
@@ -133,22 +133,22 @@ class _ImplicitFieldTypeRoot extends ImplicitFieldType {
|
||||
return inferredType!;
|
||||
} else if (parent is SourceEnumBuilder &&
|
||||
parent.elementBuilders.contains(fieldBuilder)) {
|
||||
inferredType = parent.buildElement(
|
||||
parent.library, fieldBuilder, parent.library.loader.coreTypes);
|
||||
inferredType = parent.buildElement(parent.libraryBuilder, fieldBuilder,
|
||||
parent.libraryBuilder.loader.coreTypes);
|
||||
} else if (initializerToken != null) {
|
||||
InterfaceType? enclosingClassThisType = fieldBuilder.classBuilder == null
|
||||
? null
|
||||
: fieldBuilder.library.loader.typeInferenceEngine.coreTypes
|
||||
: fieldBuilder.libraryBuilder.loader.typeInferenceEngine.coreTypes
|
||||
.thisInterfaceType(fieldBuilder.classBuilder!.cls,
|
||||
fieldBuilder.library.library.nonNullable);
|
||||
fieldBuilder.libraryBuilder.library.nonNullable);
|
||||
TypeInferrer typeInferrer = fieldBuilder
|
||||
.library.loader.typeInferenceEngine
|
||||
.libraryBuilder.loader.typeInferenceEngine
|
||||
.createTopLevelTypeInferrer(
|
||||
fieldBuilder.fileUri,
|
||||
enclosingClassThisType,
|
||||
fieldBuilder.library,
|
||||
fieldBuilder.libraryBuilder,
|
||||
fieldBuilder.dataForTesting?.inferenceData);
|
||||
BodyBuilder bodyBuilder = fieldBuilder.library.loader
|
||||
BodyBuilder bodyBuilder = fieldBuilder.libraryBuilder.loader
|
||||
.createBodyBuilderForField(fieldBuilder, typeInferrer);
|
||||
bodyBuilder.constantContext = fieldBuilder.isConst
|
||||
? ConstantContext.inferred
|
||||
@@ -179,7 +179,7 @@ class _ImplicitFieldTypeRoot extends ImplicitFieldType {
|
||||
if (_overriddenFields != null) {
|
||||
for (ImplicitFieldType overridden in _overriddenFields!) {
|
||||
DartType overriddenType = overridden.inferType();
|
||||
if (!fieldBuilder.library.isNonNullableByDefault) {
|
||||
if (!fieldBuilder.libraryBuilder.isNonNullableByDefault) {
|
||||
overriddenType = legacyErasure(overriddenType);
|
||||
}
|
||||
if (type != overriddenType) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1011,7 +1011,7 @@ Expression? checkWebIntLiteralsErrorIfUnexact(
|
||||
TypeInferrerImpl inferrer, int value, String? literal, int charOffset) {
|
||||
if (value >= 0 && value <= (1 << 53)) return null;
|
||||
if (inferrer.isTopLevel) return null;
|
||||
if (!inferrer.library.loader.target.backendTarget
|
||||
if (!inferrer.libraryBuilder.loader.target.backendTarget
|
||||
.errorOnUnexactWebIntLiterals) return null;
|
||||
BigInt asInt = new BigInt.from(value).toUnsigned(64);
|
||||
BigInt asDouble = new BigInt.from(asInt.toDouble());
|
||||
|
||||
@@ -915,7 +915,7 @@ class KernelTarget extends TargetImplementation {
|
||||
|
||||
void installForwardingConstructors(SourceClassBuilder builder) {
|
||||
assert(builder.isMixinApplication);
|
||||
if (builder.library.loader != loader) return;
|
||||
if (builder.libraryBuilder.loader != loader) return;
|
||||
if (builder.cls.constructors.isNotEmpty) {
|
||||
// These were installed by a subclass in the recursive call below.
|
||||
return;
|
||||
@@ -1087,7 +1087,7 @@ class KernelTarget extends TargetImplementation {
|
||||
SynthesizedFunctionNode synthesizedFunctionNode =
|
||||
new SynthesizedFunctionNode(
|
||||
substitutionMap, superConstructor.function, function,
|
||||
libraryBuilder: classBuilder.library);
|
||||
libraryBuilder: classBuilder.libraryBuilder);
|
||||
if (!isConst) {
|
||||
// For constant constructors default values are computed and cloned part
|
||||
// of the outline expression and therefore passed to the
|
||||
@@ -1119,7 +1119,7 @@ class KernelTarget extends TargetImplementation {
|
||||
|
||||
Procedure? constructorTearOff = createConstructorTearOffProcedure(
|
||||
superConstructor.name.text,
|
||||
classBuilder.library,
|
||||
classBuilder.libraryBuilder,
|
||||
cls.fileUri,
|
||||
cls.fileOffset,
|
||||
tearOffReference,
|
||||
@@ -1127,7 +1127,7 @@ class KernelTarget extends TargetImplementation {
|
||||
|
||||
if (constructorTearOff != null) {
|
||||
buildConstructorTearOffProcedure(constructorTearOff, constructor,
|
||||
classBuilder.cls, classBuilder.library);
|
||||
classBuilder.cls, classBuilder.libraryBuilder);
|
||||
}
|
||||
return new SyntheticSourceConstructorBuilder(
|
||||
classBuilder, constructor, constructorTearOff,
|
||||
@@ -1174,7 +1174,7 @@ class KernelTarget extends TargetImplementation {
|
||||
enclosingClass.enclosingLibrary.isNonNullableByDefault;
|
||||
Procedure? constructorTearOff = createConstructorTearOffProcedure(
|
||||
'',
|
||||
classBuilder.library,
|
||||
classBuilder.libraryBuilder,
|
||||
enclosingClass.fileUri,
|
||||
enclosingClass.fileOffset,
|
||||
tearOffReference,
|
||||
@@ -1182,7 +1182,7 @@ class KernelTarget extends TargetImplementation {
|
||||
enclosingClass.isAbstract || enclosingClass.isEnum);
|
||||
if (constructorTearOff != null) {
|
||||
buildConstructorTearOffProcedure(constructorTearOff, constructor,
|
||||
classBuilder.cls, classBuilder.library);
|
||||
classBuilder.cls, classBuilder.libraryBuilder);
|
||||
}
|
||||
return new SyntheticSourceConstructorBuilder(
|
||||
classBuilder, constructor, constructorTearOff);
|
||||
@@ -1389,7 +1389,7 @@ class KernelTarget extends TargetImplementation {
|
||||
.toList());
|
||||
nonFinalFields.clear();
|
||||
}
|
||||
SourceLibraryBuilder library = builder.library;
|
||||
SourceLibraryBuilder library = builder.libraryBuilder;
|
||||
if (library.isNonNullableByDefault) {
|
||||
if (constructor.isConst && lateFinalFields.isNotEmpty) {
|
||||
for (FieldBuilder field in lateFinalFields) {
|
||||
@@ -1452,7 +1452,7 @@ class KernelTarget extends TargetImplementation {
|
||||
if (!fieldBuilder.isLate) {
|
||||
if (fieldBuilder.isFinal &&
|
||||
uninitializedFinalOrNonNullableFieldIsError) {
|
||||
String uri = '${fieldBuilder.library.importUri}';
|
||||
String uri = '${fieldBuilder.libraryBuilder.importUri}';
|
||||
String file = fieldBuilder.fileUri.pathSegments.last;
|
||||
if (uri == 'dart:html' ||
|
||||
uri == 'dart:svg' ||
|
||||
@@ -1461,7 +1461,7 @@ class KernelTarget extends TargetImplementation {
|
||||
// TODO(johnniwinther): Use external getters instead of final
|
||||
// fields. See https://github.com/dart-lang/sdk/issues/33762
|
||||
} else {
|
||||
builder.library.addProblem(
|
||||
builder.libraryBuilder.addProblem(
|
||||
templateFinalFieldNotInitialized
|
||||
.withArguments(fieldBuilder.name),
|
||||
fieldBuilder.charOffset,
|
||||
@@ -1471,7 +1471,7 @@ class KernelTarget extends TargetImplementation {
|
||||
} else if (fieldBuilder.fieldType is! InvalidType &&
|
||||
fieldBuilder.fieldType.isPotentiallyNonNullable &&
|
||||
uninitializedFinalOrNonNullableFieldIsError) {
|
||||
SourceLibraryBuilder library = builder.library;
|
||||
SourceLibraryBuilder library = builder.libraryBuilder;
|
||||
if (library.isNonNullableByDefault) {
|
||||
library.addProblem(
|
||||
templateFieldNonNullableWithoutInitializerError.withArguments(
|
||||
@@ -1500,7 +1500,7 @@ class KernelTarget extends TargetImplementation {
|
||||
initializer.parent = constructorBuilder.constructor;
|
||||
constructorBuilder.constructor.initializers.insert(0, initializer);
|
||||
if (fieldBuilder.isFinal) {
|
||||
builder.library.addProblem(
|
||||
builder.libraryBuilder.addProblem(
|
||||
templateFinalFieldNotInitializedByConstructor
|
||||
.withArguments(fieldBuilder.name),
|
||||
constructorBuilder.charOffset,
|
||||
@@ -1515,7 +1515,7 @@ class KernelTarget extends TargetImplementation {
|
||||
} else if (fieldBuilder.field.type is! InvalidType &&
|
||||
!fieldBuilder.isLate &&
|
||||
fieldBuilder.field.type.isPotentiallyNonNullable) {
|
||||
SourceLibraryBuilder library = builder.library;
|
||||
SourceLibraryBuilder library = builder.libraryBuilder;
|
||||
if (library.isNonNullableByDefault) {
|
||||
library.addProblem(
|
||||
templateFieldNonNullableNotInitializedByConstructorError
|
||||
|
||||
@@ -37,9 +37,9 @@ abstract class IdentifierImpl extends macro.IdentifierImpl {
|
||||
if (typeDeclarationBuilder != null) {
|
||||
Uri? uri;
|
||||
if (typeDeclarationBuilder is ClassBuilder) {
|
||||
uri = typeDeclarationBuilder.library.importUri;
|
||||
uri = typeDeclarationBuilder.libraryBuilder.importUri;
|
||||
} else if (typeDeclarationBuilder is TypeAliasBuilder) {
|
||||
uri = typeDeclarationBuilder.library.importUri;
|
||||
uri = typeDeclarationBuilder.libraryBuilder.importUri;
|
||||
} else if (name == 'dynamic') {
|
||||
uri = Uri.parse('dart:core');
|
||||
}
|
||||
@@ -144,10 +144,10 @@ class MemberBuilderIdentifier extends IdentifierImpl {
|
||||
if (memberBuilder.isStatic || memberBuilder.isConstructor) {
|
||||
ClassBuilder classBuilder = memberBuilder.classBuilder!;
|
||||
staticScope = classBuilder.name;
|
||||
uri = classBuilder.library.importUri;
|
||||
uri = classBuilder.libraryBuilder.importUri;
|
||||
kind = macro.IdentifierKind.staticInstanceMember;
|
||||
} else if (memberBuilder.isTopLevel) {
|
||||
uri = memberBuilder.library.importUri;
|
||||
uri = memberBuilder.libraryBuilder.importUri;
|
||||
kind = macro.IdentifierKind.topLevelMember;
|
||||
} else {
|
||||
kind = macro.IdentifierKind.instanceMember;
|
||||
|
||||
@@ -136,7 +136,7 @@ class MacroApplications {
|
||||
List<MacroApplication>? applications) async {
|
||||
if (applications != null) {
|
||||
for (MacroApplication application in applications) {
|
||||
Uri libraryUri = application.classBuilder.library.importUri;
|
||||
Uri libraryUri = application.classBuilder.libraryBuilder.importUri;
|
||||
String macroClassName = application.classBuilder.name;
|
||||
Uri? precompiledMacroUri = precompiledMacroUris[libraryUri];
|
||||
try {
|
||||
@@ -157,7 +157,7 @@ class MacroApplications {
|
||||
} catch (e) {
|
||||
throw "Error loading macro class "
|
||||
"'${application.classBuilder.name}' from "
|
||||
"'${application.classBuilder.library.importUri}': $e";
|
||||
"'${application.classBuilder.libraryBuilder.importUri}': $e";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -478,7 +478,7 @@ class MacroApplications {
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
identifier: new TypeDeclarationBuilderIdentifier(
|
||||
typeDeclarationBuilder: builder,
|
||||
libraryBuilder: builder.library,
|
||||
libraryBuilder: builder.libraryBuilder,
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
name: builder.name),
|
||||
// TODO(johnniwinther): Support typeParameters
|
||||
@@ -501,12 +501,13 @@ class MacroApplications {
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
identifier: new TypeDeclarationBuilderIdentifier(
|
||||
typeDeclarationBuilder: builder,
|
||||
libraryBuilder: builder.library,
|
||||
libraryBuilder: builder.libraryBuilder,
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
name: builder.name),
|
||||
// TODO(johnniwinther): Support typeParameters
|
||||
typeParameters: [],
|
||||
aliasedType: _computeTypeAnnotation(builder.library, builder.type));
|
||||
aliasedType:
|
||||
_computeTypeAnnotation(builder.libraryBuilder, builder.type));
|
||||
return declaration;
|
||||
}
|
||||
|
||||
@@ -521,12 +522,12 @@ class MacroApplications {
|
||||
namedParameters = [];
|
||||
for (FormalParameterBuilder formal in formals) {
|
||||
macro.TypeAnnotationImpl type =
|
||||
computeTypeAnnotation(builder.library, formal.type);
|
||||
computeTypeAnnotation(builder.libraryBuilder, formal.type);
|
||||
macro.IdentifierImpl identifier = new FormalParameterBuilderIdentifier(
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
name: formal.name,
|
||||
parameterBuilder: formal,
|
||||
libraryBuilder: builder.library);
|
||||
libraryBuilder: builder.libraryBuilder);
|
||||
if (formal.isNamed) {
|
||||
namedParameters.add(new macro.ParameterDeclarationImpl(
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
@@ -576,7 +577,7 @@ class MacroApplications {
|
||||
positionalParameters: parameters[0],
|
||||
namedParameters: parameters[1],
|
||||
// TODO(johnniwinther): Support constructor return type.
|
||||
returnType: computeTypeAnnotation(builder.library, null),
|
||||
returnType: computeTypeAnnotation(builder.libraryBuilder, null),
|
||||
// TODO(johnniwinther): Support typeParameters
|
||||
typeParameters: const [],
|
||||
);
|
||||
@@ -605,7 +606,7 @@ class MacroApplications {
|
||||
positionalParameters: parameters[0],
|
||||
namedParameters: parameters[1],
|
||||
// TODO(johnniwinther): Support constructor return type.
|
||||
returnType: computeTypeAnnotation(builder.library, null),
|
||||
returnType: computeTypeAnnotation(builder.libraryBuilder, null),
|
||||
// TODO(johnniwinther): Support typeParameters
|
||||
typeParameters: const [],
|
||||
);
|
||||
@@ -640,7 +641,7 @@ class MacroApplications {
|
||||
positionalParameters: parameters[0],
|
||||
namedParameters: parameters[1],
|
||||
returnType:
|
||||
computeTypeAnnotation(builder.library, builder.returnType),
|
||||
computeTypeAnnotation(builder.libraryBuilder, builder.returnType),
|
||||
// TODO(johnniwinther): Support typeParameters
|
||||
typeParameters: const []);
|
||||
} else {
|
||||
@@ -658,7 +659,7 @@ class MacroApplications {
|
||||
positionalParameters: parameters[0],
|
||||
namedParameters: parameters[1],
|
||||
returnType:
|
||||
computeTypeAnnotation(builder.library, builder.returnType),
|
||||
computeTypeAnnotation(builder.libraryBuilder, builder.returnType),
|
||||
// TODO(johnniwinther): Support typeParameters
|
||||
typeParameters: const []);
|
||||
}
|
||||
@@ -685,7 +686,7 @@ class MacroApplications {
|
||||
isFinal: builder.isFinal,
|
||||
isLate: builder.isLate,
|
||||
isStatic: builder.isStatic,
|
||||
type: computeTypeAnnotation(builder.library, builder.type));
|
||||
type: computeTypeAnnotation(builder.libraryBuilder, builder.type));
|
||||
} else {
|
||||
return new macro.VariableDeclarationImpl(
|
||||
id: macro.RemoteInstance.uniqueId,
|
||||
@@ -696,7 +697,7 @@ class MacroApplications {
|
||||
isExternal: builder.isExternal,
|
||||
isFinal: builder.isFinal,
|
||||
isLate: builder.isLate,
|
||||
type: computeTypeAnnotation(builder.library, builder.type));
|
||||
type: computeTypeAnnotation(builder.libraryBuilder, builder.type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -805,7 +805,7 @@ mixin ErroneousMemberBuilderMixin implements SourceMemberBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library {
|
||||
SourceLibraryBuilder get libraryBuilder {
|
||||
throw new UnsupportedError('AmbiguousMemberBuilder.library');
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,8 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
Class get cls => origin.actualCls;
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => super.library as SourceLibraryBuilder;
|
||||
SourceLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as SourceLibraryBuilder;
|
||||
|
||||
Class build(SourceLibraryBuilder library, LibraryBuilder coreLibrary) {
|
||||
SourceLibraryBuilder.checkMemberConflicts(library, scope,
|
||||
@@ -622,7 +623,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
originMember.applyPatch(patchMember);
|
||||
} else {
|
||||
patchMember.isConflictingAugmentationMember = true;
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateNonAugmentationClassMemberConflict
|
||||
.withArguments(name),
|
||||
patchMember.charOffset,
|
||||
@@ -637,7 +638,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
}
|
||||
} else {
|
||||
if (patchMember.isAugmentation) {
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateUnmatchedAugmentationClassMember.withArguments(name),
|
||||
patchMember.charOffset,
|
||||
name.length,
|
||||
@@ -707,8 +708,8 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
}
|
||||
}
|
||||
} else {
|
||||
library.addProblem(messagePatchDeclarationMismatch, patch.charOffset,
|
||||
noLength, patch.fileUri, context: [
|
||||
libraryBuilder.addProblem(messagePatchDeclarationMismatch,
|
||||
patch.charOffset, noLength, patch.fileUri, context: [
|
||||
messagePatchDeclarationOrigin.withLocation(
|
||||
fileUri, charOffset, noLength)
|
||||
]);
|
||||
@@ -726,7 +727,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
// Moreover, it checks that `FutureOr` and `void` are not among the
|
||||
// supertypes and that `Enum` is not implemented by non-abstract classes.
|
||||
|
||||
if (library.enableEnhancedEnumsInLibrary) {
|
||||
if (libraryBuilder.enableEnhancedEnumsInLibrary) {
|
||||
bool hasEnumSuperinterface = false;
|
||||
List<Supertype> interfaces =
|
||||
hierarchyBuilder.getNodeFromClass(cls).superclasses;
|
||||
@@ -755,7 +756,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
while (customValuesDeclaration?.next != null) {
|
||||
customValuesDeclaration = customValuesDeclaration?.next;
|
||||
}
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateEnumImplementerContainsValuesDeclaration
|
||||
.withArguments(this.name),
|
||||
customValuesDeclaration!.charOffset,
|
||||
@@ -770,7 +771,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
while (customValuesDeclaration?.next != null) {
|
||||
customValuesDeclaration = customValuesDeclaration?.next;
|
||||
}
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateEnumImplementerContainsValuesDeclaration
|
||||
.withArguments(this.name),
|
||||
customValuesDeclaration!.charOffset,
|
||||
@@ -917,20 +918,20 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
InterfaceType requiredInterface =
|
||||
substitution.substituteSupertype(constraint).asInterfaceType;
|
||||
InterfaceType? implementedInterface = hierarchy.getTypeAsInstanceOf(
|
||||
supertype, requiredInterface.classNode, library.library);
|
||||
supertype, requiredInterface.classNode, libraryBuilder.library);
|
||||
if (implementedInterface == null ||
|
||||
!typeEnvironment.areMutualSubtypes(
|
||||
implementedInterface,
|
||||
requiredInterface,
|
||||
library.isNonNullableByDefault
|
||||
libraryBuilder.isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities)) {
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateMixinApplicationIncompatibleSupertype.withArguments(
|
||||
supertype,
|
||||
requiredInterface,
|
||||
cls.mixedInType!.asInterfaceType,
|
||||
library.isNonNullableByDefault),
|
||||
libraryBuilder.isNonNullableByDefault),
|
||||
cls.fileOffset,
|
||||
noLength,
|
||||
cls.fileUri);
|
||||
@@ -961,7 +962,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
|
||||
List<DartType>? typeArguments = factory.getTypeArguments();
|
||||
FunctionType targetFunctionType =
|
||||
targetNode.computeFunctionType(library.nonNullable);
|
||||
targetNode.computeFunctionType(libraryBuilder.nonNullable);
|
||||
if (typeArguments != null &&
|
||||
targetFunctionType.typeParameters.length != typeArguments.length) {
|
||||
_addProblemForRedirectingFactory(
|
||||
@@ -994,18 +995,18 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
templateRedirectingFactoryIncompatibleTypeArgument.withArguments(
|
||||
typeArgument,
|
||||
typeParameterBound,
|
||||
library.isNonNullableByDefault),
|
||||
libraryBuilder.isNonNullableByDefault),
|
||||
redirectionTarget.charOffset,
|
||||
noLength);
|
||||
hasProblem = true;
|
||||
} else if (library.isNonNullableByDefault) {
|
||||
} else if (libraryBuilder.isNonNullableByDefault) {
|
||||
if (!typeEnvironment.isSubtypeOf(typeArgument, typeParameterBound,
|
||||
SubtypeCheckMode.withNullabilities)) {
|
||||
_addProblemForRedirectingFactory(
|
||||
factory,
|
||||
templateRedirectingFactoryIncompatibleTypeArgument
|
||||
.withArguments(typeArgument, typeParameterBound,
|
||||
library.isNonNullableByDefault),
|
||||
libraryBuilder.isNonNullableByDefault),
|
||||
redirectionTarget.charOffset,
|
||||
noLength);
|
||||
hasProblem = true;
|
||||
@@ -1074,7 +1075,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
void _addProblemForRedirectingFactory(RedirectingFactoryBuilder factory,
|
||||
Message message, int charOffset, int length) {
|
||||
addProblem(message, charOffset, length);
|
||||
String text = library.loader.target.context
|
||||
String text = libraryBuilder.loader.target.context
|
||||
.format(
|
||||
message.withLocation(fileUri, charOffset, length), Severity.error)
|
||||
.plain;
|
||||
@@ -1099,7 +1100,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
// its enclosing class, because constructors cannot specify type parameters
|
||||
// of their own.
|
||||
FunctionType factoryType = factory.function
|
||||
.computeThisFunctionType(library.nonNullable)
|
||||
.computeThisFunctionType(libraryBuilder.nonNullable)
|
||||
.withoutTypeParameters;
|
||||
FunctionType? redirecteeType =
|
||||
_computeRedirecteeType(factory, typeEnvironment);
|
||||
@@ -1120,16 +1121,20 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
_addProblemForRedirectingFactory(
|
||||
factory,
|
||||
templateIncompatibleRedirecteeFunctionType.withArguments(
|
||||
redirecteeType, factoryType, library.isNonNullableByDefault),
|
||||
redirecteeType,
|
||||
factoryType,
|
||||
libraryBuilder.isNonNullableByDefault),
|
||||
factory.redirectionTarget.charOffset,
|
||||
noLength);
|
||||
} else if (library.isNonNullableByDefault) {
|
||||
} else if (libraryBuilder.isNonNullableByDefault) {
|
||||
if (!typeEnvironment.isSubtypeOf(
|
||||
redirecteeType, factoryType, SubtypeCheckMode.withNullabilities)) {
|
||||
_addProblemForRedirectingFactory(
|
||||
factory,
|
||||
templateIncompatibleRedirecteeFunctionType.withArguments(
|
||||
redirecteeType, factoryType, library.isNonNullableByDefault),
|
||||
redirecteeType,
|
||||
factoryType,
|
||||
libraryBuilder.isNonNullableByDefault),
|
||||
factory.redirectionTarget.charOffset,
|
||||
noLength);
|
||||
}
|
||||
@@ -1174,7 +1179,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
for (int i = 0; i < typeVariables!.length; ++i) {
|
||||
TypeVariableBuilder typeVariableBuilder = typeVariables![i];
|
||||
int variance = computeTypeVariableBuilderVariance(
|
||||
typeVariableBuilder, supertype, library);
|
||||
typeVariableBuilder, supertype, libraryBuilder);
|
||||
if (!Variance.greaterThanOrEqual(variance, typeVariables![i].variance)) {
|
||||
if (typeVariables![i].parameter.isLegacyCovariant) {
|
||||
message = templateInvalidTypeVariableInSupertype.withArguments(
|
||||
@@ -1189,7 +1194,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
Variance.keywordString(variance),
|
||||
supertype.name as String);
|
||||
}
|
||||
library.addProblem(message, charOffset, noLength, fileUri);
|
||||
libraryBuilder.addProblem(message, charOffset, noLength, fileUri);
|
||||
}
|
||||
}
|
||||
if (message != null) {
|
||||
@@ -1285,7 +1290,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
void reportVariancePositionIfInvalid(
|
||||
int variance, TypeParameter typeParameter, Uri fileUri, int fileOffset,
|
||||
{bool isReturnType: false}) {
|
||||
SourceLibraryBuilder library = this.library;
|
||||
SourceLibraryBuilder library = this.libraryBuilder;
|
||||
if (!typeParameter.isLegacyCovariant &&
|
||||
!Variance.greaterThanOrEqual(variance, typeParameter.variance)) {
|
||||
Message message;
|
||||
@@ -1306,29 +1311,29 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
|
||||
void checkBoundsInSupertype(
|
||||
Supertype supertype, TypeEnvironment typeEnvironment) {
|
||||
SourceLibraryBuilder libraryBuilder = this.library;
|
||||
Library library = libraryBuilder.library;
|
||||
SourceLibraryBuilder libraryBuilder2 = this.libraryBuilder;
|
||||
Library library = libraryBuilder2.library;
|
||||
|
||||
List<TypeArgumentIssue> issues = findTypeArgumentIssues(
|
||||
new InterfaceType(
|
||||
supertype.classNode, library.nonNullable, supertype.typeArguments),
|
||||
typeEnvironment,
|
||||
libraryBuilder.isNonNullableByDefault
|
||||
libraryBuilder2.isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities,
|
||||
allowSuperBounded: false,
|
||||
isNonNullableByDefault: library.isNonNullableByDefault,
|
||||
areGenericArgumentsAllowed:
|
||||
libraryBuilder.enableGenericMetadataInLibrary);
|
||||
libraryBuilder2.enableGenericMetadataInLibrary);
|
||||
for (TypeArgumentIssue issue in issues) {
|
||||
DartType argument = issue.argument;
|
||||
TypeParameter typeParameter = issue.typeParameter;
|
||||
bool inferred = libraryBuilder.inferredTypes.contains(argument);
|
||||
bool inferred = libraryBuilder2.inferredTypes.contains(argument);
|
||||
if (issue.isGenericTypeAsArgumentIssue) {
|
||||
if (inferred) {
|
||||
// Supertype can't be or contain super-bounded types, so null is
|
||||
// passed for super-bounded hint here.
|
||||
libraryBuilder.reportTypeArgumentIssue(
|
||||
libraryBuilder2.reportTypeArgumentIssue(
|
||||
templateGenericFunctionTypeInferredAsActualTypeArgument
|
||||
.withArguments(argument, library.isNonNullableByDefault),
|
||||
fileUri,
|
||||
@@ -1339,7 +1344,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
} else {
|
||||
// Supertype can't be or contain super-bounded types, so null is
|
||||
// passed for super-bounded hint here.
|
||||
libraryBuilder.reportTypeArgumentIssue(
|
||||
libraryBuilder2.reportTypeArgumentIssue(
|
||||
messageGenericFunctionTypeUsedAsActualTypeArgument,
|
||||
fileUri,
|
||||
charOffset,
|
||||
@@ -1355,7 +1360,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
template) {
|
||||
// Supertype can't be or contain super-bounded types, so null is
|
||||
// passed for super-bounded hint here.
|
||||
libraryBuilder.reportTypeArgumentIssue(
|
||||
libraryBuilder2.reportTypeArgumentIssue(
|
||||
template.withArguments(
|
||||
argument,
|
||||
typeParameter.bound,
|
||||
@@ -1381,7 +1386,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
}
|
||||
|
||||
void checkTypesInOutline(TypeEnvironment typeEnvironment) {
|
||||
library.checkBoundsInTypeParameters(
|
||||
libraryBuilder.checkBoundsInTypeParameters(
|
||||
typeEnvironment, cls.typeParameters, fileUri);
|
||||
|
||||
// Check in supers.
|
||||
@@ -1401,7 +1406,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
forEach((String name, Builder builder) {
|
||||
if (builder is SourceMemberBuilder) {
|
||||
builder.checkVariance(this, typeEnvironment);
|
||||
builder.checkTypes(library, typeEnvironment);
|
||||
builder.checkTypes(libraryBuilder, typeEnvironment);
|
||||
} else {
|
||||
assert(
|
||||
false,
|
||||
@@ -1412,7 +1417,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
|
||||
forEachConstructor((String name, MemberBuilder builder) {
|
||||
if (builder is SourceMemberBuilder) {
|
||||
builder.checkTypes(library, typeEnvironment);
|
||||
builder.checkTypes(libraryBuilder, typeEnvironment);
|
||||
} else {
|
||||
assert(false,
|
||||
"Unexpected constructor builder $builder (${builder.runtimeType})");
|
||||
@@ -1607,8 +1612,8 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
memberSignature.parent = cls;
|
||||
|
||||
if (member is Procedure) {
|
||||
library.forwardersOrigins.add(memberSignature);
|
||||
library.forwardersOrigins.add(member);
|
||||
libraryBuilder.forwardersOrigins.add(memberSignature);
|
||||
libraryBuilder.forwardersOrigins.add(member);
|
||||
}
|
||||
}
|
||||
changed = true;
|
||||
@@ -1720,7 +1725,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
target.loader.coreTypes,
|
||||
new ThisExpression(),
|
||||
invocationName,
|
||||
new Arguments.forwarded(procedure.function, library.library),
|
||||
new Arguments.forwarded(procedure.function, libraryBuilder.library),
|
||||
procedure.fileOffset,
|
||||
/*isSuper=*/ false);
|
||||
Expression result = new InstanceInvocation(InstanceAccessKind.Instance,
|
||||
@@ -1732,7 +1737,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
result = new AsExpression(result, procedure.function.returnType)
|
||||
..isTypeError = true
|
||||
..isForDynamic = true
|
||||
..isForNonNullableByDefault = library.isNonNullableByDefault
|
||||
..isForNonNullableByDefault = libraryBuilder.isNonNullableByDefault
|
||||
..fileOffset = procedure.fileOffset;
|
||||
}
|
||||
procedure.function.body = new ReturnStatement(result)
|
||||
@@ -2041,10 +2046,10 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
bool isValid = types.isSubtypeOf(
|
||||
getterType,
|
||||
setterType,
|
||||
library.isNonNullableByDefault
|
||||
libraryBuilder.isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities);
|
||||
if (!isValid && !library.isNonNullableByDefault) {
|
||||
if (!isValid && !libraryBuilder.isNonNullableByDefault) {
|
||||
// Allow assignability in legacy libraries.
|
||||
isValid = types.isSubtypeOf(
|
||||
setterType, getterType, SubtypeCheckMode.ignoringNullabilities);
|
||||
@@ -2059,12 +2064,12 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
if (getterOrigin.enclosingClass == cls &&
|
||||
setterOrigin.enclosingClass == cls) {
|
||||
Template<Message Function(DartType, String, DartType, String, bool)>
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterType
|
||||
: templateInvalidGetterSetterTypeLegacy;
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
template.withArguments(getterType, getterMemberName, setterType,
|
||||
setterMemberName, library.isNonNullableByDefault),
|
||||
setterMemberName, libraryBuilder.isNonNullableByDefault),
|
||||
getterOrigin.fileOffset,
|
||||
getterOrigin.name.text.length,
|
||||
getterOrigin.fileUri,
|
||||
@@ -2076,17 +2081,17 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
]);
|
||||
} else if (getterOrigin.enclosingClass == cls) {
|
||||
Template<Message Function(DartType, String, DartType, String, bool)>
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterTypeSetterInheritedGetter
|
||||
: templateInvalidGetterSetterTypeSetterInheritedGetterLegacy;
|
||||
if (getterOrigin is Field) {
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterTypeSetterInheritedField
|
||||
: templateInvalidGetterSetterTypeSetterInheritedFieldLegacy;
|
||||
}
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
template.withArguments(getterType, getterMemberName, setterType,
|
||||
setterMemberName, library.isNonNullableByDefault),
|
||||
setterMemberName, libraryBuilder.isNonNullableByDefault),
|
||||
getterOrigin.fileOffset,
|
||||
getterOrigin.name.text.length,
|
||||
getterOrigin.fileUri,
|
||||
@@ -2098,20 +2103,20 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
]);
|
||||
} else if (setterOrigin.enclosingClass == cls) {
|
||||
Template<Message Function(DartType, String, DartType, String, bool)>
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterTypeGetterInherited
|
||||
: templateInvalidGetterSetterTypeGetterInheritedLegacy;
|
||||
Template<Message Function(String)> context =
|
||||
templateInvalidGetterSetterTypeGetterContext;
|
||||
if (getterOrigin is Field) {
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterTypeFieldInherited
|
||||
: templateInvalidGetterSetterTypeFieldInheritedLegacy;
|
||||
context = templateInvalidGetterSetterTypeFieldContext;
|
||||
}
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
template.withArguments(getterType, getterMemberName, setterType,
|
||||
setterMemberName, library.isNonNullableByDefault),
|
||||
setterMemberName, libraryBuilder.isNonNullableByDefault),
|
||||
setterOrigin.fileOffset,
|
||||
setterOrigin.name.text.length,
|
||||
setterOrigin.fileUri,
|
||||
@@ -2123,20 +2128,20 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
]);
|
||||
} else {
|
||||
Template<Message Function(DartType, String, DartType, String, bool)>
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterTypeBothInheritedGetter
|
||||
: templateInvalidGetterSetterTypeBothInheritedGetterLegacy;
|
||||
Template<Message Function(String)> context =
|
||||
templateInvalidGetterSetterTypeGetterContext;
|
||||
if (getterOrigin is Field) {
|
||||
template = library.isNonNullableByDefault
|
||||
template = libraryBuilder.isNonNullableByDefault
|
||||
? templateInvalidGetterSetterTypeBothInheritedField
|
||||
: templateInvalidGetterSetterTypeBothInheritedFieldLegacy;
|
||||
context = templateInvalidGetterSetterTypeFieldContext;
|
||||
}
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
template.withArguments(getterType, getterMemberName, setterType,
|
||||
setterMemberName, library.isNonNullableByDefault),
|
||||
setterMemberName, libraryBuilder.isNonNullableByDefault),
|
||||
charOffset,
|
||||
noLength,
|
||||
fileUri,
|
||||
@@ -2239,7 +2244,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
interfaceSubstitution.substituteType(interfaceBound);
|
||||
}
|
||||
DartType computedBound = substitution.substituteType(interfaceBound);
|
||||
if (!library.isNonNullableByDefault) {
|
||||
if (!libraryBuilder.isNonNullableByDefault) {
|
||||
computedBound = legacyErasure(computedBound);
|
||||
}
|
||||
if (declaredNeedsLegacyErasure) {
|
||||
@@ -2260,7 +2265,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
computedBound,
|
||||
"${interfaceMemberOrigin.enclosingClass!.name}."
|
||||
"${interfaceMemberOrigin.name.text}",
|
||||
library.isNonNullableByDefault),
|
||||
libraryBuilder.isNonNullableByDefault),
|
||||
declaredMember.fileOffset,
|
||||
noLength,
|
||||
context: [
|
||||
@@ -2346,7 +2351,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
(!isCovariantByDeclaration ||
|
||||
!types.isSubtypeOf(
|
||||
supertype, subtype, SubtypeCheckMode.ignoringNullabilities));
|
||||
if (isErrorInNnbdOptedOutMode || library.isNonNullableByDefault) {
|
||||
if (isErrorInNnbdOptedOutMode || libraryBuilder.isNonNullableByDefault) {
|
||||
String declaredMemberName = '${declaredMember.enclosingClass!.name}'
|
||||
'.${declaredMember.name.text}';
|
||||
String interfaceMemberName =
|
||||
@@ -2362,14 +2367,14 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
declaredType,
|
||||
interfaceType,
|
||||
interfaceMemberName,
|
||||
library.isNonNullableByDefault);
|
||||
libraryBuilder.isNonNullableByDefault);
|
||||
} else {
|
||||
message = templateOverrideTypeMismatchReturnType.withArguments(
|
||||
declaredMemberName,
|
||||
declaredType,
|
||||
interfaceType,
|
||||
interfaceMemberName,
|
||||
library.isNonNullableByDefault);
|
||||
libraryBuilder.isNonNullableByDefault);
|
||||
}
|
||||
fileOffset = declaredMember.fileOffset;
|
||||
} else {
|
||||
@@ -2379,7 +2384,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
declaredType,
|
||||
interfaceType,
|
||||
interfaceMemberName,
|
||||
library.isNonNullableByDefault);
|
||||
libraryBuilder.isNonNullableByDefault);
|
||||
fileOffset = declaredParameter.fileOffset;
|
||||
}
|
||||
reportInvalidOverride(
|
||||
@@ -2737,7 +2742,8 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
|
||||
if (declaredMember.enclosingClass == cls) {
|
||||
// Ordinary override
|
||||
library.addProblem(message, fileOffset, length, declaredMember.fileUri,
|
||||
libraryBuilder.addProblem(
|
||||
message, fileOffset, length, declaredMember.fileUri,
|
||||
context: context);
|
||||
} else {
|
||||
context = [
|
||||
@@ -2746,7 +2752,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
];
|
||||
if (isInterfaceCheck) {
|
||||
// Interface check
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateInterfaceCheck.withArguments(
|
||||
declaredMember.name.text, cls.name),
|
||||
cls.fileOffset,
|
||||
@@ -2759,7 +2765,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
String baseName = cls.superclass!.demangledName;
|
||||
String mixinName = cls.mixedInClass!.name;
|
||||
int classNameLength = cls.nameAsMixinApplicationSubclass.length;
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateImplicitMixinOverride.withArguments(
|
||||
mixinName, baseName, declaredMember.name.text),
|
||||
cls.fileOffset,
|
||||
@@ -2768,7 +2774,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
||||
context: context);
|
||||
} else {
|
||||
// Named mixin application class
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateNamedMixinOverride.withArguments(
|
||||
cls.name, declaredMember.name.text),
|
||||
cls.fileOffset,
|
||||
@@ -2799,7 +2805,7 @@ bool shouldOverrideProblemBeOverlooked(ClassBuilder classBuilder) {
|
||||
/// 'dart:_interceptors' that implements both `int` and `double`, and `JsArray`
|
||||
/// in `dart:js` that implement both `ListMixin` and `JsObject`.
|
||||
int? getOverlookedOverrideProblemChoice(ClassBuilder classBuilder) {
|
||||
String uri = '${classBuilder.library.importUri}';
|
||||
String uri = '${classBuilder.libraryBuilder.importUri}';
|
||||
if (uri == 'dart:js' && classBuilder.fileUri.pathSegments.last == 'js.dart') {
|
||||
return 0;
|
||||
} else if (uri == 'dart:_interceptors' &&
|
||||
@@ -2815,7 +2821,8 @@ class _RedirectingConstructorsFieldBuilder extends DillFieldBuilder
|
||||
: super(field, parent);
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => super.library as SourceLibraryBuilder;
|
||||
SourceLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as SourceLibraryBuilder;
|
||||
|
||||
@override
|
||||
void buildOutlineExpressions(
|
||||
|
||||
@@ -186,19 +186,19 @@ class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
|
||||
bool _hasBeenBuilt = false;
|
||||
|
||||
@override
|
||||
Constructor build(SourceLibraryBuilder libraryBuilder) {
|
||||
Constructor build(SourceLibraryBuilder sourceLibraryBuilder) {
|
||||
if (!_hasBeenBuilt) {
|
||||
buildFunction(libraryBuilder);
|
||||
buildFunction(sourceLibraryBuilder);
|
||||
_constructor.function.fileOffset = charOpenParenOffset;
|
||||
_constructor.function.fileEndOffset = _constructor.fileEndOffset;
|
||||
_constructor.function.typeParameters = const <TypeParameter>[];
|
||||
_constructor.isConst = isConst;
|
||||
_constructor.isExternal = isExternal;
|
||||
updatePrivateMemberName(_constructor, libraryBuilder);
|
||||
updatePrivateMemberName(_constructor, sourceLibraryBuilder);
|
||||
|
||||
if (_constructorTearOff != null) {
|
||||
buildConstructorTearOffProcedure(_constructorTearOff!, _constructor,
|
||||
classBuilder.cls, libraryBuilder);
|
||||
classBuilder.cls, sourceLibraryBuilder);
|
||||
}
|
||||
|
||||
_hasBeenBuilt = true;
|
||||
@@ -217,10 +217,10 @@ class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
|
||||
}
|
||||
if (needsInference) {
|
||||
assert(
|
||||
library == libraryBuilder,
|
||||
"Unexpected library builder ${libraryBuilder} for"
|
||||
" constructor $this in ${library}.");
|
||||
libraryBuilder.loader
|
||||
libraryBuilder == sourceLibraryBuilder,
|
||||
"Unexpected library builder ${sourceLibraryBuilder} for"
|
||||
" constructor $this in ${libraryBuilder}.");
|
||||
sourceLibraryBuilder.loader
|
||||
.registerConstructorToBeInferred(_constructor, this);
|
||||
}
|
||||
}
|
||||
@@ -242,9 +242,9 @@ class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
|
||||
if (_hasSuperInitializingFormals) {
|
||||
List<Initializer>? initializers;
|
||||
if (beginInitializers != null) {
|
||||
BodyBuilder bodyBuilder = library.loader
|
||||
.createBodyBuilderForOutlineExpression(
|
||||
library, classBuilder, this, classBuilder.scope, fileUri);
|
||||
BodyBuilder bodyBuilder = libraryBuilder.loader
|
||||
.createBodyBuilderForOutlineExpression(libraryBuilder,
|
||||
classBuilder, this, classBuilder.scope, fileUri);
|
||||
bodyBuilder.constantContext = ConstantContext.required;
|
||||
initializers = bodyBuilder.parseInitializers(beginInitializers!,
|
||||
doFinishConstructor: false);
|
||||
@@ -289,7 +289,7 @@ class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
|
||||
superTarget = (initializers.last as SuperInitializer).target;
|
||||
} else {
|
||||
MemberBuilder? memberBuilder = superclassBuilder.constructorScope
|
||||
.lookup("", charOffset, library.fileUri);
|
||||
.lookup("", charOffset, libraryBuilder.fileUri);
|
||||
if (memberBuilder is ConstructorBuilder) {
|
||||
superTarget = memberBuilder.constructor;
|
||||
} else {
|
||||
@@ -299,8 +299,8 @@ class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
|
||||
}
|
||||
|
||||
MemberBuilder? constructorBuilder =
|
||||
superclassBuilder.findConstructorOrFactory(
|
||||
superTarget.name.text, charOffset, library.fileUri, library);
|
||||
superclassBuilder.findConstructorOrFactory(superTarget.name.text,
|
||||
charOffset, libraryBuilder.fileUri, libraryBuilder);
|
||||
return constructorBuilder is ConstructorBuilder ? constructorBuilder : null;
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ class DeclaredSourceConstructorBuilder extends SourceFunctionBuilderImpl
|
||||
positionalSuperParameters: positionalSuperParameters ?? const <int>[],
|
||||
namedSuperParameters: namedSuperParameters ?? const <String>[],
|
||||
isOutlineNode: true,
|
||||
libraryBuilder: library));
|
||||
libraryBuilder: libraryBuilder));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,7 +781,8 @@ class SyntheticSourceConstructorBuilder extends DillConstructorBuilder
|
||||
super(constructor, constructorTearOff, parent);
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => super.library as SourceLibraryBuilder;
|
||||
SourceLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as SourceLibraryBuilder;
|
||||
|
||||
// TODO(johnniwinther,cstefantsova): Rename [actualOrigin] to avoid the
|
||||
// confusion with patches.
|
||||
@@ -806,7 +807,7 @@ class SyntheticSourceConstructorBuilder extends DillConstructorBuilder
|
||||
List<SynthesizedFunctionNode> synthesizedFunctionNodes) {
|
||||
if (_origin != null) {
|
||||
// Ensure that default value expressions have been created for [_origin].
|
||||
LibraryBuilder originLibraryBuilder = _origin!.library;
|
||||
LibraryBuilder originLibraryBuilder = _origin!.libraryBuilder;
|
||||
if (originLibraryBuilder is SourceLibraryBuilder) {
|
||||
// If [_origin] is from a source library, we need to build the default
|
||||
// values and initializers first.
|
||||
|
||||
@@ -552,17 +552,21 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
Class build(SourceLibraryBuilder libraryBuilder, LibraryBuilder coreLibrary) {
|
||||
Class build(
|
||||
SourceLibraryBuilder sourceLibraryBuilder, LibraryBuilder coreLibrary) {
|
||||
cls.isEnum = true;
|
||||
intType.resolveIn(coreLibrary.scope, charOffset, fileUri, libraryBuilder);
|
||||
intType.resolveIn(
|
||||
coreLibrary.scope, charOffset, fileUri, sourceLibraryBuilder);
|
||||
stringType.resolveIn(
|
||||
coreLibrary.scope, charOffset, fileUri, libraryBuilder);
|
||||
coreLibrary.scope, charOffset, fileUri, sourceLibraryBuilder);
|
||||
objectType.resolveIn(
|
||||
coreLibrary.scope, charOffset, fileUri, libraryBuilder);
|
||||
coreLibrary.scope, charOffset, fileUri, sourceLibraryBuilder);
|
||||
NamedTypeBuilder? enumType = _computeEnumSupertype();
|
||||
enumType!.resolveIn(coreLibrary.scope, charOffset, fileUri, libraryBuilder);
|
||||
enumType!.resolveIn(
|
||||
coreLibrary.scope, charOffset, fileUri, sourceLibraryBuilder);
|
||||
|
||||
listType.resolveIn(coreLibrary.scope, charOffset, fileUri, libraryBuilder);
|
||||
listType.resolveIn(
|
||||
coreLibrary.scope, charOffset, fileUri, sourceLibraryBuilder);
|
||||
|
||||
List<Expression> values = <Expression>[];
|
||||
if (enumConstantInfos != null) {
|
||||
@@ -571,7 +575,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
Builder declaration = firstMemberNamed(enumConstantInfo.name)!;
|
||||
if (declaration.isField) {
|
||||
SourceFieldBuilder fieldBuilder = declaration as SourceFieldBuilder;
|
||||
fieldBuilder.build(libraryBuilder);
|
||||
fieldBuilder.build(sourceLibraryBuilder);
|
||||
values.add(new StaticGet(fieldBuilder.field));
|
||||
}
|
||||
}
|
||||
@@ -579,7 +583,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
}
|
||||
SourceFieldBuilder valuesBuilder =
|
||||
firstMemberNamed("values") as SourceFieldBuilder;
|
||||
valuesBuilder.build(libraryBuilder);
|
||||
valuesBuilder.build(sourceLibraryBuilder);
|
||||
|
||||
// The super initializer for the synthesized default constructor is
|
||||
// inserted here if the enum's supertype is _Enum to preserve the legacy
|
||||
@@ -590,11 +594,11 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
if (identical(this.supertypeBuilder, enumType)) {
|
||||
if (synthesizedDefaultConstructorBuilder != null) {
|
||||
Constructor constructor =
|
||||
synthesizedDefaultConstructorBuilder!.build(libraryBuilder);
|
||||
synthesizedDefaultConstructorBuilder!.build(sourceLibraryBuilder);
|
||||
ClassBuilder objectClass = objectType.declaration as ClassBuilder;
|
||||
ClassBuilder enumClass = enumType.declaration as ClassBuilder;
|
||||
MemberBuilder? superConstructor = enumClass.findConstructorOrFactory(
|
||||
"", charOffset, fileUri, libraryBuilder);
|
||||
"", charOffset, fileUri, sourceLibraryBuilder);
|
||||
if (superConstructor == null || !superConstructor.isConstructor) {
|
||||
// TODO(ahe): Ideally, we would also want to check that [Object]'s
|
||||
// unnamed constructor requires no arguments. But that information
|
||||
@@ -602,7 +606,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
// situation that can happen unless you start modifying the SDK
|
||||
// sources. (We should add a correct message. We no longer depend on
|
||||
// Object here.)
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
messageNoUnnamedConstructorInObject,
|
||||
objectClass.charOffset,
|
||||
objectClass.name.length,
|
||||
@@ -611,19 +615,19 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
constructor.initializers.add(new SuperInitializer(
|
||||
superConstructor.member as Constructor,
|
||||
new Arguments.forwarded(
|
||||
constructor.function, libraryBuilder.library))
|
||||
constructor.function, sourceLibraryBuilder.library))
|
||||
..parent = constructor);
|
||||
}
|
||||
synthesizedDefaultConstructorBuilder = null;
|
||||
}
|
||||
}
|
||||
|
||||
return super.build(libraryBuilder, coreLibrary);
|
||||
return super.build(sourceLibraryBuilder, coreLibrary);
|
||||
}
|
||||
|
||||
DartType buildElement(SourceLibraryBuilder libraryBuilder,
|
||||
DartType buildElement(SourceLibraryBuilder sourceLibraryBuilder,
|
||||
SourceFieldBuilder fieldBuilder, CoreTypes coreTypes) {
|
||||
DartType selfType = this.selfType.build(libraryBuilder);
|
||||
DartType selfType = this.selfType.build(sourceLibraryBuilder);
|
||||
Builder? builder = firstMemberNamed(fieldBuilder.name);
|
||||
if (builder == null || !builder.isField) return selfType;
|
||||
fieldBuilder = builder as SourceFieldBuilder;
|
||||
@@ -669,19 +673,19 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
if (typeArgumentBuilders != null) {
|
||||
typeArguments = <DartType>[];
|
||||
for (TypeBuilder typeBuilder in typeArgumentBuilders) {
|
||||
typeArguments.add(typeBuilder.build(library));
|
||||
typeArguments.add(typeBuilder.build(libraryBuilder));
|
||||
}
|
||||
}
|
||||
if (libraryBuilder.enableEnhancedEnumsInLibrary) {
|
||||
if (sourceLibraryBuilder.enableEnhancedEnumsInLibrary) {
|
||||
// We need to create a BodyBuilder to solve the following: 1) if
|
||||
// the arguments token is provided, we'll use the BodyBuilder to
|
||||
// parse them and perform inference, 2) if the type arguments
|
||||
// aren't provided, but required, we'll use it to infer them, and
|
||||
// 3) in case of erroneous code the constructor invocation should
|
||||
// be built via a body builder to detect potential errors.
|
||||
BodyBuilder bodyBuilder = library.loader
|
||||
BodyBuilder bodyBuilder = libraryBuilder.loader
|
||||
.createBodyBuilderForOutlineExpression(
|
||||
library, this, this, scope, fileUri);
|
||||
libraryBuilder, this, this, scope, fileUri);
|
||||
bodyBuilder.constantContext = ConstantContext.inferred;
|
||||
|
||||
if (enumConstantInfo.argumentsBeginToken != null) {
|
||||
@@ -732,8 +736,8 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
!constructorBuilder.isConst) {
|
||||
// This can only occur if there enhanced enum features are used
|
||||
// when they are not enabled.
|
||||
assert(libraryBuilder.loader.hasSeenError);
|
||||
String text = libraryBuilder.loader.target.context
|
||||
assert(sourceLibraryBuilder.loader.hasSeenError);
|
||||
String text = sourceLibraryBuilder.loader.target.context
|
||||
.format(
|
||||
templateConstructorNotFound
|
||||
.withArguments(fullConstructorNameForErrors)
|
||||
@@ -760,7 +764,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
|
||||
@override
|
||||
void buildOutlineExpressions(
|
||||
SourceLibraryBuilder libraryBuilder,
|
||||
SourceLibraryBuilder sourceLibraryBuilder,
|
||||
ClassHierarchy classHierarchy,
|
||||
List<DelayedActionPerformer> delayedActionPerformers,
|
||||
List<SynthesizedFunctionNode> synthesizedFunctionNodes) {
|
||||
@@ -771,7 +775,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
Builder declaration = firstMemberNamed(enumConstantInfo.name)!;
|
||||
if (declaration.isField) {
|
||||
SourceFieldBuilder fieldBuilder = declaration as SourceFieldBuilder;
|
||||
fieldBuilder.build(libraryBuilder);
|
||||
fieldBuilder.build(sourceLibraryBuilder);
|
||||
values.add(new StaticGet(fieldBuilder.field));
|
||||
}
|
||||
}
|
||||
@@ -782,11 +786,11 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
valuesBuilder.buildBody(
|
||||
classHierarchy.coreTypes,
|
||||
new ListLiteral(values,
|
||||
typeArgument: rawType(library.nonNullable), isConst: true));
|
||||
typeArgument: rawType(libraryBuilder.nonNullable), isConst: true));
|
||||
|
||||
for (SourceFieldBuilder elementBuilder in elementBuilders) {
|
||||
elementBuilder.fieldType = buildElement(
|
||||
libraryBuilder, elementBuilder, classHierarchy.coreTypes);
|
||||
sourceLibraryBuilder, elementBuilder, classHierarchy.coreTypes);
|
||||
}
|
||||
delayedActionPerformers.addAll(_delayedActionPerformers);
|
||||
_delayedActionPerformers.clear();
|
||||
@@ -809,7 +813,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
|
||||
resultType: nameField.getterType),
|
||||
]));
|
||||
|
||||
super.buildOutlineExpressions(library, classHierarchy,
|
||||
super.buildOutlineExpressions(libraryBuilder, classHierarchy,
|
||||
delayedActionPerformers, synthesizedFunctionNodes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
super(metadata, modifiers, name, parent, nameOffset, scope);
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => super.library as SourceLibraryBuilder;
|
||||
SourceLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as SourceLibraryBuilder;
|
||||
|
||||
@override
|
||||
SourceExtensionBuilder get origin => _origin ?? this;
|
||||
@@ -81,7 +82,7 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
Extension get extension => isPatch ? origin._extension : _extension;
|
||||
|
||||
/// Builds the [Extension] for this extension build and inserts the members
|
||||
/// into the [Library] of [libraryBuilder].
|
||||
/// into the [Library] of [sourceLibraryBuilder].
|
||||
///
|
||||
/// [addMembersToLibrary] is `true` if the extension members should be added
|
||||
/// to the library. This is `false` if the extension is in conflict with
|
||||
@@ -89,13 +90,13 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
/// added to the library to avoid name clashes with other members in the
|
||||
/// library.
|
||||
Extension build(
|
||||
SourceLibraryBuilder libraryBuilder, LibraryBuilder coreLibrary,
|
||||
SourceLibraryBuilder sourceLibraryBuilder, LibraryBuilder coreLibrary,
|
||||
{required bool addMembersToLibrary}) {
|
||||
_extension.onType = onType.build(libraryBuilder);
|
||||
_extension.onType = onType.build(sourceLibraryBuilder);
|
||||
extensionTypeShowHideClauseBuilder.buildAndStoreTypes(
|
||||
_extension, libraryBuilder);
|
||||
_extension, sourceLibraryBuilder);
|
||||
|
||||
SourceLibraryBuilder.checkMemberConflicts(library, scope,
|
||||
SourceLibraryBuilder.checkMemberConflicts(libraryBuilder, scope,
|
||||
checkForInstanceVsStaticConflict: true,
|
||||
checkForMethodVsSetterConflict: true);
|
||||
|
||||
@@ -123,7 +124,7 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
}
|
||||
} else if (declaration is SourceMemberBuilder) {
|
||||
SourceMemberBuilder memberBuilder = declaration;
|
||||
memberBuilder.buildMembers(libraryBuilder,
|
||||
memberBuilder.buildMembers(sourceLibraryBuilder,
|
||||
(Member member, BuiltMemberKind memberKind) {
|
||||
if (addMembersToLibrary &&
|
||||
!memberBuilder.isPatch &&
|
||||
@@ -167,17 +168,17 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
assert(kind != null);
|
||||
Reference memberReference;
|
||||
if (member is Field) {
|
||||
libraryBuilder.library.addField(member);
|
||||
sourceLibraryBuilder.library.addField(member);
|
||||
memberReference = member.fieldReference;
|
||||
} else if (member is Procedure) {
|
||||
libraryBuilder.library.addProcedure(member);
|
||||
sourceLibraryBuilder.library.addProcedure(member);
|
||||
memberReference = member.reference;
|
||||
} else {
|
||||
unhandled("${member.runtimeType}", "buildBuilders",
|
||||
member.fileOffset, member.fileUri);
|
||||
}
|
||||
extension.members.add(new ExtensionMemberDescriptor(
|
||||
name: new Name(name, libraryBuilder.library),
|
||||
name: new Name(name, sourceLibraryBuilder.library),
|
||||
member: memberReference,
|
||||
isStatic: memberBuilder.isStatic,
|
||||
kind: kind));
|
||||
@@ -221,8 +222,8 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
// TODO(johnniwinther): Check that type parameters and on-type match
|
||||
// with origin declaration.
|
||||
} else {
|
||||
library.addProblem(messagePatchDeclarationMismatch, patch.charOffset,
|
||||
noLength, patch.fileUri, context: [
|
||||
libraryBuilder.addProblem(messagePatchDeclarationMismatch,
|
||||
patch.charOffset, noLength, patch.fileUri, context: [
|
||||
messagePatchDeclarationOrigin.withLocation(
|
||||
fileUri, charOffset, noLength)
|
||||
]);
|
||||
@@ -241,28 +242,28 @@ class SourceExtensionBuilder extends ExtensionBuilderImpl {
|
||||
}
|
||||
|
||||
void checkTypesInOutline(TypeEnvironment typeEnvironment) {
|
||||
library.checkBoundsInTypeParameters(
|
||||
libraryBuilder.checkBoundsInTypeParameters(
|
||||
typeEnvironment, extension.typeParameters, fileUri);
|
||||
|
||||
// Check on clause.
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (_extension.onType != null) {
|
||||
library.checkBoundsInType(_extension.onType, typeEnvironment,
|
||||
libraryBuilder.checkBoundsInType(_extension.onType, typeEnvironment,
|
||||
onType.fileUri!, onType.charOffset!);
|
||||
}
|
||||
|
||||
forEach((String name, Builder builder) {
|
||||
if (builder is SourceFieldBuilder) {
|
||||
// Check fields.
|
||||
library.checkTypesInField(builder, typeEnvironment);
|
||||
libraryBuilder.checkTypesInField(builder, typeEnvironment);
|
||||
} else if (builder is SourceProcedureBuilder) {
|
||||
// Check procedures
|
||||
library.checkTypesInFunctionBuilder(builder, typeEnvironment);
|
||||
libraryBuilder.checkTypesInFunctionBuilder(builder, typeEnvironment);
|
||||
if (builder.isGetter) {
|
||||
Builder? setterDeclaration =
|
||||
scope.lookupLocalMember(builder.name, setter: true);
|
||||
if (setterDeclaration != null) {
|
||||
library.checkGetterSetterTypes(builder,
|
||||
libraryBuilder.checkGetterSetterTypes(builder,
|
||||
setterDeclaration as ProcedureBuilder, typeEnvironment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
|
||||
|
||||
// Ensure that constant factories only have constant targets/bodies.
|
||||
if (isConst && !target.isConst) {
|
||||
library.addProblem(messageConstFactoryRedirectionToNonConst, charOffset,
|
||||
noLength, fileUri);
|
||||
libraryBuilder.addProblem(messageConstFactoryRedirectionToNonConst,
|
||||
charOffset, noLength, fileUri);
|
||||
}
|
||||
|
||||
bodyInternal = new RedirectingFactoryBody(target, typeArguments, function);
|
||||
@@ -334,7 +334,8 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
|
||||
for (int i = 0; i < function.typeParameters.length; i++) {
|
||||
substitution[function.typeParameters[i]] =
|
||||
new TypeParameterType.withDefaultNullabilityForLibrary(
|
||||
actualOrigin!.function.typeParameters[i], library.library);
|
||||
actualOrigin!.function.typeParameters[i],
|
||||
libraryBuilder.library);
|
||||
}
|
||||
typeArguments = new List<DartType>.generate(typeArguments.length,
|
||||
(int i) => substitute(typeArguments[i], substitution),
|
||||
@@ -355,8 +356,8 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
Procedure build(SourceLibraryBuilder libraryBuilder) {
|
||||
buildFunction(libraryBuilder);
|
||||
Procedure build(SourceLibraryBuilder sourceLibraryBuilder) {
|
||||
buildFunction(sourceLibraryBuilder);
|
||||
_procedureInternal.function.fileOffset = charOpenParenOffset;
|
||||
_procedureInternal.function.fileEndOffset =
|
||||
_procedureInternal.fileEndOffset;
|
||||
@@ -368,14 +369,14 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
|
||||
if (redirectionTarget.typeArguments != null) {
|
||||
typeArguments = new List<DartType>.generate(
|
||||
redirectionTarget.typeArguments!.length,
|
||||
(int i) => redirectionTarget.typeArguments![i].build(library),
|
||||
(int i) => redirectionTarget.typeArguments![i].build(libraryBuilder),
|
||||
growable: false);
|
||||
}
|
||||
updatePrivateMemberName(_procedureInternal, libraryBuilder);
|
||||
updatePrivateMemberName(_procedureInternal, sourceLibraryBuilder);
|
||||
if (_factoryTearOff != null) {
|
||||
_tearOffTypeParameters =
|
||||
buildRedirectingFactoryTearOffProcedureParameters(
|
||||
_factoryTearOff!, _procedureInternal, libraryBuilder);
|
||||
_factoryTearOff!, _procedureInternal, sourceLibraryBuilder);
|
||||
}
|
||||
return _procedureInternal;
|
||||
}
|
||||
@@ -409,7 +410,7 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
|
||||
Builder? targetBuilder = redirectionTarget.target;
|
||||
if (targetBuilder is SourceMemberBuilder) {
|
||||
// Ensure that target has been built.
|
||||
targetBuilder.buildOutlineExpressions(targetBuilder.library,
|
||||
targetBuilder.buildOutlineExpressions(targetBuilder.libraryBuilder,
|
||||
classHierarchy, delayedActionPerformers, synthesizedFunctionNodes);
|
||||
}
|
||||
if (targetBuilder is FunctionBuilder) {
|
||||
|
||||
@@ -119,7 +119,7 @@ class SourceFieldBuilder extends SourceMemberBuilderImpl
|
||||
isExternal: isExternal,
|
||||
isFinal: isFinal,
|
||||
isCovariantByDeclaration: isCovariantByDeclaration,
|
||||
isNonNullableByDefault: library.isNonNullableByDefault);
|
||||
isNonNullableByDefault: libraryBuilder.isNonNullableByDefault);
|
||||
} else if (isLate &&
|
||||
libraryBuilder.loader.target.backendTarget.isLateFieldLoweringEnabled(
|
||||
hasInitializer: hasInitializer,
|
||||
@@ -250,7 +250,7 @@ class SourceFieldBuilder extends SourceMemberBuilderImpl
|
||||
isConst: isConst,
|
||||
isLate: isLate,
|
||||
hasInitializer: hasInitializer,
|
||||
isNonNullableByDefault: library.isNonNullableByDefault,
|
||||
isNonNullableByDefault: libraryBuilder.isNonNullableByDefault,
|
||||
fieldReference: fieldReference,
|
||||
getterReference: fieldGetterReference,
|
||||
setterReference: fieldSetterReference);
|
||||
@@ -446,7 +446,6 @@ class SourceFieldBuilder extends SourceMemberBuilderImpl
|
||||
}
|
||||
|
||||
DartType inferType() {
|
||||
SourceLibraryBuilder library = this.library;
|
||||
if (fieldType is! ImplicitFieldType) {
|
||||
// We have already inferred a type.
|
||||
return fieldType;
|
||||
@@ -457,7 +456,7 @@ class SourceFieldBuilder extends SourceMemberBuilderImpl
|
||||
if (fieldType is ImplicitFieldType) {
|
||||
// `fieldType` may have changed if a circularity was detected when
|
||||
// [inferredType] was computed.
|
||||
if (!library.isNonNullableByDefault) {
|
||||
if (!libraryBuilder.isNonNullableByDefault) {
|
||||
inferredType = legacyErasure(inferredType);
|
||||
}
|
||||
fieldType = implicitFieldType.checkInferred(inferredType);
|
||||
|
||||
@@ -494,7 +494,7 @@ abstract class SourceFunctionBuilderImpl extends SourceMemberBuilderImpl
|
||||
@override
|
||||
bool checkPatch(FunctionBuilder patch) {
|
||||
if (!isExternal) {
|
||||
patch.library.addProblem(
|
||||
patch.libraryBuilder.addProblem(
|
||||
messagePatchNonExternal, patch.charOffset, noLength, patch.fileUri!,
|
||||
context: [
|
||||
messagePatchDeclarationOrigin.withLocation(
|
||||
@@ -507,7 +507,7 @@ abstract class SourceFunctionBuilderImpl extends SourceMemberBuilderImpl
|
||||
|
||||
@override
|
||||
void reportPatchMismatch(Builder patch) {
|
||||
library.addProblem(messagePatchDeclarationMismatch, patch.charOffset,
|
||||
libraryBuilder.addProblem(messagePatchDeclarationMismatch, patch.charOffset,
|
||||
noLength, patch.fileUri!, context: [
|
||||
messagePatchDeclarationOrigin.withLocation(fileUri, charOffset, noLength)
|
||||
]);
|
||||
|
||||
@@ -1449,7 +1449,7 @@ severity: $severity
|
||||
while (iterator.moveNext()) {
|
||||
Builder builder = iterator.current;
|
||||
if (builder is ClassBuilder && builder.isMacro) {
|
||||
Uri libraryUri = builder.library.importUri;
|
||||
Uri libraryUri = builder.libraryBuilder.importUri;
|
||||
if (!precompiledMacroUris.containsKey(libraryUri)) {
|
||||
(macroLibraries[libraryUri] ??= []).add(builder);
|
||||
if (retainDataForTesting) {
|
||||
@@ -1794,7 +1794,7 @@ severity: $severity
|
||||
/// found.
|
||||
void checkObjectClassHierarchy(ClassBuilder objectClass) {
|
||||
if (objectClass is SourceClassBuilder &&
|
||||
objectClass.library.loader == this) {
|
||||
objectClass.libraryBuilder.loader == this) {
|
||||
if (objectClass.supertypeBuilder != null) {
|
||||
objectClass.supertypeBuilder = null;
|
||||
objectClass.addProblem(
|
||||
@@ -1897,7 +1897,7 @@ severity: $severity
|
||||
}
|
||||
|
||||
bool checkEnumSupertypeIsDenylisted(SourceClassBuilder cls) {
|
||||
if (!cls.library.enableEnhancedEnumsInLibrary) {
|
||||
if (!cls.libraryBuilder.enableEnhancedEnumsInLibrary) {
|
||||
cls.addProblem(
|
||||
templateEnumSupertypeOfNonAbstractClass.withArguments(cls.name),
|
||||
cls.charOffset,
|
||||
@@ -1920,7 +1920,7 @@ severity: $severity
|
||||
if (supertype is SourceEnumBuilder) {
|
||||
cls.addProblem(templateExtendingEnum.withArguments(supertype.name),
|
||||
cls.charOffset, noLength);
|
||||
} else if (!cls.library.mayImplementRestrictedTypes &&
|
||||
} else if (!cls.libraryBuilder.mayImplementRestrictedTypes &&
|
||||
(denyListedClasses.contains(supertype) ||
|
||||
identical(supertype, enumClass) &&
|
||||
checkEnumSupertypeIsDenylisted(cls))) {
|
||||
@@ -1968,7 +1968,7 @@ severity: $severity
|
||||
aliasBuilder.fileUri, aliasBuilder.charOffset, noLength),
|
||||
]);
|
||||
return;
|
||||
} else if (!cls.library.mayImplementRestrictedTypes &&
|
||||
} else if (!cls.libraryBuilder.mayImplementRestrictedTypes &&
|
||||
denyListedClasses.contains(builder)) {
|
||||
cls.addProblem(
|
||||
templateExtendingRestricted
|
||||
@@ -2106,7 +2106,7 @@ severity: $severity
|
||||
void checkSupertypes(
|
||||
List<SourceClassBuilder> sourceClasses, Class enumClass) {
|
||||
for (SourceClassBuilder builder in sourceClasses) {
|
||||
if (builder.library.loader == this && !builder.isPatch) {
|
||||
if (builder.libraryBuilder.loader == this && !builder.isPatch) {
|
||||
builder.checkSupertypes(
|
||||
coreTypes, hierarchyBuilder, enumClass, _macroClassBuilder?.cls);
|
||||
}
|
||||
@@ -2151,7 +2151,7 @@ severity: $severity
|
||||
void checkRedirectingFactories(List<SourceClassBuilder> sourceClasses) {
|
||||
// TODO(ahe): Move this to [ClassHierarchyBuilder].
|
||||
for (SourceClassBuilder builder in sourceClasses) {
|
||||
if (builder.library.loader == this && !builder.isPatch) {
|
||||
if (builder.libraryBuilder.loader == this && !builder.isPatch) {
|
||||
builder.checkRedirectingFactories(
|
||||
typeInferenceEngine.typeSchemaEnvironment);
|
||||
}
|
||||
@@ -2165,7 +2165,7 @@ severity: $severity
|
||||
|
||||
List<Class> changedClasses = <Class>[];
|
||||
for (SourceClassBuilder builder in sourceClasses) {
|
||||
if (builder.library.loader == this && !builder.isPatch) {
|
||||
if (builder.libraryBuilder.loader == this && !builder.isPatch) {
|
||||
if (builder.addNoSuchMethodForwarders(target, hierarchy)) {
|
||||
changedClasses.add(builder.cls);
|
||||
}
|
||||
@@ -2177,7 +2177,7 @@ severity: $severity
|
||||
|
||||
void checkMixins(List<SourceClassBuilder> sourceClasses) {
|
||||
for (SourceClassBuilder builder in sourceClasses) {
|
||||
if (builder.library.loader == this && !builder.isPatch) {
|
||||
if (builder.libraryBuilder.loader == this && !builder.isPatch) {
|
||||
Class? mixedInClass = builder.cls.mixedInClass;
|
||||
if (mixedInClass != null && mixedInClass.isMixinDeclaration) {
|
||||
builder.checkMixinApplication(hierarchy, coreTypes);
|
||||
|
||||
@@ -26,7 +26,7 @@ abstract class SourceMemberBuilder implements MemberBuilder {
|
||||
MemberDataForTesting? get dataForTesting;
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library;
|
||||
SourceLibraryBuilder get libraryBuilder;
|
||||
|
||||
/// Builds the core AST structures for this member as needed for the outline.
|
||||
void buildMembers(
|
||||
@@ -91,7 +91,8 @@ abstract class SourceMemberBuilderImpl extends MemberBuilderImpl
|
||||
super(parent, charOffset, fileUri);
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => super.library as SourceLibraryBuilder;
|
||||
SourceLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as SourceLibraryBuilder;
|
||||
|
||||
bool get isRedirectingGenerativeConstructor => false;
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class SourceProcedureBuilder extends SourceFunctionBuilderImpl
|
||||
isExtensionMember: true,
|
||||
reference: _tearOffReference,
|
||||
fileUri: fileUri)
|
||||
..isNonNullableByDefault = library.isNonNullableByDefault;
|
||||
..isNonNullableByDefault = libraryBuilder.isNonNullableByDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,8 +302,8 @@ class SourceProcedureBuilder extends SourceFunctionBuilderImpl
|
||||
/// return (S s, Y y) => E|method<T, S>(#this, s, y);
|
||||
/// }
|
||||
///
|
||||
void _buildExtensionTearOff(
|
||||
SourceLibraryBuilder libraryBuilder, ExtensionBuilder extensionBuilder) {
|
||||
void _buildExtensionTearOff(SourceLibraryBuilder sourceLibraryBuilder,
|
||||
ExtensionBuilder extensionBuilder) {
|
||||
assert(
|
||||
_extensionTearOff != null, "No extension tear off created for $this.");
|
||||
|
||||
@@ -418,7 +418,8 @@ class SourceProcedureBuilder extends SourceFunctionBuilderImpl
|
||||
typeParameters: tearOffTypeParameters,
|
||||
positionalParameters: [extensionThis],
|
||||
requiredParameterCount: 1,
|
||||
returnType: closure.function.computeFunctionType(library.nonNullable))
|
||||
returnType:
|
||||
closure.function.computeFunctionType(libraryBuilder.nonNullable))
|
||||
..fileOffset = fileOffset
|
||||
..fileEndOffset = fileEndOffset)
|
||||
..fileUri = fileUri
|
||||
|
||||
@@ -75,7 +75,8 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
super(metadata, name, parent, charOffset);
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => super.library as SourceLibraryBuilder;
|
||||
SourceLibraryBuilder get libraryBuilder =>
|
||||
super.libraryBuilder as SourceLibraryBuilder;
|
||||
|
||||
@override
|
||||
List<TypeVariableBuilder>? get typeVariables => _typeVariables;
|
||||
@@ -141,7 +142,7 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
if (thisType != null) {
|
||||
if (identical(thisType, pendingTypeAliasMarker)) {
|
||||
thisType = cyclicTypeAliasMarker;
|
||||
library.addProblem(templateCyclicTypedef.withArguments(name),
|
||||
libraryBuilder.addProblem(templateCyclicTypedef.withArguments(name),
|
||||
charOffset, noLength, fileUri);
|
||||
return const InvalidType();
|
||||
} else if (identical(thisType, cyclicTypeAliasMarker)) {
|
||||
@@ -156,14 +157,14 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
TypeBuilder? type = this.type;
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (type != null) {
|
||||
DartType builtType =
|
||||
type.build(library, origin: thisTypedefType(typedef, library));
|
||||
DartType builtType = type.build(libraryBuilder,
|
||||
origin: thisTypedefType(typedef, libraryBuilder));
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (builtType != null) {
|
||||
if (typeVariables != null) {
|
||||
for (TypeVariableBuilder tv in typeVariables!) {
|
||||
// Follow bound in order to find all cycles
|
||||
tv.bound?.build(library);
|
||||
tv.bound?.build(libraryBuilder);
|
||||
}
|
||||
}
|
||||
if (identical(thisType, cyclicTypeAliasMarker)) {
|
||||
@@ -204,7 +205,7 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
// At this point, [parent] should be a [SourceLibraryBuilder] because
|
||||
// otherwise it's a compiled library loaded from a dill file, and the
|
||||
// bounds should have been assigned.
|
||||
library.registerPendingNullability(
|
||||
libraryBuilder.registerPendingNullability(
|
||||
_typeVariables![i].fileUri!,
|
||||
_typeVariables![i].charOffset,
|
||||
asTypeArguments[i] as TypeParameterType);
|
||||
@@ -248,9 +249,9 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
}
|
||||
|
||||
void checkTypesInOutline(TypeEnvironment typeEnvironment) {
|
||||
library.checkBoundsInTypeParameters(
|
||||
libraryBuilder.checkBoundsInTypeParameters(
|
||||
typeEnvironment, typedef.typeParameters, fileUri);
|
||||
library.checkBoundsInType(
|
||||
libraryBuilder.checkBoundsInType(
|
||||
typedef.type!, typeEnvironment, fileUri, type?.charOffset ?? charOffset,
|
||||
allowSuperBounded: false);
|
||||
}
|
||||
@@ -318,7 +319,7 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
|
||||
target = builder.readTarget!;
|
||||
}
|
||||
Name targetName =
|
||||
new Name(constructorName, declaration.library.library);
|
||||
new Name(constructorName, declaration.libraryBuilder.library);
|
||||
Reference? tearOffReference;
|
||||
if (library.referencesFromIndexed != null) {
|
||||
tearOffReference = library.referencesFromIndexed!
|
||||
|
||||
@@ -326,7 +326,7 @@ class _SyncClosureContext implements ClosureContext {
|
||||
// No explicit return and the function doesn't complete normally; that
|
||||
// is, it throws.
|
||||
actualReturnedType =
|
||||
NeverType.fromNullability(inferrer.library.nonNullable);
|
||||
NeverType.fromNullability(inferrer.libraryBuilder.nonNullable);
|
||||
}
|
||||
// Use the types seen from the explicit return statements.
|
||||
for (int i = 0; i < _returnStatements!.length; i++) {
|
||||
@@ -344,7 +344,7 @@ class _SyncClosureContext implements ClosureContext {
|
||||
} else {
|
||||
actualReturnedType = inferrer.typeSchemaEnvironment
|
||||
.getStandardUpperBound(
|
||||
actualReturnedType, type, inferrer.library.library);
|
||||
actualReturnedType, type, inferrer.libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ class _SyncClosureContext implements ClosureContext {
|
||||
} else {
|
||||
actualReturnedType = inferrer.typeSchemaEnvironment
|
||||
.getStandardUpperBound(
|
||||
actualReturnedType, type, inferrer.library.library);
|
||||
actualReturnedType, type, inferrer.libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
} else if (hasImplicitReturn) {
|
||||
@@ -413,8 +413,8 @@ class _SyncClosureContext implements ClosureContext {
|
||||
}
|
||||
}
|
||||
|
||||
return _inferredReturnType =
|
||||
demoteTypeInLibrary(inferredReturnType, inferrer.library.library);
|
||||
return _inferredReturnType = demoteTypeInLibrary(
|
||||
inferredReturnType, inferrer.libraryBuilder.library);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -432,7 +432,7 @@ class _SyncClosureContext implements ClosureContext {
|
||||
returnType = _declaredReturnType;
|
||||
}
|
||||
if (!inferrer.isTopLevel &&
|
||||
inferrer.library.isNonNullableByDefault &&
|
||||
inferrer.libraryBuilder.isNonNullableByDefault &&
|
||||
!containsInvalidType(returnType) &&
|
||||
returnType.isPotentiallyNonNullable &&
|
||||
inferrer.flowAnalysis.isReachable) {
|
||||
@@ -443,7 +443,7 @@ class _SyncClosureContext implements ClosureContext {
|
||||
.wrapInProblem(
|
||||
new NullLiteral()..fileOffset = fileOffset,
|
||||
templateImplicitReturnNull.withArguments(
|
||||
returnType, inferrer.library.isNonNullableByDefault),
|
||||
returnType, inferrer.libraryBuilder.isNonNullableByDefault),
|
||||
fileOffset,
|
||||
noLength))
|
||||
..fileOffset = fileOffset;
|
||||
@@ -707,7 +707,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
DartType unfuturedExpectedType =
|
||||
inferrer.typeSchemaEnvironment.flatten(contextType);
|
||||
DartType futuredExpectedType = inferrer.wrapFutureType(
|
||||
unfuturedExpectedType, inferrer.library.nonNullable);
|
||||
unfuturedExpectedType, inferrer.libraryBuilder.nonNullable);
|
||||
if (inferrer.isAssignable(unfuturedExpectedType, expressionType)) {
|
||||
contextType = unfuturedExpectedType;
|
||||
} else if (inferrer.isAssignable(futuredExpectedType, expressionType)) {
|
||||
@@ -732,7 +732,8 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
} else {
|
||||
// No explicit return and the function doesn't complete normally; that
|
||||
// is, it throws.
|
||||
inferredType = NeverType.fromNullability(inferrer.library.nonNullable);
|
||||
inferredType =
|
||||
NeverType.fromNullability(inferrer.libraryBuilder.nonNullable);
|
||||
}
|
||||
// Use the types seen from the explicit return statements.
|
||||
for (int i = 0; i < _returnStatements!.length; i++) {
|
||||
@@ -743,7 +744,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
inferredType = unwrappedType;
|
||||
} else {
|
||||
inferredType = inferrer.typeSchemaEnvironment.getStandardUpperBound(
|
||||
inferredType, unwrappedType, inferrer.library.library);
|
||||
inferredType, unwrappedType, inferrer.libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,7 +768,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
}
|
||||
inferredType = inferrer.wrapFutureType(
|
||||
inferrer.typeSchemaEnvironment.flatten(inferredType),
|
||||
inferrer.library.nonNullable);
|
||||
inferrer.libraryBuilder.nonNullable);
|
||||
} else {
|
||||
if (_returnStatements!.isNotEmpty) {
|
||||
// Use the types seen from the explicit return statements.
|
||||
@@ -789,7 +790,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
inferredType = unwrappedType;
|
||||
} else {
|
||||
inferredType = inferrer.typeSchemaEnvironment.getStandardUpperBound(
|
||||
inferredType, unwrappedType, inferrer.library.library);
|
||||
inferredType, unwrappedType, inferrer.libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
} else if (hasImplicitReturn) {
|
||||
@@ -800,8 +801,8 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
// that is, it throws.
|
||||
inferredType = const NullType();
|
||||
}
|
||||
inferredType =
|
||||
inferrer.wrapFutureType(inferredType!, inferrer.library.nonNullable);
|
||||
inferredType = inferrer.wrapFutureType(
|
||||
inferredType!, inferrer.libraryBuilder.nonNullable);
|
||||
|
||||
if (!inferrer.typeSchemaEnvironment.isSubtypeOf(
|
||||
inferredType, _returnContext, SubtypeCheckMode.withNullabilities)) {
|
||||
@@ -823,7 +824,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
}
|
||||
|
||||
return _inferredReturnType =
|
||||
demoteTypeInLibrary(inferredType, inferrer.library.library);
|
||||
demoteTypeInLibrary(inferredType, inferrer.libraryBuilder.library);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -842,7 +843,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
}
|
||||
returnType = inferrer.typeSchemaEnvironment.flatten(returnType);
|
||||
if (!inferrer.isTopLevel &&
|
||||
inferrer.library.isNonNullableByDefault &&
|
||||
inferrer.libraryBuilder.isNonNullableByDefault &&
|
||||
!containsInvalidType(returnType) &&
|
||||
returnType.isPotentiallyNonNullable &&
|
||||
inferrer.flowAnalysis.isReachable) {
|
||||
@@ -853,7 +854,7 @@ class _AsyncClosureContext implements ClosureContext {
|
||||
.wrapInProblem(
|
||||
new NullLiteral()..fileOffset = fileOffset,
|
||||
templateImplicitReturnNull.withArguments(
|
||||
returnType, inferrer.library.isNonNullableByDefault),
|
||||
returnType, inferrer.libraryBuilder.isNonNullableByDefault),
|
||||
fileOffset,
|
||||
noLength))
|
||||
..fileOffset = fileOffset;
|
||||
@@ -922,8 +923,10 @@ class _SyncStarClosureContext implements ClosureContext {
|
||||
void handleYield(TypeInferrerImpl inferrer, YieldStatement node,
|
||||
ExpressionInferenceResult expressionResult) {
|
||||
DartType expectedType = node.isYieldStar
|
||||
? inferrer.wrapType(_yieldElementContext,
|
||||
inferrer.coreTypes.iterableClass, inferrer.library.nonNullable)
|
||||
? inferrer.wrapType(
|
||||
_yieldElementContext,
|
||||
inferrer.coreTypes.iterableClass,
|
||||
inferrer.libraryBuilder.nonNullable)
|
||||
: _yieldElementContext;
|
||||
Expression expression = inferrer
|
||||
.ensureAssignableResult(expectedType, expressionResult,
|
||||
@@ -961,7 +964,7 @@ class _SyncStarClosureContext implements ClosureContext {
|
||||
} else {
|
||||
inferredElementType = inferrer.typeSchemaEnvironment
|
||||
.getStandardUpperBound(
|
||||
inferredElementType, type, inferrer.library.library);
|
||||
inferredElementType, type, inferrer.libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
} else if (hasImplicitReturn) {
|
||||
@@ -972,14 +975,14 @@ class _SyncStarClosureContext implements ClosureContext {
|
||||
// it throws.
|
||||
if (inferrer.isNonNullableByDefault) {
|
||||
inferredElementType =
|
||||
NeverType.fromNullability(inferrer.library.nonNullable);
|
||||
NeverType.fromNullability(inferrer.libraryBuilder.nonNullable);
|
||||
} else {
|
||||
inferredElementType = const NullType();
|
||||
}
|
||||
}
|
||||
|
||||
DartType inferredType = inferrer.wrapType(inferredElementType!,
|
||||
inferrer.coreTypes.iterableClass, inferrer.library.nonNullable);
|
||||
inferrer.coreTypes.iterableClass, inferrer.libraryBuilder.nonNullable);
|
||||
|
||||
if (!inferrer.typeSchemaEnvironment.isSubtypeOf(inferredType,
|
||||
_yieldElementContext, SubtypeCheckMode.withNullabilities)) {
|
||||
@@ -988,7 +991,7 @@ class _SyncStarClosureContext implements ClosureContext {
|
||||
inferredType = inferrer.computeGreatestClosure2(_declaredReturnType);
|
||||
}
|
||||
|
||||
return demoteTypeInLibrary(inferredType, inferrer.library.library);
|
||||
return demoteTypeInLibrary(inferredType, inferrer.libraryBuilder.library);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1055,7 +1058,7 @@ class _AsyncStarClosureContext implements ClosureContext {
|
||||
ExpressionInferenceResult expressionResult) {
|
||||
DartType expectedType = node.isYieldStar
|
||||
? inferrer.wrapType(_yieldElementContext,
|
||||
inferrer.coreTypes.streamClass, inferrer.library.nonNullable)
|
||||
inferrer.coreTypes.streamClass, inferrer.libraryBuilder.nonNullable)
|
||||
: _yieldElementContext;
|
||||
|
||||
Expression expression = inferrer
|
||||
@@ -1092,8 +1095,8 @@ class _AsyncStarClosureContext implements ClosureContext {
|
||||
inferredElementType = elementType;
|
||||
} else {
|
||||
inferredElementType = inferrer.typeSchemaEnvironment
|
||||
.getStandardUpperBound(
|
||||
inferredElementType, elementType, inferrer.library.library);
|
||||
.getStandardUpperBound(inferredElementType, elementType,
|
||||
inferrer.libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
} else if (hasImplicitReturn) {
|
||||
@@ -1104,14 +1107,14 @@ class _AsyncStarClosureContext implements ClosureContext {
|
||||
// it throws.
|
||||
if (inferrer.isNonNullableByDefault) {
|
||||
inferredElementType =
|
||||
NeverType.fromNullability(inferrer.library.nonNullable);
|
||||
NeverType.fromNullability(inferrer.libraryBuilder.nonNullable);
|
||||
} else {
|
||||
inferredElementType = const NullType();
|
||||
}
|
||||
}
|
||||
|
||||
DartType inferredType = inferrer.wrapType(inferredElementType!,
|
||||
inferrer.coreTypes.streamClass, inferrer.library.nonNullable);
|
||||
inferrer.coreTypes.streamClass, inferrer.libraryBuilder.nonNullable);
|
||||
|
||||
if (!inferrer.typeSchemaEnvironment.isSubtypeOf(inferredType,
|
||||
_yieldElementContext, SubtypeCheckMode.withNullabilities)) {
|
||||
@@ -1120,7 +1123,7 @@ class _AsyncStarClosureContext implements ClosureContext {
|
||||
inferredType = inferrer.computeGreatestClosure2(_declaredReturnType);
|
||||
}
|
||||
|
||||
return demoteTypeInLibrary(inferredType, inferrer.library.library);
|
||||
return demoteTypeInLibrary(inferredType, inferrer.libraryBuilder.library);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -101,7 +101,7 @@ enum MethodContravarianceCheckKind {
|
||||
/// This class describes the interface for use by clients of type inference
|
||||
/// (e.g. BodyBuilder). Derived classes should derive from [TypeInferrerImpl].
|
||||
abstract class TypeInferrer {
|
||||
SourceLibraryBuilder get library;
|
||||
SourceLibraryBuilder get libraryBuilder;
|
||||
|
||||
/// Gets the [TypeSchemaEnvironment] being used for type inference.
|
||||
TypeSchemaEnvironment get typeSchemaEnvironment;
|
||||
@@ -188,12 +188,12 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
@override
|
||||
late final FlowAnalysis<TreeNode, Statement, Expression, VariableDeclaration,
|
||||
DartType> flowAnalysis =
|
||||
library.isNonNullableByDefault
|
||||
libraryBuilder.isNonNullableByDefault
|
||||
? new FlowAnalysis(
|
||||
new TypeOperationsCfe(engine.typeSchemaEnvironment),
|
||||
assignedVariables,
|
||||
respectImplicitlyTypedVarInitializers:
|
||||
library.enableConstructorTearOffsInLibrary)
|
||||
libraryBuilder.enableConstructorTearOffsInLibrary)
|
||||
: new FlowAnalysis.legacy(
|
||||
new TypeOperationsCfe(engine.typeSchemaEnvironment),
|
||||
assignedVariables);
|
||||
@@ -221,7 +221,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
final InterfaceType? thisType;
|
||||
|
||||
@override
|
||||
final SourceLibraryBuilder library;
|
||||
final SourceLibraryBuilder libraryBuilder;
|
||||
|
||||
@override
|
||||
InferenceHelper? helper;
|
||||
@@ -230,12 +230,18 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
/// inside a closure.
|
||||
ClosureContext? closureContext;
|
||||
|
||||
TypeInferrerImpl(this.engine, this.uriForInstrumentation, bool topLevel,
|
||||
this.thisType, this.library, this.assignedVariables, this.dataForTesting)
|
||||
TypeInferrerImpl(
|
||||
this.engine,
|
||||
this.uriForInstrumentation,
|
||||
bool topLevel,
|
||||
this.thisType,
|
||||
this.libraryBuilder,
|
||||
this.assignedVariables,
|
||||
this.dataForTesting)
|
||||
// ignore: unnecessary_null_comparison
|
||||
: assert(library != null),
|
||||
: assert(libraryBuilder != null),
|
||||
unknownFunction = new FunctionType(
|
||||
const [], const DynamicType(), library.nonNullable),
|
||||
const [], const DynamicType(), libraryBuilder.nonNullable),
|
||||
classHierarchy = engine.classHierarchy,
|
||||
instrumentation = topLevel ? null : engine.instrumentation,
|
||||
typeSchemaEnvironment = engine.typeSchemaEnvironment,
|
||||
@@ -243,9 +249,9 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
|
||||
CoreTypes get coreTypes => engine.coreTypes;
|
||||
|
||||
bool get isNonNullableByDefault => library.isNonNullableByDefault;
|
||||
bool get isNonNullableByDefault => libraryBuilder.isNonNullableByDefault;
|
||||
|
||||
NnbdMode get nnbdMode => library.loader.nnbdMode;
|
||||
NnbdMode get nnbdMode => libraryBuilder.loader.nnbdMode;
|
||||
|
||||
DartType get bottomType =>
|
||||
isNonNullableByDefault ? const NeverType.nonNullable() : const NullType();
|
||||
@@ -267,12 +273,12 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
if (type is NullType || type is NeverType) {
|
||||
return const NullType();
|
||||
}
|
||||
return type.withDeclaredNullability(library.nullable);
|
||||
return type.withDeclaredNullability(libraryBuilder.nullable);
|
||||
}
|
||||
|
||||
Expression createReachabilityError(
|
||||
int fileOffset, Message errorMessage, Message warningMessage) {
|
||||
if (library.loader.target.context.options.warnOnReachabilityCheck &&
|
||||
if (libraryBuilder.loader.target.context.options.warnOnReachabilityCheck &&
|
||||
// ignore: unnecessary_null_comparison
|
||||
warningMessage != null) {
|
||||
helper?.addProblem(warningMessage, fileOffset, noLength);
|
||||
@@ -395,7 +401,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// instead. However, `inferrer.helper` may be null.
|
||||
name += ".${target.name.text}";
|
||||
}
|
||||
constructor.library.addProblem(
|
||||
constructor.libraryBuilder.addProblem(
|
||||
templateCantInferTypeDueToCircularity.withArguments(name),
|
||||
target.fileOffset,
|
||||
name.length,
|
||||
@@ -807,7 +813,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
}
|
||||
}
|
||||
ImplicitInstantiation? implicitInstantiation;
|
||||
if (library.enableConstructorTearOffsInLibrary) {
|
||||
if (libraryBuilder.enableConstructorTearOffsInLibrary) {
|
||||
implicitInstantiation =
|
||||
computeImplicitInstantiation(expressionType, contextType);
|
||||
if (implicitInstantiation != null) {
|
||||
@@ -897,7 +903,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
List<DartType> inferredTypes =
|
||||
new List<DartType>.filled(typeParameters.length, const UnknownType());
|
||||
typeSchemaEnvironment.inferGenericFunctionOrType(null, typeParameters,
|
||||
[onType], [receiverType], null, inferredTypes, library.library);
|
||||
[onType], [receiverType], null, inferredTypes, libraryBuilder.library);
|
||||
return inferredTypes;
|
||||
}
|
||||
|
||||
@@ -968,7 +974,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
break;
|
||||
default:
|
||||
unhandled("${descriptor.kind}", "_findDirectExtensionMember",
|
||||
fileOffset, library.fileUri);
|
||||
fileOffset, libraryBuilder.fileUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1025,7 +1031,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
|
||||
ExtensionAccessCandidate? bestSoFar;
|
||||
List<ExtensionAccessCandidate> noneMoreSpecific = [];
|
||||
library.forEachExtensionInScope((ExtensionBuilder extensionBuilder) {
|
||||
libraryBuilder.forEachExtensionInScope((ExtensionBuilder extensionBuilder) {
|
||||
MemberBuilder? thisBuilder = extensionBuilder
|
||||
.lookupLocalMemberByName(name, setter: setter) as MemberBuilder?;
|
||||
MemberBuilder? otherBuilder = extensionBuilder.lookupLocalMemberByName(
|
||||
@@ -1061,7 +1067,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
onType = inferredSubstitution
|
||||
.substituteType(extensionBuilder.extension.onType);
|
||||
List<DartType> instantiateToBoundTypeArguments = calculateBounds(
|
||||
typeParameters, coreTypes.objectClass, library.library);
|
||||
typeParameters, coreTypes.objectClass, libraryBuilder.library);
|
||||
Substitution instantiateToBoundsSubstitution = Substitution.fromPairs(
|
||||
typeParameters, instantiateToBoundTypeArguments);
|
||||
onTypeInstantiateToBounds = instantiateToBoundsSubstitution
|
||||
@@ -1095,7 +1101,8 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
onType,
|
||||
onTypeInstantiateToBounds,
|
||||
target,
|
||||
isPlatform: extensionBuilder.library.importUri.isScheme('dart'));
|
||||
isPlatform:
|
||||
extensionBuilder.libraryBuilder.importUri.isScheme('dart'));
|
||||
if (noneMoreSpecific.isNotEmpty) {
|
||||
bool isMostSpecific = true;
|
||||
for (ExtensionAccessCandidate other in noneMoreSpecific) {
|
||||
@@ -1211,7 +1218,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
receiverBound,
|
||||
isNonNullableByDefault),
|
||||
fileOffset,
|
||||
library.fileUri);
|
||||
libraryBuilder.fileUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1231,7 +1238,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
target = isReceiverTypePotentiallyNullable
|
||||
? const ObjectAccessTarget.nullableCallFunction()
|
||||
: const ObjectAccessTarget.callFunction();
|
||||
} else if (library.enableExtensionTypesInLibrary &&
|
||||
} else if (libraryBuilder.enableExtensionTypesInLibrary &&
|
||||
receiverBound is ExtensionType) {
|
||||
target = _findDirectExtensionTypeMember(receiverBound, name, fileOffset,
|
||||
isSetter: isSetter,
|
||||
@@ -1379,7 +1386,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
case ProcedureKind.Method:
|
||||
case ProcedureKind.Operator:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
List<TypeParameter> extensionTypeParameters = functionType
|
||||
.typeParameters
|
||||
.take(target.inferredExtensionTypeArguments.length)
|
||||
@@ -1389,7 +1396,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
DartType resultType = substitution.substituteType(new FunctionType(
|
||||
functionType.positionalParameters.skip(1).toList(),
|
||||
functionType.returnType,
|
||||
library.nonNullable,
|
||||
libraryBuilder.nonNullable,
|
||||
namedParameters: functionType.namedParameters,
|
||||
typeParameters: functionType.typeParameters
|
||||
.skip(target.inferredExtensionTypeArguments.length)
|
||||
@@ -1402,7 +1409,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
return resultType;
|
||||
case ProcedureKind.Getter:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
List<TypeParameter> extensionTypeParameters = functionType
|
||||
.typeParameters
|
||||
.take(target.inferredExtensionTypeArguments.length)
|
||||
@@ -1500,7 +1507,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
case ProcedureKind.Method:
|
||||
case ProcedureKind.Operator:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
if (!isNonNullableByDefault) {
|
||||
functionType = legacyErasure(functionType) as FunctionType;
|
||||
}
|
||||
@@ -1545,7 +1552,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
switch (target.extensionMethodKind) {
|
||||
case ProcedureKind.Operator:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
DartType returnType = functionType.returnType;
|
||||
if (functionType.typeParameters.isNotEmpty) {
|
||||
Substitution substitution = Substitution.fromPairs(
|
||||
@@ -1588,8 +1595,8 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
break;
|
||||
case ObjectAccessTargetKind.extensionMember:
|
||||
case ObjectAccessTargetKind.nullableExtensionMember:
|
||||
FunctionType functionType =
|
||||
target.member!.function!.computeFunctionType(library.nonNullable);
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
if (functionType.positionalParameters.length > index + 1) {
|
||||
DartType keyType = functionType.positionalParameters[index + 1];
|
||||
if (functionType.typeParameters.isNotEmpty) {
|
||||
@@ -1652,7 +1659,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
switch (target.extensionMethodKind) {
|
||||
case ProcedureKind.Operator:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
if (functionType.positionalParameters.length >= 2) {
|
||||
DartType keyType = functionType.positionalParameters[1];
|
||||
if (functionType.typeParameters.isNotEmpty) {
|
||||
@@ -1716,7 +1723,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
switch (target.extensionMethodKind) {
|
||||
case ProcedureKind.Operator:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
if (functionType.positionalParameters.length >= 3) {
|
||||
DartType indexType = functionType.positionalParameters[2];
|
||||
if (functionType.typeParameters.isNotEmpty) {
|
||||
@@ -1849,7 +1856,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
switch (target.extensionMethodKind) {
|
||||
case ProcedureKind.Setter:
|
||||
FunctionType functionType = target.member!.function!
|
||||
.computeFunctionType(library.nonNullable);
|
||||
.computeFunctionType(libraryBuilder.nonNullable);
|
||||
List<TypeParameter> extensionTypeParameters = functionType
|
||||
.typeParameters
|
||||
.take(target.inferredExtensionTypeArguments.length)
|
||||
@@ -1897,9 +1904,10 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
return const DynamicType();
|
||||
}
|
||||
if (forSyntheticVariable) {
|
||||
return normalizeNullabilityInLibrary(initializerType, library.library);
|
||||
return normalizeNullabilityInLibrary(
|
||||
initializerType, libraryBuilder.library);
|
||||
} else {
|
||||
return demoteTypeInLibrary(initializerType, library.library);
|
||||
return demoteTypeInLibrary(initializerType, libraryBuilder.library);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2164,7 +2172,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
FunctionType extensionFunctionType = new FunctionType(
|
||||
[calleeType.positionalParameters.first],
|
||||
const DynamicType(),
|
||||
library.nonNullable,
|
||||
libraryBuilder.nonNullable,
|
||||
requiredParameterCount: 1,
|
||||
typeParameters: calleeType.typeParameters
|
||||
.take(extensionTypeParameterCount)
|
||||
@@ -2191,7 +2199,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
FunctionType targetFunctionType = new FunctionType(
|
||||
calleeType.positionalParameters.skip(1).toList(),
|
||||
calleeType.returnType,
|
||||
library.nonNullable,
|
||||
libraryBuilder.nonNullable,
|
||||
requiredParameterCount: calleeType.requiredParameterCount - 1,
|
||||
namedParameters: calleeType.namedParameters,
|
||||
typeParameters: targetTypeParameters);
|
||||
@@ -2275,7 +2283,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
}
|
||||
|
||||
List<VariableDeclaration>? localHoistedExpressions;
|
||||
if (library.enableNamedArgumentsAnywhereInLibrary &&
|
||||
if (libraryBuilder.enableNamedArgumentsAnywhereInLibrary &&
|
||||
arguments.argumentsOriginalOrder != null &&
|
||||
hoistedExpressions == null &&
|
||||
!isTopLevel) {
|
||||
@@ -2303,7 +2311,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
null,
|
||||
typeContext,
|
||||
inferredTypes,
|
||||
library.library);
|
||||
libraryBuilder.library);
|
||||
substitution =
|
||||
Substitution.fromPairs(calleeTypeParameters, inferredTypes);
|
||||
} else if (explicitTypeArguments != null &&
|
||||
@@ -2321,7 +2329,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// TODO(paulberry): if we are doing top level inference and type arguments
|
||||
// were omitted, report an error.
|
||||
List<Object?> argumentsEvaluationOrder;
|
||||
if (library.enableNamedArgumentsAnywhereInLibrary &&
|
||||
if (libraryBuilder.enableNamedArgumentsAnywhereInLibrary &&
|
||||
arguments.argumentsOriginalOrder != null) {
|
||||
if (staticTarget?.isExtensionMember ?? false) {
|
||||
// Add the receiver.
|
||||
@@ -2352,7 +2360,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// vector, and none of the arguments is hoisted. That way the legacy
|
||||
// behavior is preserved.
|
||||
int hoistingEndIndex;
|
||||
if (library.enableNamedArgumentsAnywhereInLibrary) {
|
||||
if (libraryBuilder.enableNamedArgumentsAnywhereInLibrary) {
|
||||
hoistingEndIndex = argumentsEvaluationOrder.length - 1;
|
||||
for (int i = argumentsEvaluationOrder.length - 2;
|
||||
i >= 0 && hoistingEndIndex == i + 1;
|
||||
@@ -2490,7 +2498,10 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
calleeType = replaceReturnType(
|
||||
calleeType,
|
||||
typeSchemaEnvironment.getTypeOfSpecialCasedTernaryOperator(
|
||||
receiverType!, actualTypes![0], actualTypes[1], library.library));
|
||||
receiverType!,
|
||||
actualTypes![0],
|
||||
actualTypes[1],
|
||||
libraryBuilder.library));
|
||||
}
|
||||
|
||||
// Check for and remove duplicated named arguments.
|
||||
@@ -2546,7 +2557,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
actualTypes,
|
||||
typeContext,
|
||||
inferredTypes!,
|
||||
library.library);
|
||||
libraryBuilder.library);
|
||||
assert(inferredTypes.every((type) => isKnown(type)),
|
||||
"Unknown type(s) in inferred types: $inferredTypes.");
|
||||
assert(inferredTypes.every((type) => !hasPromotedTypeVariable(type)),
|
||||
@@ -2748,14 +2759,14 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
isNonNullableByDefault
|
||||
? SubtypeCheckMode.withNullabilities
|
||||
: SubtypeCheckMode.ignoringNullabilities)) {
|
||||
inferredType = coreTypes.objectRawType(library.nullable);
|
||||
inferredType = coreTypes.objectRawType(libraryBuilder.nullable);
|
||||
}
|
||||
} else {
|
||||
inferredType = const DynamicType();
|
||||
}
|
||||
instrumentation?.record(uriForInstrumentation, formal.fileOffset,
|
||||
'type', new InstrumentationValueForType(inferredType));
|
||||
formal.type = demoteTypeInLibrary(inferredType, library.library);
|
||||
formal.type = demoteTypeInLibrary(inferredType, libraryBuilder.library);
|
||||
if (dataForTesting != null) {
|
||||
dataForTesting!.typeInferenceResult.inferredVariableTypes[formal] =
|
||||
formal.type;
|
||||
@@ -2772,12 +2783,12 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
if ((isOptionalPositional || isOptionalNamed) &&
|
||||
formal.type.isPotentiallyNonNullable &&
|
||||
!formal.hasDeclaredInitializer) {
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateOptionalNonNullableWithoutInitializerError.withArguments(
|
||||
formal.name!, formal.type, isNonNullableByDefault),
|
||||
formal.fileOffset,
|
||||
formal.name!.length,
|
||||
library.importUri);
|
||||
libraryBuilder.importUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2787,12 +2798,12 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
VariableDeclarationImpl formal = parameter as VariableDeclarationImpl;
|
||||
// Required named parameters shouldn't have initializers.
|
||||
if (formal.isRequired && formal.hasDeclaredInitializer) {
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateRequiredNamedParameterHasDefaultValueError
|
||||
.withArguments(formal.name!),
|
||||
formal.fileOffset,
|
||||
formal.name!.length,
|
||||
library.importUri);
|
||||
libraryBuilder.importUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2842,7 +2853,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
function.body = bodyResult.statement..parent = function;
|
||||
}
|
||||
this.closureContext = oldClosureContext;
|
||||
return function.computeFunctionType(library.nonNullable);
|
||||
return function.computeFunctionType(libraryBuilder.nonNullable);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -3037,7 +3048,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
isImplicitCall: isImplicitCall,
|
||||
isExtensionMemberInvocation: true);
|
||||
if (!isTopLevel) {
|
||||
library.checkBoundsInStaticInvocation(
|
||||
libraryBuilder.checkBoundsInStaticInvocation(
|
||||
staticInvocation,
|
||||
typeSchemaEnvironment,
|
||||
helper!.uri,
|
||||
@@ -3185,7 +3196,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
return new FunctionType(
|
||||
new List<DartType>.filled(arguments.positional.length, type),
|
||||
type,
|
||||
library.nonNullable,
|
||||
libraryBuilder.nonNullable,
|
||||
namedParameters: new List<NamedType>.generate(arguments.named.length,
|
||||
(int index) => new NamedType(arguments.named[index].name, type)));
|
||||
}
|
||||
@@ -3499,7 +3510,8 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
context: context);
|
||||
}
|
||||
|
||||
if (!library.loader.target.backendTarget.supportsExplicitGetterCalls) {
|
||||
if (!libraryBuilder
|
||||
.loader.target.backendTarget.supportsExplicitGetterCalls) {
|
||||
// TODO(johnniwinther): Remove this when dart2js/ddc supports explicit
|
||||
// getter calls.
|
||||
Expression nullAwareAction = invocationResult.nullAwareAction;
|
||||
@@ -3696,7 +3708,8 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
context: context);
|
||||
}
|
||||
|
||||
if (!library.loader.target.backendTarget.supportsExplicitGetterCalls) {
|
||||
if (!libraryBuilder
|
||||
.loader.target.backendTarget.supportsExplicitGetterCalls) {
|
||||
// TODO(johnniwinther): Remove this when dart2js/ddc supports explicit
|
||||
// getter calls.
|
||||
Expression nullAwareAction = invocationResult.nullAwareAction;
|
||||
@@ -3890,7 +3903,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
: null;
|
||||
actualMethodName = methodName;
|
||||
}
|
||||
library.checkBoundsInMethodInvocation(
|
||||
libraryBuilder.checkBoundsInMethodInvocation(
|
||||
actualReceiverType,
|
||||
typeSchemaEnvironment,
|
||||
classHierarchy,
|
||||
@@ -3911,8 +3924,14 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// If [arguments] were inferred, check them.
|
||||
if (!isTopLevel) {
|
||||
// We only perform checks in full inference.
|
||||
library.checkBoundsInInstantiation(typeSchemaEnvironment, classHierarchy,
|
||||
this, functionType, arguments, helper!.uri, fileOffset,
|
||||
libraryBuilder.checkBoundsInInstantiation(
|
||||
typeSchemaEnvironment,
|
||||
classHierarchy,
|
||||
this,
|
||||
functionType,
|
||||
arguments,
|
||||
helper!.uri,
|
||||
fileOffset,
|
||||
inferred: inferred);
|
||||
}
|
||||
}
|
||||
@@ -3922,7 +3941,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// If [arguments] were inferred, check them.
|
||||
if (!isTopLevel) {
|
||||
// We only perform checks in full inference.
|
||||
library.checkBoundsInFunctionInvocation(
|
||||
libraryBuilder.checkBoundsInFunctionInvocation(
|
||||
typeSchemaEnvironment,
|
||||
classHierarchy,
|
||||
this,
|
||||
@@ -3985,7 +4004,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// operator == always allows nullable arguments.
|
||||
functionType = new FunctionType([
|
||||
functionType.positionalParameters.single
|
||||
.withDeclaredNullability(library.nullable)
|
||||
.withDeclaredNullability(libraryBuilder.nullable)
|
||||
], functionType.returnType, functionType.declaredNullability);
|
||||
}
|
||||
InvocationInferenceResult result = inferInvocation(
|
||||
@@ -3995,7 +4014,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
isImplicitExtensionMember: false);
|
||||
DartType inferredType = result.inferredType;
|
||||
if (methodName.text == '==') {
|
||||
inferredType = coreTypes.boolRawType(library.nonNullable);
|
||||
inferredType = coreTypes.boolRawType(libraryBuilder.nonNullable);
|
||||
}
|
||||
_checkBoundsInMethodInvocation(
|
||||
target, receiverType, calleeType, methodName, arguments, fileOffset);
|
||||
@@ -4076,8 +4095,14 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
List<DartType> inferredTypes = new List<DartType>.filled(
|
||||
typeParameters.length, const UnknownType());
|
||||
FunctionType instantiatedType = functionType.withoutTypeParameters;
|
||||
typeSchemaEnvironment.inferGenericFunctionOrType(instantiatedType,
|
||||
typeParameters, [], [], context, inferredTypes, library.library);
|
||||
typeSchemaEnvironment.inferGenericFunctionOrType(
|
||||
instantiatedType,
|
||||
typeParameters,
|
||||
[],
|
||||
[],
|
||||
context,
|
||||
inferredTypes,
|
||||
libraryBuilder.library);
|
||||
Substitution substitution =
|
||||
Substitution.fromPairs(typeParameters, inferredTypes);
|
||||
tearoffType = substitution.substituteType(instantiatedType);
|
||||
@@ -4241,9 +4266,9 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
// return it unmodified?
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (type == null) {
|
||||
return coreTypes.futureRawType(library.nullable);
|
||||
return coreTypes.futureRawType(libraryBuilder.nullable);
|
||||
}
|
||||
return new FutureOrType(type, library.nonNullable);
|
||||
return new FutureOrType(type, libraryBuilder.nonNullable);
|
||||
}
|
||||
|
||||
DartType wrapFutureType(DartType type, Nullability nullability) {
|
||||
@@ -4280,7 +4305,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
classMember = null;
|
||||
} else if (classMember.isDuplicate) {
|
||||
if (!isTopLevel) {
|
||||
library.addProblem(
|
||||
libraryBuilder.addProblem(
|
||||
templateDuplicatedDeclarationUse.withArguments(name.text),
|
||||
charOffset,
|
||||
name.text.length,
|
||||
@@ -4290,7 +4315,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
}
|
||||
}
|
||||
Member? member = classMember?.getMember(engine.membersBuilder);
|
||||
if (member == null && library.isPatch) {
|
||||
if (member == null && libraryBuilder.isPatch) {
|
||||
// TODO(johnniwinther): Injected members are currently not included
|
||||
// in the class hierarchy builder.
|
||||
member ??=
|
||||
@@ -4698,7 +4723,7 @@ class TypeInferrerImplBenchmarked implements TypeInferrer {
|
||||
get flowAnalysis => impl.flowAnalysis;
|
||||
|
||||
@override
|
||||
SourceLibraryBuilder get library => impl.library;
|
||||
SourceLibraryBuilder get libraryBuilder => impl.libraryBuilder;
|
||||
|
||||
@override
|
||||
TypeSchemaEnvironment get typeSchemaEnvironment => impl.typeSchemaEnvironment;
|
||||
|
||||
@@ -212,7 +212,7 @@ class InheritanceDataExtractor extends CfeDataExtractor<String> {
|
||||
addSupertype(new Supertype(
|
||||
classHierarchyNode.classBuilder.cls,
|
||||
getAsTypeArguments(classHierarchyNode.classBuilder.cls.typeParameters,
|
||||
classHierarchyNode.classBuilder.library.library)));
|
||||
classHierarchyNode.classBuilder.libraryBuilder.library)));
|
||||
classHierarchyNode.superclasses.forEach(addSupertype);
|
||||
classHierarchyNode.interfaces.forEach(addSupertype);
|
||||
List<String> sorted = supertypes.toList()..sort();
|
||||
|
||||
@@ -372,7 +372,8 @@ abstract class Target {
|
||||
(importer.isScheme("package") &&
|
||||
importer.path.startsWith("dart_internal/"));
|
||||
|
||||
/// Whether the `native` language extension is supported within [library].
|
||||
/// Whether the `native` language extension is supported within the library
|
||||
/// with the given import [uri].
|
||||
///
|
||||
/// The `native` language extension is not part of the language specification,
|
||||
/// it means something else to each target, and it is enabled under different
|
||||
|
||||
Reference in New Issue
Block a user