Skip to content

Commit

Permalink
Version 3.2.0-34.0.dev
Browse files Browse the repository at this point in the history
Merge 4243547 into dev
  • Loading branch information
Dart CI committed Aug 3, 2023
2 parents dcd09f5 + 4243547 commit e3d2b4a
Show file tree
Hide file tree
Showing 105 changed files with 2,825 additions and 236 deletions.
50 changes: 50 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12319,6 +12319,56 @@ const MessageCode messageSuperAsIdentifier = const MessageCode(
analyzerCodes: <String>["SUPER_AS_EXPRESSION"],
problemMessage: r"""Expected identifier, but got 'super'.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateSuperExtensionTypeIsIllegal =
const Template<Message Function(String name)>(
problemMessageTemplate:
r"""The type '#name' can't be implemented by an extension type.""",
withArguments: _withArgumentsSuperExtensionTypeIsIllegal);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)> codeSuperExtensionTypeIsIllegal =
const Code<Message Function(String name)>(
"SuperExtensionTypeIsIllegal",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSuperExtensionTypeIsIllegal(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeSuperExtensionTypeIsIllegal,
problemMessage:
"""The type '${name}' can't be implemented by an extension type.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String
name)> templateSuperExtensionTypeIsTypeVariable = const Template<
Message Function(String name)>(
problemMessageTemplate:
r"""The type variable '#name' can't be implemented by an extension type.""",
withArguments: _withArgumentsSuperExtensionTypeIsTypeVariable);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)> codeSuperExtensionTypeIsTypeVariable =
const Code<Message Function(String name)>(
"SuperExtensionTypeIsTypeVariable",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSuperExtensionTypeIsTypeVariable(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeSuperExtensionTypeIsTypeVariable,
problemMessage:
"""The type variable '${name}' can't be implemented by an extension type.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeSuperInitializerNotLast = messageSuperInitializerNotLast;

Expand Down
32 changes: 31 additions & 1 deletion pkg/front_end/lib/src/fasta/builder/library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ library fasta.library_builder;

import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity;

import 'package:kernel/ast.dart' show Library, Nullability;
import 'package:kernel/ast.dart' show Class, Library, Nullability;

import '../combinator.dart' show CombinatorBuilder;

Expand Down Expand Up @@ -177,6 +177,36 @@ abstract class LibraryBuilder implements ModifierBuilder {
NullabilityBuilder get nonNullableBuilder;

NullabilityBuilder nullableBuilderIfTrue(bool isNullable);

/// Returns `true` if [cls] is the 'Function' class defined in [coreLibrary].
static bool isFunction(Class cls, LibraryBuilder coreLibrary) {
return cls.name == 'Function' && _isCoreClass(cls, coreLibrary);
}

/// Returns `true` if [cls] is the 'Record' class defined in [coreLibrary].
static bool isRecord(Class cls, LibraryBuilder coreLibrary) {
return cls.name == 'Record' && _isCoreClass(cls, coreLibrary);
}

/// Returns `true` if [cls] is the 'Object' class defined in [coreLibrary].
static bool isObject(Class cls, LibraryBuilder coreLibrary) {
return cls.name == 'Object' && _isCoreClass(cls, coreLibrary);
}

static bool _isCoreClass(Class cls, LibraryBuilder coreLibrary) {
// We use `superclass.parent` here instead of
// `superclass.enclosingLibrary` to handle platform compilation. If
// we are currently compiling the platform, the enclosing library of
// the core class has not yet been set, so the accessing
// `enclosingLibrary` would result in a cast error. We assume that the
// SDK does not contain this error, which we otherwise not find. If we
// are _not_ compiling the platform, the `superclass.parent` has been
// set, if it is a class from `dart:core`.
if (cls.parent == coreLibrary.library) {
return true;
}
return false;
}
}

abstract class LibraryBuilderImpl extends ModifierBuilderImpl
Expand Down
72 changes: 72 additions & 0 deletions pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5265,6 +5265,78 @@ Message _withArgumentsSuperBoundedHint(
arguments: {'type': _type, 'type2': _type2});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>
templateSuperExtensionTypeIsIllegalAliased = const Template<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>(
problemMessageTemplate:
r"""The type '#name' which is an alias of '#type' can't be implemented by an extension type.""",
withArguments: _withArgumentsSuperExtensionTypeIsIllegalAliased);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>
codeSuperExtensionTypeIsIllegalAliased = const Code<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>(
"SuperExtensionTypeIsIllegalAliased",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSuperExtensionTypeIsIllegalAliased(
String name, DartType _type, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeSuperExtensionTypeIsIllegalAliased,
problemMessage:
"""The type '${name}' which is an alias of '${type}' can't be implemented by an extension type.""" +
labeler.originMessages,
arguments: {'name': name, 'type': _type});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>
templateSuperExtensionTypeIsNullableAliased = const Template<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>(
problemMessageTemplate:
r"""The type '#name' which is an alias of '#type' can't be implemented by an extension type because it is nullable.""",
withArguments: _withArgumentsSuperExtensionTypeIsNullableAliased);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>
codeSuperExtensionTypeIsNullableAliased = const Code<
Message Function(
String name, DartType _type, bool isNonNullableByDefault)>(
"SuperExtensionTypeIsNullableAliased",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSuperExtensionTypeIsNullableAliased(
String name, DartType _type, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeSuperExtensionTypeIsNullableAliased,
problemMessage:
"""The type '${name}' which is an alias of '${type}' can't be implemented by an extension type because it is nullable.""" +
labeler.originMessages,
arguments: {'name': name, 'type': _type});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
Expand Down
27 changes: 26 additions & 1 deletion pkg/front_end/lib/src/fasta/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ class BodyBuilder extends StackListenerImpl
/// This is set to true when we are parsing constructor initializers.
bool inConstructorInitializer = false;

/// This is set to `true` when we are parsing formals.
bool inFormals = false;

/// Set to `true` when we are parsing a field initializer either directly
/// or within an initializer list.
///
Expand Down Expand Up @@ -3272,7 +3275,7 @@ class BodyBuilder extends StackListenerImpl
return new UnresolvedNameGenerator(this, token, n,
unresolvedReadKind: UnresolvedKind.Unknown);
}
if (thisVariable != null) {
if (!inFormals && thisVariable != null) {
// If we are in an extension instance member we interpret this as an
// implicit access on the 'this' parameter.
return PropertyAccessGenerator.make(this, token,
Expand Down Expand Up @@ -5479,13 +5482,34 @@ class BodyBuilder extends StackListenerImpl
@override
void beginFormalParameters(Token token, MemberKind kind) {
super.push(constantContext);
super.push(inFormals);
constantContext = ConstantContext.none;
inFormals = true;
}

@override
void endFormalParameters(
int count, Token beginToken, Token endToken, MemberKind kind) {
debugEvent("FormalParameters");
assert(checkState(beginToken, [
if (count > 0 && peek() is List<FormalParameterBuilder>) ...[
ValueKinds.FormalList,
...repeatedKind(
unionOfKinds([
ValueKinds.FormalParameterBuilder,
ValueKinds.ParserRecovery,
]),
count - 1),
] else
...repeatedKind(
unionOfKinds([
ValueKinds.FormalParameterBuilder,
ValueKinds.ParserRecovery,
]),
count),
/* inFormals */ ValueKinds.Bool,
/* constantContext */ ValueKinds.ConstantContext,
]));
List<FormalParameterBuilder>? optionals;
int optionalsCount = 0;
if (count > 0 && peek() is List<FormalParameterBuilder>) {
Expand All @@ -5502,6 +5526,7 @@ class BodyBuilder extends StackListenerImpl
assert(parameters?.isNotEmpty ?? true);
FormalParameters formals = new FormalParameters(parameters,
offsetForToken(beginToken), lengthOfSpan(beginToken, endToken), uri);
inFormals = pop() as bool;
constantContext = pop() as ConstantContext;
push(formals);
if ((inCatchClause || functionNestingLevel != 0) &&
Expand Down
27 changes: 5 additions & 22 deletions pkg/front_end/lib/src/fasta/source/source_class_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ class SourceClassBuilder extends ClassBuilderImpl
supertypeBuilder = _checkSupertype(supertypeBuilder!);
}
Supertype? supertype = supertypeBuilder?.buildSupertype(libraryBuilder);
if (_isFunction(supertype, coreLibrary)) {
if (supertype != null &&
LibraryBuilder.isFunction(supertype.classNode, coreLibrary)) {
supertype = null;
supertypeBuilder = null;
}
Expand Down Expand Up @@ -273,7 +274,8 @@ class SourceClassBuilder extends ClassBuilderImpl
}
Supertype? mixedInType =
mixedInTypeBuilder?.buildMixedInType(libraryBuilder);
if (_isFunction(mixedInType, coreLibrary)) {
if (mixedInType != null &&
LibraryBuilder.isFunction(mixedInType.classNode, coreLibrary)) {
mixedInType = null;
mixedInTypeBuilder = null;
actualCls.isAnonymousMixin = false;
Expand Down Expand Up @@ -301,7 +303,7 @@ class SourceClassBuilder extends ClassBuilderImpl
Supertype? supertype =
interfaceBuilders![i].buildSupertype(libraryBuilder);
if (supertype != null) {
if (_isFunction(supertype, coreLibrary)) {
if (LibraryBuilder.isFunction(supertype.classNode, coreLibrary)) {
continue;
}
// TODO(ahe): Report an error if supertype is null.
Expand Down Expand Up @@ -350,25 +352,6 @@ class SourceClassBuilder extends ClassBuilderImpl
return cls;
}

bool _isFunction(Supertype? supertype, LibraryBuilder coreLibrary) {
if (supertype != null) {
Class superclass = supertype.classNode;
if (superclass.name == 'Function' &&
// We use `superclass.parent` here instead of
// `superclass.enclosingLibrary` to handle platform compilation. If
// we are currently compiling the platform, the enclosing library of
// `Function` has not yet been set, so the accessing
// `enclosingLibrary` would result in a cast error. We assume that the
// SDK does not contain this error, which we otherwise not find. If we
// are _not_ compiling the platform, the `superclass.parent` has been
// set, if it is `Function` from `dart:core`.
superclass.parent == coreLibrary.library) {
return true;
}
}
return false;
}

BodyBuilderContext get bodyBuilderContext =>
new ClassBodyBuilderContext(this);

Expand Down
Loading

0 comments on commit e3d2b4a

Please sign in to comment.