Skip to content

Commit

Permalink
Version 3.7.0-175.0.dev
Browse files Browse the repository at this point in the history
Merge c6362da into dev
  • Loading branch information
Dart CI committed Nov 21, 2024
2 parents 6ea9f45 + c6362da commit 3855907
Show file tree
Hide file tree
Showing 20 changed files with 419 additions and 126 deletions.
61 changes: 27 additions & 34 deletions pkg/front_end/lib/src/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ class BodyBuilder extends StackListenerImpl
for (Statement statement in declaration.users) {
statement.parent!.replaceChild(
statement,
wrapInProblemStatement(statement,
cfe.templateLabelNotFound.withArguments(name)));
wrapInProblemStatement(
statement, cfe.templateLabelNotFound.withArguments(name)));
}
} else {
outerSwitchScope.forwardDeclareLabel(name, declaration);
Expand Down Expand Up @@ -2790,10 +2790,8 @@ class BodyBuilder extends StackListenerImpl
Name name = new Name(operator);
if (!isBinaryOperator(operator) && !isMinusOperator(operator)) {
if (isUserDefinableOperator(operator)) {
push(buildProblem(
cfe.templateNotBinaryOperator.withArguments(token),
token.charOffset,
token.length));
push(buildProblem(cfe.templateNotBinaryOperator.withArguments(token),
token.charOffset, token.length));
} else {
push(buildProblem(cfe.templateInvalidOperator.withArguments(token),
token.charOffset, token.length));
Expand Down Expand Up @@ -3129,8 +3127,8 @@ class BodyBuilder extends StackListenerImpl
constantContext != ConstantContext.none &&
!context.allowedInConstantExpression) {
// Coverage-ignore-block(suite): Not run.
addProblem(cfe.messageNotAConstantExpression, token.charOffset,
token.length);
addProblem(
cfe.messageNotAConstantExpression, token.charOffset, token.length);
}
if (token.isSynthetic) {
push(new ParserRecovery(offsetForToken(token)));
Expand Down Expand Up @@ -3398,8 +3396,8 @@ class BodyBuilder extends StackListenerImpl
if (!(readTarget is Field && readTarget.isConst ||
// Static tear-offs are also compile time constants.
readTarget is Procedure)) {
addProblem(cfe.messageNotAConstantExpression, nameOffset,
nameToken.length);
addProblem(
cfe.messageNotAConstantExpression, nameOffset, nameToken.length);
}
}
return generator;
Expand Down Expand Up @@ -4713,8 +4711,8 @@ class BodyBuilder extends StackListenerImpl
]));

if (constantContext == ConstantContext.required && constKeyword == null) {
addProblem(cfe.messageMissingExplicitConst, offsetForToken(leftBrace),
noLength);
addProblem(
cfe.messageMissingExplicitConst, offsetForToken(leftBrace), noLength);
}

List<dynamic> setOrMapEntries =
Expand Down Expand Up @@ -6405,16 +6403,16 @@ class BodyBuilder extends StackListenerImpl
ConstantContext savedConstantContext = pop() as ConstantContext;

if (arguments is! Arguments) {
push(new ParserErrorGenerator(
this, nameToken, cfe.messageSyntheticToken));
push(
new ParserErrorGenerator(this, nameToken, cfe.messageSyntheticToken));
arguments = forest.createArguments(offset, []);
} else if (type is Generator) {
push(type.invokeConstructor(
typeArguments, name, arguments, nameToken, nameLastToken, constness,
inImplicitCreationContext: inImplicitCreationContext));
} else if (type is ParserRecovery) {
push(new ParserErrorGenerator(
this, nameToken, cfe.messageSyntheticToken));
push(
new ParserErrorGenerator(this, nameToken, cfe.messageSyntheticToken));
} else if (type is InvalidExpression) {
push(type);
} else if (type is Expression) {
Expand Down Expand Up @@ -6511,13 +6509,13 @@ class BodyBuilder extends StackListenerImpl
required UnresolvedKind unresolvedKind}) {
if (arguments == null) {
// Coverage-ignore-block(suite): Not run.
return buildProblem(cfe.messageMissingArgumentList,
nameToken.charOffset, nameToken.length);
return buildProblem(cfe.messageMissingArgumentList, nameToken.charOffset,
nameToken.length);
}
if (name.isNotEmpty && arguments.types.isNotEmpty) {
// TODO(ahe): Point to the type arguments instead.
addProblem(cfe.messageConstructorWithTypeArguments,
nameToken.charOffset, nameToken.length);
addProblem(cfe.messageConstructorWithTypeArguments, nameToken.charOffset,
nameToken.length);
}

String? errorName;
Expand Down Expand Up @@ -7101,8 +7099,8 @@ class BodyBuilder extends StackListenerImpl
// Coverage-ignore(suite): Not run.
offsetForToken(ifToken);
node = new MapLiteralEntry(
buildProblem(cfe.templateExpectedAfterButGot.withArguments(':'),
offset, 1),
buildProblem(
cfe.templateExpectedAfterButGot.withArguments(':'), offset, 1),
new NullLiteral())
..fileOffset = offsetForToken(ifToken);
}
Expand Down Expand Up @@ -7138,8 +7136,8 @@ class BodyBuilder extends StackListenerImpl
// Coverage-ignore(suite): Not run.
offsetForToken(ifToken);
node = new MapLiteralEntry(
buildProblem(cfe.templateExpectedAfterButGot.withArguments(':'),
offset, 1),
buildProblem(
cfe.templateExpectedAfterButGot.withArguments(':'), offset, 1),
new NullLiteral())
..fileOffset = offsetForToken(ifToken);
}
Expand Down Expand Up @@ -9355,10 +9353,8 @@ class BodyBuilder extends StackListenerImpl
typeParameter.declaration is ExtensionTypeDeclaration) {
if (constantContext != ConstantContext.none &&
(!inConstructorInitializer || !allowPotentiallyConstantType)) {
LocatedMessage message =
cfe.messageTypeVariableInConstantContext.withLocation(
builder.fileUri!,
builder.charOffset!,
LocatedMessage message = cfe.messageTypeVariableInConstantContext
.withLocation(builder.fileUri!, builder.charOffset!,
typeParameter.name!.length);
builder.bind(
libraryBuilder,
Expand Down Expand Up @@ -9450,8 +9446,7 @@ class BodyBuilder extends StackListenerImpl
!isConstantExpression &&
!libraryFeatures.constFunctions.isEnabled) {
return buildProblem(
cfe.templateNotConstantExpression
.withArguments('Method invocation'),
cfe.templateNotConstantExpression.withArguments('Method invocation'),
offset,
name.text.length);
}
Expand Down Expand Up @@ -9480,8 +9475,7 @@ class BodyBuilder extends StackListenerImpl
!isConstantExpression &&
!libraryFeatures.constFunctions.isEnabled) {
return buildProblem(
cfe.templateNotConstantExpression
.withArguments('Method invocation'),
cfe.templateNotConstantExpression.withArguments('Method invocation'),
offset,
name.text.length);
}
Expand Down Expand Up @@ -9904,8 +9898,7 @@ class BodyBuilder extends StackListenerImpl
if (colon != null) {
Object? identifier = pop();
if (identifier is ParserRecovery) {
push(
new ParserErrorGenerator(this, colon, cfe.messageSyntheticToken));
push(new ParserErrorGenerator(this, colon, cfe.messageSyntheticToken));
} else {
String? name;
if (identifier is Identifier) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/front_end/lib/src/kernel/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ int compareProcedures(Procedure a, Procedure b) {
return a.fileOffset.compareTo(b.fileOffset);
}

List<Combinator>? toCombinators(
List<CombinatorBuilder>? combinatorBuilders) {
List<Combinator>? toCombinators(List<CombinatorBuilder>? combinatorBuilders) {
if (combinatorBuilders == null) {
// Note: it's safe to return null here as Kernel's LibraryDependency will
// convert null to an empty list.
Expand Down
3 changes: 1 addition & 2 deletions pkg/front_end/lib/src/source/source_compilation_unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,7 @@ class SourceCompilationUnitImpl implements SourceCompilationUnit {
LibraryBuilder imported = import.importedLibraryBuilder!.origin;
Library targetLibrary = imported.library;
libraryDependency = new LibraryDependency.import(targetLibrary,
name: import.prefix,
combinators: toCombinators(import.combinators))
name: import.prefix, combinators: toCombinators(import.combinators))
..fileOffset = import.importOffset;
}
library.addDependency(libraryDependency);
Expand Down
9 changes: 8 additions & 1 deletion pkg/front_end/lib/src/source/source_enum_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ class SourceEnumBuilder extends SourceClassBuilder {
super.buildScopes(coreLibrary);
_createSynthesizedMembers(coreLibrary);

// Include duplicates to install the formals on all constructors to avoid a
// crash later.
Iterator<MemberBuilder> iterator =
nameSpace.filteredConstructorNameIterator(
includeDuplicates: false, includeAugmentations: true);
includeDuplicates: true, includeAugmentations: true);
while (iterator.moveNext()) {
MemberBuilder member = iterator.current;
if (member is DeclaredSourceConstructorBuilder) {
Expand Down Expand Up @@ -612,6 +614,11 @@ class SourceEnumBuilder extends SourceClassBuilder {
constructorName = constructorName == "new" ? "" : constructorName;
MemberBuilder? constructorBuilder =
nameSpace.lookupConstructor(constructorName);
// TODO(CFE Team): Should there be a conversion to an invalid expression
// instead? That's what happens on classes.
while (constructorBuilder?.next != null) {
constructorBuilder = constructorBuilder?.next as MemberBuilder;
}

ArgumentsImpl arguments;
List<Expression> enumSyntheticArguments = <Expression>[
Expand Down
10 changes: 2 additions & 8 deletions pkg/front_end/lib/src/type_inference/type_inference_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -974,21 +974,15 @@ class OperationsCfe
DartType greatestClosureOfTypeInternal(DartType type,
List<SharedTypeParameterStructure<DartType>> typeParametersToEliminate) {
return new NullabilityAwareFreeTypeParameterEliminator(
bottomType: const NeverType.nonNullable(),
topType: typeEnvironment.coreTypes.objectNullableRawType,
topFunctionType: typeEnvironment.coreTypes
.functionRawType(Nullability.nonNullable))
coreTypes: typeEnvironment.coreTypes)
.eliminateToGreatest(type);
}

@override
DartType leastClosureOfTypeInternal(DartType type,
List<SharedTypeParameterStructure<DartType>> typeParametersToEliminate) {
return new NullabilityAwareFreeTypeParameterEliminator(
bottomType: const NeverType.nonNullable(),
topType: typeEnvironment.coreTypes.objectNullableRawType,
topFunctionType: typeEnvironment.coreTypes
.functionRawType(Nullability.nonNullable))
coreTypes: typeEnvironment.coreTypes)
.eliminateToLeast(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
TypeSchemaEnvironment(CoreTypes coreTypes, this.hierarchy)
: super(coreTypes, hierarchy);

// Coverage-ignore(suite): Not run.
InterfaceType functionRawType(Nullability nullability) {
return coreTypes.functionRawType(nullability);
}
Expand Down Expand Up @@ -370,9 +371,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
if (!isEmptyContext(returnContextType)) {
if (isConst) {
returnContextType = new NullabilityAwareFreeTypeParameterEliminator(
bottomType: const NeverType.nonNullable(),
topType: objectNullableRawType,
topFunctionType: functionRawType(Nullability.nonNullable))
coreTypes: coreTypes)
.eliminateToLeast(returnContextType!);
}
gatherer.tryConstrainUpper(declaredReturnType!, returnContextType!,
Expand Down
16 changes: 8 additions & 8 deletions pkg/front_end/test/coverage_suite_expected.dart
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/kernel/body_builder.dart": (
hitCount: 7173,
hitCount: 7185,
missCount: 0,
),
// 100.0%.
Expand Down Expand Up @@ -765,7 +765,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/kernel/member_covariance.dart": (
hitCount: 257,
hitCount: 258,
missCount: 0,
),
// 100.0%.
Expand Down Expand Up @@ -926,12 +926,12 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_field_builder.dart": (
hitCount: 1246,
hitCount: 1250,
missCount: 0,
),
// 100.0%.
"package:front_end/src/source/source_function_builder.dart": (
hitCount: 316,
hitCount: 345,
missCount: 0,
),
// 100.0%.
Expand Down Expand Up @@ -1006,7 +1006,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/type_inference/inference_visitor_base.dart": (
hitCount: 2460,
hitCount: 2458,
missCount: 0,
),
// 100.0%.
Expand Down Expand Up @@ -1046,7 +1046,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/type_inference/type_inference_engine.dart": (
hitCount: 547,
hitCount: 530,
missCount: 0,
),
// 100.0%.
Expand All @@ -1061,12 +1061,12 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/type_inference/type_schema_elimination.dart": (
hitCount: 32,
hitCount: 29,
missCount: 0,
),
// 100.0%.
"package:front_end/src/type_inference/type_schema_environment.dart": (
hitCount: 267,
hitCount: 261,
missCount: 0,
),
// 100.0%.
Expand Down
10 changes: 10 additions & 0 deletions pkg/front_end/testcases/regress/duplicate_enum_constructor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

enum Foo {
a, b;

const Foo();
const Foo();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/duplicate_enum_constructor.dart:9:9: Error: 'Foo' is already declared in this scope.
// const Foo();
// ^^^
// pkg/front_end/testcases/regress/duplicate_enum_constructor.dart:8:9: Context: Previous declaration of 'Foo'.
// const Foo();
// ^^^
//
import self as self;
import "dart:core" as core;

class Foo extends core::_Enum /*isEnum*/ {
static const field core::List<self::Foo> values = #C7;
enum-element static const field self::Foo a = #C3;
enum-element static const field self::Foo b = #C6;
const constructor •(core::int #index, core::String #name) → self::Foo
: super core::_Enum::•(#index, #name)
;
method _enumToString() → core::String
return "Foo.${this.{core::_Enum::_name}{core::String}}";
}

constants {
#C1 = 0
#C2 = "a"
#C3 = self::Foo {index:#C1, _name:#C2}
#C4 = 1
#C5 = "b"
#C6 = self::Foo {index:#C4, _name:#C5}
#C7 = <self::Foo>[#C3, #C6]
}


Constructor coverage from constants:
org-dartlang-testcase:///duplicate_enum_constructor.dart:
- Foo. (from org-dartlang-testcase:///duplicate_enum_constructor.dart:8:9)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
Loading

0 comments on commit 3855907

Please sign in to comment.