[cfe][InternalNodes] Add Argument nodes
This adds the sealed class Argument with subclasses PositionalArgument and NamedArgument to the internal AST and uses these through out compilation. This cleans up a lot of the handling of arguments during inference. Change-Id: If604895ee578d45874d4760e5ead2426b19b96ff Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469621 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
committed by
Commit Queue
parent
0a154753c6
commit
77073f7992
@@ -106,7 +106,6 @@ class DillCompilationUnitImpl extends DillCompilationUnit {
|
||||
_dillLibraryBuilder.conditionalImportSupported;
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
Importability get importability => _dillLibraryBuilder.importability;
|
||||
|
||||
@override
|
||||
@@ -396,7 +395,6 @@ class DillLibraryBuilder extends LibraryBuilderImpl {
|
||||
bool get conditionalImportSupported => library.conditionalImportSupported;
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
Importability get importability => library.importability;
|
||||
|
||||
@override
|
||||
|
||||
@@ -813,7 +813,11 @@ class _ExtensionTypeInitializerToStatementConverter
|
||||
thisVariable,
|
||||
new StaticInvocation(
|
||||
node.target,
|
||||
node.arguments.toArguments(node.inferredTypeArguments),
|
||||
node.arguments.toArguments(
|
||||
node.inferredTypeArguments,
|
||||
node.positional,
|
||||
node.named,
|
||||
),
|
||||
)..fileOffset = node.fileOffset,
|
||||
)..fileOffset = node.fileOffset,
|
||||
)..fileOffset = node.fileOffset,
|
||||
|
||||
@@ -360,7 +360,10 @@ class EnumElementDeclaration
|
||||
extensionScope: _fragment.enclosingCompilationUnit.extensionScope,
|
||||
scope: _fragment.enclosingScope,
|
||||
token: token,
|
||||
enumSyntheticArguments: enumSyntheticArguments,
|
||||
enumSyntheticArguments: [
|
||||
new PositionalArgument(enumSyntheticArguments[0]),
|
||||
new PositionalArgument(enumSyntheticArguments[1]),
|
||||
],
|
||||
enumTypeParameterCount: sourceEnumBuilder.typeParametersCount,
|
||||
typeArguments: typeArguments,
|
||||
constructorBuilder: constructorBuilder,
|
||||
|
||||
@@ -914,7 +914,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
]),
|
||||
);
|
||||
debugEvent("Metadata");
|
||||
ArgumentsImpl? arguments = pop() as ArgumentsImpl?;
|
||||
ActualArguments? arguments = pop() as ActualArguments?;
|
||||
pushQualifiedReference(
|
||||
beginToken.next!,
|
||||
periodBeforeName,
|
||||
@@ -1335,14 +1335,14 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
return annotation;
|
||||
}
|
||||
|
||||
ArgumentsImpl parseArguments(Token token) {
|
||||
ActualArguments parseArguments(Token token) {
|
||||
Parser parser = new Parser(
|
||||
this,
|
||||
useImplicitCreationExpression: useImplicitCreationExpressionInCfe,
|
||||
experimentalFeatures: new LibraryExperimentalFeatures(libraryFeatures),
|
||||
);
|
||||
token = parser.parseArgumentsRest(token);
|
||||
ArgumentsImpl arguments = pop() as ArgumentsImpl;
|
||||
ActualArguments arguments = pop() as ActualArguments;
|
||||
checkEmpty(token.charOffset);
|
||||
return arguments;
|
||||
}
|
||||
@@ -1366,104 +1366,71 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
@override
|
||||
void endArguments(int count, Token beginToken, Token endToken) {
|
||||
debugEvent("Arguments");
|
||||
List<Object?>? arguments = count == 0
|
||||
? <Object>[]
|
||||
: const FixedNullableList<Object>().pop(stack, count);
|
||||
assert(
|
||||
checkState(
|
||||
beginToken,
|
||||
repeatedKind(
|
||||
unionOfKinds([ValueKinds.Argument, ValueKinds.ParserRecovery]),
|
||||
count,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
List<Argument>? arguments = count == 0
|
||||
? <Argument>[]
|
||||
: const FixedNullableList<Argument>().popNonNullable(
|
||||
stack,
|
||||
count,
|
||||
dummyArgument,
|
||||
);
|
||||
if (arguments == null) {
|
||||
push(new ParserRecovery(beginToken.charOffset));
|
||||
return;
|
||||
}
|
||||
List<Object?>? argumentsOriginalOrder;
|
||||
if (libraryFeatures.namedArgumentsAnywhere.isEnabled) {
|
||||
argumentsOriginalOrder = new List<Object?>.of(arguments);
|
||||
}
|
||||
List<Argument> argumentsOriginalOrder = new List.of(arguments);
|
||||
int firstNamedArgumentIndex = arguments.length;
|
||||
int positionalCount = 0;
|
||||
bool hasNamedBeforePositional = false;
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
Object? node = arguments[i];
|
||||
if (node is NamedExpression) {
|
||||
firstNamedArgumentIndex = i < firstNamedArgumentIndex
|
||||
? i
|
||||
: firstNamedArgumentIndex;
|
||||
} else {
|
||||
positionalCount++;
|
||||
Expression argument = toValue(node);
|
||||
arguments[i] = argument;
|
||||
argumentsOriginalOrder?[i] = argument;
|
||||
if (i > firstNamedArgumentIndex) {
|
||||
hasNamedBeforePositional = true;
|
||||
if (!libraryFeatures.namedArgumentsAnywhere.isEnabled) {
|
||||
arguments[i] = new NamedExpression(
|
||||
"#$i",
|
||||
buildProblem(
|
||||
message: cfe.codeExpectedNamedArgument,
|
||||
fileUri: uri,
|
||||
fileOffset: argument.fileOffset,
|
||||
length: noLength,
|
||||
),
|
||||
)..fileOffset = beginToken.charOffset;
|
||||
Argument argument = arguments[i];
|
||||
switch (argument) {
|
||||
case NamedArgument():
|
||||
firstNamedArgumentIndex = i < firstNamedArgumentIndex
|
||||
? i
|
||||
: firstNamedArgumentIndex;
|
||||
case PositionalArgument():
|
||||
positionalCount++;
|
||||
if (i > firstNamedArgumentIndex) {
|
||||
hasNamedBeforePositional = true;
|
||||
if (!libraryFeatures.namedArgumentsAnywhere.isEnabled) {
|
||||
addProblem(
|
||||
cfe.codeExpectedNamedArgument,
|
||||
argument.expression.fileOffset,
|
||||
noLength,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasNamedBeforePositional) {
|
||||
argumentsOriginalOrder = null;
|
||||
}
|
||||
if (firstNamedArgumentIndex < arguments.length) {
|
||||
List<Expression> positional;
|
||||
List<NamedExpression> named;
|
||||
if (libraryFeatures.namedArgumentsAnywhere.isEnabled) {
|
||||
positional = new List<Expression>.filled(
|
||||
positionalCount,
|
||||
dummyExpression,
|
||||
growable: true,
|
||||
);
|
||||
named = new List<NamedExpression>.filled(
|
||||
arguments.length - positionalCount,
|
||||
dummyNamedExpression,
|
||||
growable: true,
|
||||
);
|
||||
int positionalIndex = 0;
|
||||
int namedIndex = 0;
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] is NamedExpression) {
|
||||
named[namedIndex++] = arguments[i] as NamedExpression;
|
||||
} else {
|
||||
positional[positionalIndex++] = arguments[i] as Expression;
|
||||
}
|
||||
}
|
||||
assert(
|
||||
positionalIndex == positional.length && namedIndex == named.length,
|
||||
);
|
||||
} else {
|
||||
// arguments have non-null Expression entries after the initial loop.
|
||||
positional = new List<Expression>.from(
|
||||
arguments.getRange(0, firstNamedArgumentIndex),
|
||||
);
|
||||
named = new List<NamedExpression>.from(
|
||||
arguments.getRange(firstNamedArgumentIndex, arguments.length),
|
||||
);
|
||||
}
|
||||
|
||||
push(
|
||||
forest.createArguments(
|
||||
beginToken.offset,
|
||||
positional,
|
||||
named: named,
|
||||
argumentsOriginalOrder: argumentsOriginalOrder,
|
||||
arguments: argumentsOriginalOrder,
|
||||
hasNamedBeforePositional: hasNamedBeforePositional,
|
||||
positionalCount: positionalCount,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// TODO(kmillikin): Find a way to avoid allocating a second list in the
|
||||
// case where there were no named arguments, which is a common one.
|
||||
|
||||
// arguments have non-null Expression entries after the initial loop.
|
||||
push(
|
||||
forest.createArguments(
|
||||
beginToken.offset,
|
||||
new List<Expression>.from(arguments),
|
||||
argumentsOriginalOrder: argumentsOriginalOrder,
|
||||
arguments: argumentsOriginalOrder,
|
||||
hasNamedBeforePositional: hasNamedBeforePositional,
|
||||
positionalCount: argumentsOriginalOrder.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1592,7 +1559,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// Delay adding [typeArgumentBuilders] to [forest] for type aliases: They
|
||||
// must be unaliased to the type arguments of the denoted type.
|
||||
bool isInForest =
|
||||
arguments is ArgumentsImpl &&
|
||||
arguments is ActualArguments &&
|
||||
typeArgumentBuilders != null &&
|
||||
(receiver is! TypeUseGenerator ||
|
||||
receiver.declaration is! TypeAliasBuilder);
|
||||
@@ -1625,7 +1592,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
name,
|
||||
typeArgumentBuilders,
|
||||
typeArguments,
|
||||
arguments as ArgumentsImpl,
|
||||
arguments as ActualArguments,
|
||||
isTypeArgumentsInForest: isInForest,
|
||||
),
|
||||
);
|
||||
@@ -1638,7 +1605,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
receiver,
|
||||
typeArgumentBuilders,
|
||||
typeArguments,
|
||||
arguments as ArgumentsImpl,
|
||||
arguments as ActualArguments,
|
||||
beginToken.charOffset,
|
||||
isTypeArgumentsInForest: isInForest,
|
||||
),
|
||||
@@ -1661,7 +1628,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Object receiver,
|
||||
List<TypeBuilder>? typeArgumentBuilders,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
int charOffset, {
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
@@ -4347,7 +4314,6 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
token,
|
||||
repeatedKind(
|
||||
unionOfKinds([
|
||||
ValueKinds.Generator,
|
||||
ValueKinds.Expression,
|
||||
ValueKinds.NamedExpression,
|
||||
ValueKinds.ParserRecovery,
|
||||
@@ -6234,7 +6200,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Expression _buildConstructorInvocation(
|
||||
Member target,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
Constness constness = Constness.implicit,
|
||||
required TypeAliasBuilder? typeAliasBuilder,
|
||||
required int fileOffset,
|
||||
@@ -6370,7 +6336,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Expression buildStaticInvocation({
|
||||
required Procedure target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required int fileOffset,
|
||||
}) {
|
||||
Expression? result = problemReporting.checkStaticArguments(
|
||||
@@ -6496,9 +6462,9 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
|
||||
ConstantContext savedConstantContext = pop() as ConstantContext;
|
||||
|
||||
if (arguments is! ArgumentsImpl) {
|
||||
if (arguments is! ActualArguments) {
|
||||
push(new ParserErrorGenerator(this, nameToken, cfe.codeSyntheticToken));
|
||||
arguments = forest.createArguments(offset, []);
|
||||
arguments = forest.createArgumentsEmpty(offset);
|
||||
} else if (type is Generator) {
|
||||
push(
|
||||
type.invokeConstructor(
|
||||
@@ -6555,7 +6521,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
List<TypeBuilder>? typeArgumentBuilders,
|
||||
String className,
|
||||
String constructorName,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int instantiationOffset,
|
||||
required int invocationOffset,
|
||||
required bool inImplicitCreationContext,
|
||||
@@ -6627,7 +6593,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
TypeDeclarationBuilder? typeDeclarationBuilder,
|
||||
Token nameToken,
|
||||
Token nameLastToken,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
String name,
|
||||
List<TypeBuilder>? typeArgumentBuilders,
|
||||
TypeArguments? typeArguments,
|
||||
@@ -7651,8 +7617,10 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Object? identifier = pop();
|
||||
if (identifier is Identifier) {
|
||||
push(
|
||||
new NamedExpression(identifier.name, value)
|
||||
..fileOffset = identifier.nameOffset,
|
||||
new NamedArgument(
|
||||
new NamedExpression(identifier.name, value)
|
||||
..fileOffset = identifier.nameOffset,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
assert(
|
||||
@@ -7665,8 +7633,54 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
|
||||
@override
|
||||
// TODO: Handle directly.
|
||||
void handleNamedRecordField(Token colon) => handleNamedArgument(colon);
|
||||
void handlePositionalArgument(Token token) {
|
||||
debugEvent("NamedArgument");
|
||||
assert(
|
||||
checkState(token, [
|
||||
unionOfKinds([ValueKinds.Expression, ValueKinds.Generator]),
|
||||
]),
|
||||
);
|
||||
Expression value = popForValue();
|
||||
push(new PositionalArgument(value));
|
||||
}
|
||||
|
||||
@override
|
||||
void handleNamedRecordField(Token colon) {
|
||||
debugEvent("handleNamedRecordField");
|
||||
assert(
|
||||
checkState(colon, [
|
||||
unionOfKinds([ValueKinds.Expression, ValueKinds.Generator]),
|
||||
unionOfKinds([ValueKinds.Identifier, ValueKinds.ParserRecovery]),
|
||||
]),
|
||||
);
|
||||
Expression value = popForValue();
|
||||
Object? identifier = pop();
|
||||
if (identifier is Identifier) {
|
||||
push(
|
||||
new NamedExpression(identifier.name, value)
|
||||
..fileOffset = identifier.nameOffset,
|
||||
);
|
||||
} else {
|
||||
assert(
|
||||
identifier is ParserRecovery,
|
||||
"Unexpected record field name: "
|
||||
"${identifier} (${identifier.runtimeType})",
|
||||
);
|
||||
push(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void handlePositionalRecordField(Token token) {
|
||||
debugEvent("handlePositionalRecordField");
|
||||
assert(
|
||||
checkState(token, [
|
||||
unionOfKinds([ValueKinds.Expression, ValueKinds.Generator]),
|
||||
]),
|
||||
);
|
||||
Expression value = popForValue();
|
||||
push(value);
|
||||
}
|
||||
|
||||
@override
|
||||
void endFunctionName(
|
||||
@@ -10010,7 +10024,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Initializer buildSuperInitializer(
|
||||
bool isSynthetic,
|
||||
Constructor constructor,
|
||||
ArgumentsImpl arguments, [
|
||||
ActualArguments arguments, [
|
||||
int charOffset = -1,
|
||||
]) {
|
||||
if (_context.isConstConstructor && !constructor.isConst) {
|
||||
@@ -10031,7 +10045,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
@override
|
||||
Initializer buildRedirectingInitializer(
|
||||
Name name,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int fileOffset,
|
||||
}) {
|
||||
Builder? constructorBuilder = _context.lookupConstructor(name);
|
||||
@@ -10283,21 +10297,14 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
|
||||
@override
|
||||
Expression evaluateArgumentsBefore(
|
||||
ArgumentsImpl? arguments,
|
||||
ActualArguments? arguments,
|
||||
Expression expression,
|
||||
) {
|
||||
if (arguments == null) return expression;
|
||||
List<Expression> expressions = new List<Expression>.of(
|
||||
arguments.positional,
|
||||
);
|
||||
for (NamedExpression named in arguments.named) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
expressions.add(named.value);
|
||||
}
|
||||
for (Expression argument in expressions.reversed) {
|
||||
for (Argument argument in arguments.argumentList.reversed) {
|
||||
expression = new Let(
|
||||
new VariableDeclaration.forValue(
|
||||
argument,
|
||||
argument.expression,
|
||||
isFinal: true,
|
||||
type: coreTypes.objectRawType(Nullability.nullable),
|
||||
),
|
||||
@@ -10315,7 +10322,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Expression receiver,
|
||||
Name name,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
int offset, {
|
||||
bool isConstantExpression = false,
|
||||
bool isNullAware = false,
|
||||
@@ -10346,7 +10353,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
Expression buildSuperInvocation(
|
||||
Name name,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
int offset, {
|
||||
bool isConstantExpression = false,
|
||||
bool isNullAware = false,
|
||||
@@ -11341,7 +11348,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
|
||||
@override
|
||||
BuildEnumConstantResult buildEnumConstant({required Token token}) {
|
||||
ArgumentsImpl arguments = parseArguments(token);
|
||||
ActualArguments arguments = parseArguments(token);
|
||||
return new BuildEnumConstantResult(arguments, _takePendingAnnotations());
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ abstract class BodyBuilderContext {
|
||||
/// in the same class.
|
||||
Initializer buildRedirectingInitializer(
|
||||
Builder constructorBuilder,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int fileOffset,
|
||||
}) {
|
||||
return declarationContext.buildRedirectingInitializer(
|
||||
@@ -453,7 +453,7 @@ abstract class BodyBuilderDeclarationContext {
|
||||
|
||||
Initializer buildRedirectingInitializer(
|
||||
Builder constructorBuilder,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int fileOffset,
|
||||
}) {
|
||||
throw new UnsupportedError('${runtimeType}.buildRedirectingInitializer');
|
||||
@@ -563,7 +563,7 @@ class _SourceClassBodyBuilderDeclarationContext
|
||||
@override
|
||||
Initializer buildRedirectingInitializer(
|
||||
covariant SourceConstructorBuilder constructorBuilder,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int fileOffset,
|
||||
}) {
|
||||
return new InternalRedirectingInitializer(
|
||||
@@ -668,7 +668,7 @@ class _SourceExtensionTypeDeclarationBodyBuilderDeclarationContext
|
||||
@override
|
||||
Initializer buildRedirectingInitializer(
|
||||
covariant SourceConstructorBuilder constructorBuilder,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int fileOffset,
|
||||
}) {
|
||||
return new ExtensionTypeRedirectingInitializer(
|
||||
|
||||
@@ -565,7 +565,7 @@ class BuildFieldInitializerResult {
|
||||
}
|
||||
|
||||
class BuildEnumConstantResult {
|
||||
final ArgumentsImpl arguments;
|
||||
final ActualArguments arguments;
|
||||
final PendingAnnotations? annotations;
|
||||
|
||||
BuildEnumConstantResult(this.arguments, this.annotations);
|
||||
|
||||
@@ -234,7 +234,7 @@ abstract class Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
});
|
||||
|
||||
@@ -360,7 +360,7 @@ abstract class Generator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -540,7 +540,7 @@ class VariableUseGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.forest.createExpressionInvocation(
|
||||
@@ -668,7 +668,7 @@ class PropertyAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.buildMethodInvocation(
|
||||
@@ -1020,7 +1020,7 @@ class ThisPropertyAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.buildMethodInvocation(
|
||||
@@ -1192,7 +1192,7 @@ class NullAwarePropertyAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return unsupported("doInvocation", offset, _fileUri);
|
||||
@@ -1387,7 +1387,7 @@ class SuperPropertyAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
if (_helper.constantContext != ConstantContext.none) {
|
||||
@@ -1561,7 +1561,7 @@ class IndexedAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.forest.createExpressionInvocation(
|
||||
@@ -1739,7 +1739,7 @@ class ThisIndexedAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.forest.createExpressionInvocation(
|
||||
@@ -1814,7 +1814,12 @@ class SuperIndexedAccessGenerator extends Generator {
|
||||
indexGetName,
|
||||
getter,
|
||||
null,
|
||||
_helper.forest.createArguments(fileOffset, <Expression>[index]),
|
||||
_helper.forest.createArguments(
|
||||
fileOffset,
|
||||
arguments: [new PositionalArgument(index)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1837,10 +1842,15 @@ class SuperIndexedAccessGenerator extends Generator {
|
||||
indexSetName,
|
||||
setter,
|
||||
null,
|
||||
_helper.forest.createArguments(fileOffset, <Expression>[
|
||||
index,
|
||||
value,
|
||||
]),
|
||||
_helper.forest.createArguments(
|
||||
fileOffset,
|
||||
arguments: [
|
||||
new PositionalArgument(index),
|
||||
new PositionalArgument(value),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 2,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return new SuperIndexSet(setter, index, value)..fileOffset = fileOffset;
|
||||
@@ -1919,7 +1929,7 @@ class SuperIndexedAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.forest.createExpressionInvocation(
|
||||
@@ -2200,7 +2210,7 @@ class StaticAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
if (_helper.constantContext != ConstantContext.none &&
|
||||
@@ -2606,7 +2616,7 @@ class ExtensionInstanceAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
Procedure? method = invokeTarget;
|
||||
@@ -3053,7 +3063,7 @@ class ExplicitExtensionInstanceAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
Procedure? method = invokeTarget;
|
||||
@@ -3349,7 +3359,7 @@ class ExplicitExtensionIndexedAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.forest.createExpressionInvocation(
|
||||
@@ -3576,7 +3586,12 @@ class ExplicitExtensionAccessGenerator extends Generator {
|
||||
offset: fileOffset,
|
||||
typeArgumentBuilders: null,
|
||||
typeArguments: null,
|
||||
arguments: _forest.createArguments(fileOffset, <Expression>[right]),
|
||||
arguments: _forest.createArguments(
|
||||
fileOffset,
|
||||
arguments: [new PositionalArgument(right)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3597,7 +3612,7 @@ class ExplicitExtensionAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
Generator generator = _createInstanceAccess(token, callName);
|
||||
@@ -3770,10 +3785,10 @@ class LoadLibraryGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
if (arguments.positional.length > 0 || arguments.named.length > 0) {
|
||||
if (arguments.positionalCount > 0 || arguments.namedCount > 0) {
|
||||
_helper.addProblemErrorIfConst(
|
||||
codeLoadLibraryTakesNoArguments,
|
||||
offset,
|
||||
@@ -3998,7 +4013,7 @@ class DeferredAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
Object suffix = suffixGenerator.doInvocation(
|
||||
@@ -4029,7 +4044,7 @@ class DeferredAccessGenerator extends Generator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -4148,7 +4163,7 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -4241,7 +4256,7 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
|
||||
) {
|
||||
int nameOffset = offsetForToken(send.token);
|
||||
Name name = send.name;
|
||||
ArgumentsImpl? arguments = send.arguments;
|
||||
ActualArguments? arguments = send.arguments;
|
||||
|
||||
TypeDeclarationBuilder? declarationBuilder = declaration;
|
||||
TypeAliasBuilder? aliasBuilder;
|
||||
@@ -4696,12 +4711,12 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
if (declaration is ExtensionBuilder) {
|
||||
ExtensionBuilder extensionBuilder = declaration as ExtensionBuilder;
|
||||
if (arguments.positional.length != 1 || arguments.named.isNotEmpty) {
|
||||
if (arguments.positionalCount != 1 || arguments.namedCount > 0) {
|
||||
return _helper.buildProblem(
|
||||
message: codeExplicitExtensionArgumentMismatch,
|
||||
fileUri: _helper.uri,
|
||||
@@ -4731,7 +4746,7 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
|
||||
helper: _helper,
|
||||
token: token,
|
||||
extensionBuilder: declaration as ExtensionBuilder,
|
||||
receiver: arguments.positional.single,
|
||||
receiver: arguments.argumentList.single.expression,
|
||||
explicitTypeArguments: typeArguments,
|
||||
extensionTypeArgumentOffset: extensionTypeArgumentOffset,
|
||||
);
|
||||
@@ -4948,7 +4963,7 @@ abstract class AbstractReadOnlyAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.forest.createExpressionInvocation(
|
||||
@@ -5016,7 +5031,7 @@ abstract class ErroneousExpressionGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return buildError(charOffset: offset, kind: UnresolvedKind.Method);
|
||||
@@ -5113,7 +5128,7 @@ abstract class ErroneousExpressionGenerator extends Generator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -5239,7 +5254,7 @@ class DuplicateDeclarationGenerator extends ErroneousExpressionGenerator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -5300,7 +5315,7 @@ class UnresolvedNameGenerator extends ErroneousExpressionGenerator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return buildError(
|
||||
@@ -5414,7 +5429,7 @@ abstract class ContextAwareGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return unhandled("${runtimeType}", "doInvocation", offset, _fileUri);
|
||||
@@ -5806,7 +5821,7 @@ class PrefixUseGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return problemReporting.wrapInLocatedProblem(
|
||||
@@ -5985,7 +6000,7 @@ class UnexpectedQualifiedUseGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return _helper.buildUnresolvedError(
|
||||
@@ -6031,7 +6046,7 @@ class UnexpectedQualifiedUseGenerator extends Generator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -6186,7 +6201,7 @@ class ParserErrorGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
return buildProblem();
|
||||
@@ -6238,7 +6253,7 @@ class ParserErrorGenerator extends Generator {
|
||||
required String name,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Token nameToken,
|
||||
required Token nameLastToken,
|
||||
required Constness constness,
|
||||
@@ -6392,7 +6407,7 @@ class ThisAccessGenerator extends Generator {
|
||||
bool isNullAware,
|
||||
) {
|
||||
Name name = selector.name;
|
||||
ArgumentsImpl? arguments = selector.arguments;
|
||||
ActualArguments? arguments = selector.arguments;
|
||||
int offset = offsetForToken(selector.token);
|
||||
if (isInitializer && selector is InvocationSelector) {
|
||||
if (isNullAware) {
|
||||
@@ -6459,7 +6474,7 @@ class ThisAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
if (isInitializer) {
|
||||
@@ -6493,7 +6508,12 @@ class ThisAccessGenerator extends Generator {
|
||||
Expression result = _helper.buildSuperInvocation(
|
||||
equalsName,
|
||||
null,
|
||||
_forest.createArguments(offset, <Expression>[right]),
|
||||
_forest.createArguments(
|
||||
offset,
|
||||
arguments: [new PositionalArgument(right)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
offset,
|
||||
);
|
||||
if (isNot) {
|
||||
@@ -6516,7 +6536,12 @@ class ThisAccessGenerator extends Generator {
|
||||
return _helper.buildSuperInvocation(
|
||||
binaryName,
|
||||
null,
|
||||
_forest.createArguments(offset, <Expression>[right]),
|
||||
_forest.createArguments(
|
||||
offset,
|
||||
arguments: [new PositionalArgument(right)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
offset,
|
||||
);
|
||||
}
|
||||
@@ -6542,7 +6567,7 @@ class ThisAccessGenerator extends Generator {
|
||||
Expression_Initializer buildConstructorInitializer(
|
||||
int offset,
|
||||
Name name,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
) {
|
||||
if (isSuper) {
|
||||
MemberLookupResult? result = _helper.lookupSuperConstructor(
|
||||
@@ -6746,7 +6771,7 @@ class IncompleteErrorGenerator extends ErroneousExpressionGenerator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) => this;
|
||||
|
||||
@@ -6895,7 +6920,7 @@ abstract class Selector {
|
||||
// Coverage-ignore(suite): Not run.
|
||||
TypeArguments? get typeArguments => null;
|
||||
|
||||
ArgumentsImpl? get arguments => null;
|
||||
ActualArguments? get arguments => null;
|
||||
|
||||
/// Internal name used for debugging.
|
||||
String get _debugName;
|
||||
@@ -6951,7 +6976,7 @@ class InvocationSelector extends Selector {
|
||||
final bool isTypeArgumentsInForest;
|
||||
|
||||
@override
|
||||
final ArgumentsImpl arguments;
|
||||
final ActualArguments arguments;
|
||||
|
||||
final bool isPotentiallyConstant;
|
||||
|
||||
@@ -7186,7 +7211,7 @@ class AugmentSuperAccessGenerator extends Generator {
|
||||
required int offset,
|
||||
required List<TypeBuilder>? typeArgumentBuilders,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
bool isTypeArgumentsInForest = false,
|
||||
}) {
|
||||
Member? invokeTarget = augmentSuperTarget.invokeTarget;
|
||||
|
||||
@@ -101,7 +101,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
Object receiver,
|
||||
List<TypeBuilder>? typeArgumentBuilders,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
int offset, {
|
||||
bool isTypeArgumentsInForest = false,
|
||||
});
|
||||
@@ -119,20 +119,20 @@ abstract class ExpressionGeneratorHelper {
|
||||
Initializer buildSuperInitializer(
|
||||
bool isSynthetic,
|
||||
Constructor constructor,
|
||||
ArgumentsImpl arguments, [
|
||||
ActualArguments arguments, [
|
||||
int offset = TreeNode.noOffset,
|
||||
]);
|
||||
|
||||
Initializer buildRedirectingInitializer(
|
||||
Name name,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int fileOffset,
|
||||
});
|
||||
|
||||
Expression buildStaticInvocation({
|
||||
required Procedure target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required int fileOffset,
|
||||
});
|
||||
|
||||
@@ -157,7 +157,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
Expression receiver,
|
||||
Name name,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
int offset, {
|
||||
bool isConstantExpression = false,
|
||||
bool isNullAware = false,
|
||||
@@ -166,7 +166,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
Expression buildSuperInvocation(
|
||||
Name name,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
int offset, {
|
||||
bool isConstantExpression = false,
|
||||
bool isNullAware = false,
|
||||
@@ -177,7 +177,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
TypeDeclarationBuilder type,
|
||||
Token nameToken,
|
||||
Token nameLastToken,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
String name,
|
||||
List<TypeBuilder>? typeArgumentBuilders,
|
||||
TypeArguments? typeArguments,
|
||||
@@ -202,7 +202,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
);
|
||||
|
||||
Expression evaluateArgumentsBefore(
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
Expression expression,
|
||||
);
|
||||
|
||||
@@ -269,7 +269,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
List<TypeBuilder>? typeArguments,
|
||||
String className,
|
||||
String constructorName,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int instantiationOffset,
|
||||
required int invocationOffset,
|
||||
required bool inImplicitCreationContext,
|
||||
|
||||
@@ -28,21 +28,26 @@ import 'internal_ast.dart';
|
||||
class Forest {
|
||||
const Forest();
|
||||
|
||||
ArgumentsImpl createArguments(
|
||||
int fileOffset,
|
||||
List<Expression> positional, {
|
||||
List<NamedExpression>? named,
|
||||
List<Object?>? argumentsOriginalOrder,
|
||||
ActualArguments createArguments(
|
||||
int fileOffset, {
|
||||
required List<Argument> arguments,
|
||||
required bool hasNamedBeforePositional,
|
||||
required int positionalCount,
|
||||
}) {
|
||||
return new ArgumentsImpl(
|
||||
positional,
|
||||
named: named,
|
||||
argumentsOriginalOrder: argumentsOriginalOrder,
|
||||
return new ActualArguments(
|
||||
argumentList: arguments,
|
||||
hasNamedBeforePositional: hasNamedBeforePositional,
|
||||
positionalCount: positionalCount,
|
||||
)..fileOffset = fileOffset;
|
||||
}
|
||||
|
||||
ArgumentsImpl createArgumentsEmpty(int fileOffset) {
|
||||
return createArguments(fileOffset, []);
|
||||
ActualArguments createArgumentsEmpty(int fileOffset) {
|
||||
return createArguments(
|
||||
fileOffset,
|
||||
arguments: [],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 0,
|
||||
);
|
||||
}
|
||||
|
||||
/// Return a representation of a boolean literal at the given [fileOffset].
|
||||
@@ -192,7 +197,7 @@ class Forest {
|
||||
LoadLibrary createLoadLibrary(
|
||||
int fileOffset,
|
||||
LibraryDependency dependency,
|
||||
ArgumentsImpl? arguments,
|
||||
ActualArguments? arguments,
|
||||
) {
|
||||
return new LoadLibraryImpl(dependency, arguments)..fileOffset = fileOffset;
|
||||
}
|
||||
@@ -752,7 +757,7 @@ class Forest {
|
||||
int fileOffset,
|
||||
Expression expression,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
) {
|
||||
return new ExpressionInvocation(expression, typeArguments, arguments)
|
||||
..fileOffset = fileOffset;
|
||||
@@ -763,7 +768,7 @@ class Forest {
|
||||
Expression expression,
|
||||
Name name,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required bool isNullAware,
|
||||
}) {
|
||||
return new MethodInvocation(
|
||||
@@ -780,7 +785,7 @@ class Forest {
|
||||
Name name,
|
||||
Procedure procedure,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
) {
|
||||
return new InternalSuperMethodInvocation(
|
||||
name,
|
||||
@@ -1156,7 +1161,7 @@ class Forest {
|
||||
int fileOffset,
|
||||
Name name,
|
||||
TypeArguments? typeArguments,
|
||||
ArgumentsImpl arguments, {
|
||||
ActualArguments arguments, {
|
||||
required int nameOffset,
|
||||
required bool isConst,
|
||||
}) {
|
||||
|
||||
@@ -287,68 +287,137 @@ class TypeArguments {
|
||||
}
|
||||
}
|
||||
|
||||
/// Front end specific implementation of [Argument].
|
||||
class ArgumentsImpl extends TreeNode with InternalTreeNode {
|
||||
final List<Expression> positional;
|
||||
List<NamedExpression> named;
|
||||
sealed class Argument {
|
||||
TreeNode get node;
|
||||
|
||||
bool _hasExplicitTypeArguments;
|
||||
abstract Expression expression;
|
||||
|
||||
List<Object?>? argumentsOriginalOrder;
|
||||
bool get isSuperParameter => false;
|
||||
|
||||
/// True if the arguments are passed to the super-constructor in a
|
||||
/// super-initializer, and the positional parameters are super-initializer
|
||||
/// parameters. It is true that either all of the positional parameters are
|
||||
/// super-initializer parameters or none of them, so a simple boolean
|
||||
/// accurately reflects the state.
|
||||
bool positionalAreSuperParameters = false;
|
||||
void toTextInternal(AstPrinter printer);
|
||||
}
|
||||
|
||||
/// Names of the named positional parameters. If none of the parameters are
|
||||
/// super-positional, the field is null.
|
||||
Set<String>? namedSuperParameterNames;
|
||||
class PositionalArgument extends Argument {
|
||||
@override
|
||||
Expression expression;
|
||||
|
||||
ArgumentsImpl(
|
||||
this.positional, {
|
||||
List<DartType>? types,
|
||||
List<NamedExpression>? named,
|
||||
this.argumentsOriginalOrder,
|
||||
}) : _hasExplicitTypeArguments = false,
|
||||
this.named = named ?? [];
|
||||
PositionalArgument(this.expression);
|
||||
|
||||
ArgumentsImpl.empty()
|
||||
: _hasExplicitTypeArguments = false,
|
||||
this.positional = [],
|
||||
this.named = [];
|
||||
|
||||
@deprecated
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
bool get hasExplicitTypeArguments => _hasExplicitTypeArguments;
|
||||
TreeNode get node => expression;
|
||||
|
||||
Arguments toArguments(List<DartType> typeArguments) {
|
||||
return new Arguments(positional, types: typeArguments, named: named)
|
||||
..fileOffset = fileOffset;
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
void toTextInternal(AstPrinter printer) {
|
||||
expression.toTextInternal(printer);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'PositionalArgument($expression)';
|
||||
}
|
||||
|
||||
class SuperPositionalArgument extends PositionalArgument {
|
||||
SuperPositionalArgument(super.expression);
|
||||
|
||||
@override
|
||||
bool get isSuperParameter => true;
|
||||
}
|
||||
|
||||
class NamedArgument extends Argument {
|
||||
NamedExpression namedExpression;
|
||||
|
||||
NamedArgument(this.namedExpression);
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
TreeNode get node => namedExpression;
|
||||
|
||||
String get name => namedExpression.name;
|
||||
|
||||
@override
|
||||
Expression get expression => namedExpression.value;
|
||||
|
||||
@override
|
||||
void set expression(Expression value) {
|
||||
namedExpression.value = value..parent = namedExpression;
|
||||
}
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
void toTextInternal(AstPrinter printer) {
|
||||
namedExpression.toTextInternal(printer);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'NamedArgument($namedExpression)';
|
||||
}
|
||||
|
||||
class SuperNamedArgument extends NamedArgument {
|
||||
SuperNamedArgument(super.expression);
|
||||
|
||||
@override
|
||||
bool get isSuperParameter => true;
|
||||
}
|
||||
|
||||
/// Front end specific implementation of [Argument].
|
||||
class ActualArguments extends TreeNode with InternalTreeNode {
|
||||
final List<Argument> argumentList;
|
||||
|
||||
bool _hasNamedBeforePositional;
|
||||
int _positionalCount;
|
||||
|
||||
ActualArguments({
|
||||
required this.argumentList,
|
||||
required bool hasNamedBeforePositional,
|
||||
required int positionalCount,
|
||||
}) : _hasNamedBeforePositional = hasNamedBeforePositional,
|
||||
_positionalCount = positionalCount;
|
||||
|
||||
// Coverage-ignore(suite): Not run.
|
||||
ActualArguments.empty()
|
||||
: this.argumentList = [],
|
||||
this._hasNamedBeforePositional = false,
|
||||
this._positionalCount = 0;
|
||||
|
||||
int get positionalCount => _positionalCount;
|
||||
|
||||
int get namedCount => argumentList.length - positionalCount;
|
||||
|
||||
bool get hasNamedBeforePositional => _hasNamedBeforePositional;
|
||||
|
||||
void prependArguments(List<Argument> list, {required int positionalCount}) {
|
||||
assert(list.whereType<PositionalArgument>().length == positionalCount);
|
||||
argumentList.insertAll(0, list);
|
||||
if (!_hasNamedBeforePositional &&
|
||||
_positionalCount > 0 &&
|
||||
positionalCount < list.length) {
|
||||
_hasNamedBeforePositional = true;
|
||||
}
|
||||
_positionalCount += positionalCount;
|
||||
}
|
||||
|
||||
Arguments toArguments(
|
||||
List<DartType> typeArguments,
|
||||
List<Expression> positionalArguments,
|
||||
List<NamedExpression> namedArguments,
|
||||
) {
|
||||
return new Arguments(
|
||||
positionalArguments,
|
||||
types: typeArguments,
|
||||
named: namedArguments,
|
||||
)..fileOffset = fileOffset;
|
||||
}
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
void toTextInternal(AstPrinter printer) {
|
||||
printer.write('(');
|
||||
for (int index = 0; index < positional.length; index++) {
|
||||
for (int index = 0; index < argumentList.length; index++) {
|
||||
if (index > 0) {
|
||||
printer.write(', ');
|
||||
}
|
||||
printer.writeExpression(positional[index]);
|
||||
}
|
||||
if (named.isNotEmpty) {
|
||||
if (positional.isNotEmpty) {
|
||||
printer.write(', ');
|
||||
}
|
||||
for (int index = 0; index < named.length; index++) {
|
||||
if (index > 0) {
|
||||
printer.write(', ');
|
||||
}
|
||||
printer.writeNamedExpression(named[index]);
|
||||
}
|
||||
argumentList[index].toTextInternal(printer);
|
||||
}
|
||||
printer.write(')');
|
||||
}
|
||||
@@ -492,7 +561,7 @@ class FactoryConstructorInvocation extends InternalExpression {
|
||||
bool hasBeenInferred = false;
|
||||
final Procedure target;
|
||||
final TypeArguments? typeArguments;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
/// If `true`, this invocation is constant, either explicit or inferred.
|
||||
final bool isConst;
|
||||
@@ -543,7 +612,7 @@ class TypeAliasedConstructorInvocation extends InternalExpression {
|
||||
final TypeAliasBuilder typeAliasBuilder;
|
||||
final Constructor target;
|
||||
final TypeArguments? typeArguments;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
final bool isConst;
|
||||
|
||||
TypeAliasedConstructorInvocation(
|
||||
@@ -593,7 +662,7 @@ class TypeAliasedFactoryInvocation extends InternalExpression {
|
||||
final TypeAliasBuilder typeAliasBuilder;
|
||||
final Procedure target;
|
||||
final TypeArguments? typeArguments;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
/// If `true`, this invocation is constant, either explicit or inferred.
|
||||
final bool isConst;
|
||||
@@ -796,7 +865,7 @@ class ShadowLargeIntLiteral extends IntLiteral implements ExpressionJudgment {
|
||||
class ExpressionInvocation extends InternalExpression {
|
||||
Expression expression;
|
||||
final TypeArguments? typeArguments;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
ExpressionInvocation(this.expression, this.typeArguments, this.arguments) {
|
||||
expression.parent = this;
|
||||
@@ -1427,7 +1496,7 @@ mixin InternalExpressionVariableMixin on TreeNode
|
||||
|
||||
/// Front end specific implementation of [LoadLibrary].
|
||||
class LoadLibraryImpl extends LoadLibrary {
|
||||
final ArgumentsImpl? arguments;
|
||||
final ActualArguments? arguments;
|
||||
|
||||
LoadLibraryImpl(LibraryDependency import, this.arguments) : super(import);
|
||||
|
||||
@@ -3865,7 +3934,7 @@ class ExtensionMethodInvocation extends InternalExpression {
|
||||
final TypeArguments? typeArguments;
|
||||
|
||||
/// The arguments provided to the method.
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
/// `true` if the extension access is explicit, i.e. `E(o).a()` and
|
||||
/// not implicit like `a()` inside the extension `E`.
|
||||
@@ -3885,7 +3954,7 @@ class ExtensionMethodInvocation extends InternalExpression {
|
||||
required Name name,
|
||||
required Procedure target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
}) : this._(
|
||||
extension,
|
||||
thisAccess,
|
||||
@@ -3905,7 +3974,7 @@ class ExtensionMethodInvocation extends InternalExpression {
|
||||
required Name name,
|
||||
required Procedure target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required List<DartType>? explicitTypeArguments,
|
||||
required int? extensionTypeArgumentOffset,
|
||||
required bool isNullAware,
|
||||
@@ -4012,7 +4081,7 @@ class ExtensionGetterInvocation extends InternalExpression {
|
||||
final TypeArguments? typeArguments;
|
||||
|
||||
/// The arguments provided to the getter.
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
/// `true` if the extension access is explicit, i.e. `E(o).a()` and
|
||||
/// not implicit like `a()` inside the extension `E`.
|
||||
@@ -4032,7 +4101,7 @@ class ExtensionGetterInvocation extends InternalExpression {
|
||||
required Name name,
|
||||
required Procedure target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
}) : this._(
|
||||
extension,
|
||||
thisAccess,
|
||||
@@ -4052,7 +4121,7 @@ class ExtensionGetterInvocation extends InternalExpression {
|
||||
required Name name,
|
||||
required Procedure target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required List<DartType>? explicitTypeArguments,
|
||||
required int? extensionTypeArgumentOffset,
|
||||
required bool isNullAware,
|
||||
@@ -4449,7 +4518,7 @@ class MethodInvocation extends InternalExpression {
|
||||
final TypeArguments? typeArguments;
|
||||
|
||||
/// The arguments applied at the invocation.
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
/// `true` if the access is null-aware, i.e. of the form `o?.a()`.
|
||||
final bool isNullAware;
|
||||
@@ -4618,7 +4687,7 @@ class AugmentSuperInvocation extends InternalExpression {
|
||||
|
||||
final TypeArguments? typeArguments;
|
||||
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
AugmentSuperInvocation(
|
||||
this.target,
|
||||
@@ -4808,14 +4877,19 @@ class ObjectPatternInternal extends ObjectPattern {
|
||||
|
||||
class ExtensionTypeRedirectingInitializer extends InternalInitializer {
|
||||
Reference targetReference;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
/// Redirecting initializers are encoded as calls to top-level functions.
|
||||
/// The type arguments for this call are inferred.
|
||||
List<DartType> inferredTypeArguments = [];
|
||||
|
||||
ExtensionTypeRedirectingInitializer(Procedure target, ArgumentsImpl arguments)
|
||||
: this.byReference(
|
||||
List<Expression> positional = [];
|
||||
List<NamedExpression> named = [];
|
||||
|
||||
ExtensionTypeRedirectingInitializer(
|
||||
Procedure target,
|
||||
ActualArguments arguments,
|
||||
) : this.byReference(
|
||||
// Getter vs setter doesn't matter for procedures.
|
||||
getNonNullableMemberReferenceGetter(target),
|
||||
arguments,
|
||||
@@ -4935,7 +5009,7 @@ class DotShorthandInvocation extends InternalExpression {
|
||||
final Name name;
|
||||
final int nameOffset;
|
||||
final TypeArguments? typeArguments;
|
||||
final ArgumentsImpl arguments;
|
||||
final ActualArguments arguments;
|
||||
|
||||
/// If `true`, this invocation is constant, either explicit or inferred.
|
||||
final bool isConst;
|
||||
@@ -5018,7 +5092,7 @@ class DotShorthandPropertyGet extends InternalExpression {
|
||||
class InternalConstructorInvocation extends InternalExpression {
|
||||
final Constructor target;
|
||||
final TypeArguments? typeArguments;
|
||||
final ArgumentsImpl arguments;
|
||||
final ActualArguments arguments;
|
||||
final bool isConst;
|
||||
|
||||
InternalConstructorInvocation(
|
||||
@@ -5065,7 +5139,7 @@ class InternalStaticInvocation extends InternalExpression {
|
||||
final Name name;
|
||||
final Procedure target;
|
||||
final TypeArguments? typeArguments;
|
||||
final ArgumentsImpl arguments;
|
||||
final ActualArguments arguments;
|
||||
|
||||
InternalStaticInvocation(
|
||||
this.name,
|
||||
@@ -5102,7 +5176,7 @@ class InternalSuperMethodInvocation extends InternalExpression {
|
||||
final Name name;
|
||||
final Procedure target;
|
||||
final TypeArguments? typeArguments;
|
||||
final ArgumentsImpl arguments;
|
||||
final ActualArguments arguments;
|
||||
|
||||
InternalSuperMethodInvocation(
|
||||
this.name,
|
||||
@@ -5138,7 +5212,7 @@ class InternalSuperMethodInvocation extends InternalExpression {
|
||||
|
||||
class InternalRedirectingInitializer extends InternalInitializer {
|
||||
final Constructor target;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
InternalRedirectingInitializer(this.target, this.arguments) {
|
||||
arguments.parent = this;
|
||||
@@ -5168,7 +5242,7 @@ class InternalRedirectingInitializer extends InternalInitializer {
|
||||
|
||||
class InternalSuperInitializer extends InternalInitializer {
|
||||
final Constructor target;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
|
||||
@override
|
||||
final bool isSynthetic;
|
||||
|
||||
@@ -1843,17 +1843,16 @@ class KernelTarget {
|
||||
final Importability importability = compilationUnit.importability;
|
||||
final bool importableWithFlag =
|
||||
(importability == Importability.withFlag &&
|
||||
// Coverage-ignore(suite): Not run.
|
||||
flags.includeUnsupportedPlatformLibraryStubs);
|
||||
if (!dartLibrarySupport.computeDartLibrarySupport(
|
||||
importUri.path,
|
||||
isSupportedBySpec:
|
||||
(importability == Importability.always || importableWithFlag),
|
||||
)) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
diagnostic = codeUnavailableDartLibrary.withArguments(uri: importUri);
|
||||
} else if (importableWithFlag) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
}
|
||||
// Coverage-ignore(suite): Not run.
|
||||
else if (importableWithFlag) {
|
||||
// Display a warning for each import of an unsupported library.
|
||||
diagnostic = codeUnsupportedPlatformDartLibraryImport.withArguments(
|
||||
uri: importUri,
|
||||
|
||||
@@ -71,7 +71,7 @@ class LoadLibraryBuilder extends NamedBuilderImpl {
|
||||
LoadLibrary createLoadLibrary(
|
||||
int charOffset,
|
||||
Forest forest,
|
||||
ArgumentsImpl? arguments,
|
||||
ActualArguments? arguments,
|
||||
) {
|
||||
return forest.createLoadLibrary(charOffset, importDependency, arguments);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class Resolver {
|
||||
required ExtensionScope extensionScope,
|
||||
required LookupScope scope,
|
||||
required Token? token,
|
||||
required List<Expression> enumSyntheticArguments,
|
||||
required List<Argument> enumSyntheticArguments,
|
||||
required int enumTypeParameterCount,
|
||||
required TypeArguments? typeArguments,
|
||||
required MemberBuilder? constructorBuilder,
|
||||
@@ -178,16 +178,21 @@ class Resolver {
|
||||
constantContext: constantContext,
|
||||
);
|
||||
BuildEnumConstantResult? result;
|
||||
ArgumentsImpl arguments;
|
||||
ActualArguments arguments;
|
||||
if (token != null) {
|
||||
result = bodyBuilder.buildEnumConstant(token: token);
|
||||
arguments = result.arguments;
|
||||
arguments.positional.insertAll(0, enumSyntheticArguments);
|
||||
arguments.argumentsOriginalOrder?.insertAll(0, enumSyntheticArguments);
|
||||
arguments.prependArguments(
|
||||
enumSyntheticArguments,
|
||||
positionalCount: enumSyntheticArguments.length,
|
||||
);
|
||||
} else {
|
||||
arguments = new ArgumentsImpl(enumSyntheticArguments);
|
||||
arguments = new ActualArguments(
|
||||
argumentList: enumSyntheticArguments,
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: enumSyntheticArguments.length,
|
||||
);
|
||||
}
|
||||
setParents(enumSyntheticArguments, arguments);
|
||||
Expression initializer;
|
||||
DartType? fieldType;
|
||||
if (constructorBuilder == null ||
|
||||
@@ -431,12 +436,11 @@ class Resolver {
|
||||
bool needsImplicitSuperInitializer = result.needsImplicitSuperInitializer;
|
||||
if (isConst) {
|
||||
List<FormalParameterBuilder>? formals = bodyBuilderContext.formals;
|
||||
List<Object>? superParametersAsArguments = formals != null
|
||||
? _createSuperParametersAsArguments(
|
||||
assignedVariables: context.typeInferrer.assignedVariables,
|
||||
formals: formals,
|
||||
)
|
||||
: null;
|
||||
_SuperParameterArguments? superParameterArguments =
|
||||
_createSuperParameterArguments(
|
||||
assignedVariables: context.typeInferrer.assignedVariables,
|
||||
formals: formals,
|
||||
);
|
||||
_declareFormals(
|
||||
typeInferrer: context.typeInferrer,
|
||||
bodyBuilderContext: bodyBuilderContext,
|
||||
@@ -451,7 +455,7 @@ class Resolver {
|
||||
bodyBuilderContext: bodyBuilderContext,
|
||||
asyncModifier: AsyncMarker.Sync,
|
||||
body: null,
|
||||
superParametersAsArguments: superParametersAsArguments,
|
||||
superParameterArguments: superParameterArguments,
|
||||
fileUri: fileUri,
|
||||
needsImplicitSuperInitializer: needsImplicitSuperInitializer,
|
||||
constantContext: constantContext,
|
||||
@@ -820,7 +824,7 @@ class Resolver {
|
||||
required TypeEnvironment typeEnvironment,
|
||||
required Member target,
|
||||
required TypeArguments? typeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Uri fileUri,
|
||||
required int fileOffset,
|
||||
required bool hasInferredTypeArguments,
|
||||
@@ -976,37 +980,55 @@ class Resolver {
|
||||
);
|
||||
}
|
||||
|
||||
List<Object>? _createSuperParametersAsArguments({
|
||||
_SuperParameterArguments? _createSuperParameterArguments({
|
||||
required AssignedVariables assignedVariables,
|
||||
required List<FormalParameterBuilder> formals,
|
||||
required List<FormalParameterBuilder>? formals,
|
||||
}) {
|
||||
List<Object>? superParametersAsArguments;
|
||||
if (formals == null) {
|
||||
return null;
|
||||
}
|
||||
List<Argument>? superParametersAsArguments;
|
||||
int positionalCount = 0;
|
||||
int? firstPositionalOffset;
|
||||
for (int i = 0; i < formals.length; i++) {
|
||||
FormalParameterBuilder formal = formals[i];
|
||||
if (formal.isSuperInitializingFormal) {
|
||||
if (formal.isNamed) {
|
||||
(superParametersAsArguments ??= <Object>[]).add(
|
||||
new NamedExpression(
|
||||
formal.name,
|
||||
(superParametersAsArguments ??= []).add(
|
||||
new SuperNamedArgument(
|
||||
new NamedExpression(
|
||||
formal.name,
|
||||
_createVariableGet(
|
||||
assignedVariables: assignedVariables,
|
||||
variable: formal.variable as VariableDeclarationImpl,
|
||||
fileOffset: formal.fileOffset,
|
||||
),
|
||||
)..fileOffset = formal.fileOffset,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
positionalCount++;
|
||||
firstPositionalOffset ??= formal.fileOffset;
|
||||
(superParametersAsArguments ??= []).add(
|
||||
new SuperPositionalArgument(
|
||||
_createVariableGet(
|
||||
assignedVariables: assignedVariables,
|
||||
variable: formal.variable as VariableDeclarationImpl,
|
||||
fileOffset: formal.fileOffset,
|
||||
),
|
||||
)..fileOffset = formal.fileOffset,
|
||||
);
|
||||
} else {
|
||||
(superParametersAsArguments ??= <Object>[]).add(
|
||||
_createVariableGet(
|
||||
assignedVariables: assignedVariables,
|
||||
variable: formal.variable as VariableDeclarationImpl,
|
||||
fileOffset: formal.fileOffset,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return superParametersAsArguments;
|
||||
if (superParametersAsArguments == null) {
|
||||
return null;
|
||||
}
|
||||
return new _SuperParameterArguments(
|
||||
superParametersAsArguments,
|
||||
positionalCount: positionalCount,
|
||||
firstPositionalOffset: firstPositionalOffset ?? -1,
|
||||
);
|
||||
}
|
||||
|
||||
/// Helper method to create a [VariableGet] of the [variable] using
|
||||
@@ -1059,10 +1081,7 @@ class Resolver {
|
||||
required TypeInferrer typeInferrer,
|
||||
required Uri fileUri,
|
||||
required List<Initializer> initializers,
|
||||
required Set<String>? namedSuperParameterNames,
|
||||
required List<Expression>? positionalSuperParametersAsArguments,
|
||||
required List<NamedExpression>? namedSuperParametersAsArguments,
|
||||
required List<Object>? superParametersAsArguments,
|
||||
required _SuperParameterArguments? superParameterArguments,
|
||||
required bool needsImplicitSuperInitializer,
|
||||
required AsyncMarker asyncModifier,
|
||||
required int? asyncModifierFileOffset,
|
||||
@@ -1097,10 +1116,11 @@ class Resolver {
|
||||
),
|
||||
)..parent = last.parent;
|
||||
needsImplicitSuperInitializer = false;
|
||||
} else if (libraryFeatures.superParameters.isEnabled) {
|
||||
ArgumentsImpl arguments = last.arguments;
|
||||
if (positionalSuperParametersAsArguments != null) {
|
||||
if (arguments.positional.isNotEmpty) {
|
||||
} else if (superParameterArguments != null) {
|
||||
bool insertNamedOnly = false;
|
||||
ActualArguments arguments = last.arguments;
|
||||
if (superParameterArguments.positionalCount > 0) {
|
||||
if (arguments.positionalCount > 0) {
|
||||
problemReporting.addProblem(
|
||||
codePositionalSuperParametersAndArguments,
|
||||
arguments.fileOffset,
|
||||
@@ -1109,47 +1129,44 @@ class Resolver {
|
||||
context: <LocatedMessage>[
|
||||
codeSuperInitializerParameter.withLocation(
|
||||
fileUri,
|
||||
(positionalSuperParametersAsArguments.first as VariableGet)
|
||||
.variable
|
||||
.fileOffset,
|
||||
superParameterArguments.firstPositionalOffset,
|
||||
noLength,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
arguments.positional.addAll(positionalSuperParametersAsArguments);
|
||||
setParents(positionalSuperParametersAsArguments, arguments);
|
||||
arguments.positionalAreSuperParameters = true;
|
||||
insertNamedOnly = true;
|
||||
}
|
||||
}
|
||||
if (namedSuperParametersAsArguments != null) {
|
||||
// TODO(cstefantsova): Report name conflicts.
|
||||
arguments.named.addAll(namedSuperParametersAsArguments);
|
||||
setParents(namedSuperParametersAsArguments, arguments);
|
||||
arguments.namedSuperParameterNames = namedSuperParameterNames;
|
||||
}
|
||||
if (superParametersAsArguments != null) {
|
||||
arguments.argumentsOriginalOrder?.insertAll(
|
||||
0,
|
||||
superParametersAsArguments,
|
||||
if (insertNamedOnly) {
|
||||
/// Error case: Don't insert positional argument when positional
|
||||
/// arguments already exist.
|
||||
arguments.prependArguments(
|
||||
superParameterArguments.arguments
|
||||
.whereType<NamedArgument>()
|
||||
.toList(),
|
||||
positionalCount: 0,
|
||||
);
|
||||
} else {
|
||||
arguments.prependArguments(
|
||||
superParameterArguments.arguments,
|
||||
positionalCount: superParameterArguments.positionalCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (last is InternalRedirectingInitializer) {
|
||||
if (bodyBuilderContext.isEnumClass &&
|
||||
libraryFeatures.enhancedEnums.isEnabled) {
|
||||
ArgumentsImpl arguments = last.arguments;
|
||||
ActualArguments arguments = last.arguments;
|
||||
List<Expression> enumSyntheticArguments = [
|
||||
new VariableGet(function.positionalParameters[0])
|
||||
..parent = last.arguments,
|
||||
new VariableGet(function.positionalParameters[1])
|
||||
..parent = last.arguments,
|
||||
];
|
||||
arguments.positional.insertAll(0, enumSyntheticArguments);
|
||||
arguments.argumentsOriginalOrder?.insertAll(
|
||||
0,
|
||||
enumSyntheticArguments,
|
||||
);
|
||||
arguments.prependArguments([
|
||||
new PositionalArgument(enumSyntheticArguments[0]),
|
||||
new PositionalArgument(enumSyntheticArguments[1]),
|
||||
], positionalCount: 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1199,12 +1216,12 @@ class Resolver {
|
||||
/// >of the form super() is added at the end of the constructor's
|
||||
/// >initializer list, unless the enclosing class is class Object.
|
||||
Initializer? initializer;
|
||||
ArgumentsImpl arguments;
|
||||
List<Expression>? positionalArguments;
|
||||
List<NamedExpression>? namedArguments;
|
||||
if (libraryFeatures.superParameters.isEnabled) {
|
||||
positionalArguments = positionalSuperParametersAsArguments;
|
||||
namedArguments = namedSuperParametersAsArguments;
|
||||
ActualArguments arguments;
|
||||
List<Argument>? argumentsOriginalOrder;
|
||||
int positionalCount = 0;
|
||||
if (superParameterArguments != null) {
|
||||
argumentsOriginalOrder = superParameterArguments.arguments;
|
||||
positionalCount += superParameterArguments.positionalCount;
|
||||
}
|
||||
if (bodyBuilderContext.isEnumClass) {
|
||||
assert(
|
||||
@@ -1212,22 +1229,23 @@ class Resolver {
|
||||
function.positionalParameters[0].name == "#index" &&
|
||||
function.positionalParameters[1].name == "#name",
|
||||
);
|
||||
(positionalArguments ??= <Expression>[]).insertAll(0, [
|
||||
new VariableGet(function.positionalParameters[0]),
|
||||
new VariableGet(function.positionalParameters[1]),
|
||||
Expression indexExpression = new VariableGet(
|
||||
function.positionalParameters[0],
|
||||
);
|
||||
Expression nameExpression = new VariableGet(
|
||||
function.positionalParameters[1],
|
||||
);
|
||||
(argumentsOriginalOrder ??= []).insertAll(0, [
|
||||
new PositionalArgument(indexExpression),
|
||||
new PositionalArgument(nameExpression),
|
||||
]);
|
||||
positionalCount += 2;
|
||||
}
|
||||
|
||||
int argumentsOffset = -1;
|
||||
if (superParametersAsArguments != null) {
|
||||
for (Object argument in superParametersAsArguments) {
|
||||
assert(argument is Expression || argument is NamedExpression);
|
||||
int currentArgumentOffset;
|
||||
if (argument is Expression) {
|
||||
currentArgumentOffset = argument.fileOffset;
|
||||
} else {
|
||||
currentArgumentOffset = (argument as NamedExpression).fileOffset;
|
||||
}
|
||||
if (superParameterArguments != null) {
|
||||
for (Argument argument in superParameterArguments.arguments) {
|
||||
int currentArgumentOffset = argument.expression.fileOffset;
|
||||
argumentsOffset = argumentsOffset <= currentArgumentOffset
|
||||
? argumentsOffset
|
||||
: currentArgumentOffset;
|
||||
@@ -1246,20 +1264,17 @@ class Resolver {
|
||||
}
|
||||
|
||||
const Forest forest = const Forest();
|
||||
if (positionalArguments != null || namedArguments != null) {
|
||||
if (argumentsOriginalOrder != null) {
|
||||
arguments = forest.createArguments(
|
||||
argumentsOffset,
|
||||
positionalArguments ?? <Expression>[],
|
||||
named: namedArguments,
|
||||
arguments: argumentsOriginalOrder,
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: positionalCount,
|
||||
);
|
||||
} else {
|
||||
arguments = forest.createArgumentsEmpty(argumentsOffset);
|
||||
}
|
||||
|
||||
arguments.positionalAreSuperParameters =
|
||||
positionalSuperParametersAsArguments != null;
|
||||
arguments.namedSuperParameterNames = namedSuperParameterNames;
|
||||
|
||||
MemberLookupResult? result = bodyBuilderContext.lookupSuperConstructor(
|
||||
'',
|
||||
libraryBuilder.nameOriginBuilder,
|
||||
@@ -1318,79 +1333,56 @@ class Resolver {
|
||||
typeParameters: const <TypeParameter>[],
|
||||
)
|
||||
case LocatedMessage argumentIssue) {
|
||||
List<int>? positionalSuperParametersIssueOffsets;
|
||||
if (positionalSuperParametersAsArguments != null) {
|
||||
for (
|
||||
int positionalSuperParameterIndex =
|
||||
superTarget.function.positionalParameters.length;
|
||||
positionalSuperParameterIndex <
|
||||
positionalSuperParametersAsArguments.length;
|
||||
positionalSuperParameterIndex++
|
||||
) {
|
||||
(positionalSuperParametersIssueOffsets ??= []).add(
|
||||
positionalSuperParametersAsArguments[ // force line break
|
||||
positionalSuperParameterIndex]
|
||||
.fileOffset,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
List<int>? namedSuperParametersIssueOffsets;
|
||||
if (namedSuperParametersAsArguments != null) {
|
||||
Initializer? errorMessageInitializer;
|
||||
if (superParameterArguments != null) {
|
||||
int positionalSuperParameterCount =
|
||||
superTarget.function.positionalParameters.length;
|
||||
Set<String> superTargetNamedParameterNames = {
|
||||
for (VariableDeclaration namedParameter
|
||||
in superTarget.function.namedParameters)
|
||||
if (namedParameter // Coverage-ignore(suite): Not run.
|
||||
.name !=
|
||||
null)
|
||||
// Coverage-ignore(suite): Not run.
|
||||
namedParameter.name!,
|
||||
?namedParameter // Coverage-ignore(suite): Not run.
|
||||
.name,
|
||||
};
|
||||
for (NamedExpression namedSuperParameter
|
||||
in namedSuperParametersAsArguments) {
|
||||
if (!superTargetNamedParameterNames.contains(
|
||||
namedSuperParameter.name,
|
||||
)) {
|
||||
(namedSuperParametersIssueOffsets ??= []).add(
|
||||
namedSuperParameter.fileOffset,
|
||||
);
|
||||
int positionalIndex = 0;
|
||||
for (Argument argument in superParameterArguments.arguments) {
|
||||
switch (argument) {
|
||||
case PositionalArgument():
|
||||
if (positionalIndex >= positionalSuperParameterCount) {
|
||||
InvalidExpression errorMessageExpression = problemReporting
|
||||
.buildProblem(
|
||||
compilerContext: compilerContext,
|
||||
message:
|
||||
codeMissingPositionalSuperConstructorParameter,
|
||||
fileUri: fileUri,
|
||||
fileOffset: argument.expression.fileOffset,
|
||||
length: noLength,
|
||||
);
|
||||
errorMessageInitializer ??= _buildInvalidInitializer(
|
||||
errorMessageExpression,
|
||||
);
|
||||
needsImplicitSuperInitializer = false;
|
||||
}
|
||||
positionalIndex++;
|
||||
case NamedArgument():
|
||||
if (!superTargetNamedParameterNames.contains(
|
||||
argument.namedExpression.name,
|
||||
)) {
|
||||
InvalidExpression errorMessageExpression = problemReporting
|
||||
.buildProblem(
|
||||
compilerContext: compilerContext,
|
||||
message: codeMissingNamedSuperConstructorParameter,
|
||||
fileUri: fileUri,
|
||||
fileOffset: argument.namedExpression.fileOffset,
|
||||
length: noLength,
|
||||
);
|
||||
errorMessageInitializer ??= _buildInvalidInitializer(
|
||||
errorMessageExpression,
|
||||
);
|
||||
needsImplicitSuperInitializer = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Initializer? errorMessageInitializer;
|
||||
if (positionalSuperParametersIssueOffsets != null) {
|
||||
for (int issueOffset in positionalSuperParametersIssueOffsets) {
|
||||
InvalidExpression errorMessageExpression = problemReporting
|
||||
.buildProblem(
|
||||
compilerContext: compilerContext,
|
||||
message: codeMissingPositionalSuperConstructorParameter,
|
||||
fileUri: fileUri,
|
||||
fileOffset: issueOffset,
|
||||
length: noLength,
|
||||
);
|
||||
errorMessageInitializer ??= _buildInvalidInitializer(
|
||||
errorMessageExpression,
|
||||
);
|
||||
needsImplicitSuperInitializer = false;
|
||||
}
|
||||
}
|
||||
if (namedSuperParametersIssueOffsets != null) {
|
||||
for (int issueOffset in namedSuperParametersIssueOffsets) {
|
||||
InvalidExpression errorMessageExpression = problemReporting
|
||||
.buildProblem(
|
||||
compilerContext: compilerContext,
|
||||
message: codeMissingNamedSuperConstructorParameter,
|
||||
fileUri: fileUri,
|
||||
fileOffset: issueOffset,
|
||||
length: noLength,
|
||||
);
|
||||
errorMessageInitializer ??= _buildInvalidInitializer(
|
||||
errorMessageExpression,
|
||||
);
|
||||
needsImplicitSuperInitializer = false;
|
||||
}
|
||||
}
|
||||
if (explicitSuperInitializer == null) {
|
||||
errorMessageInitializer ??= _buildInvalidInitializer(
|
||||
problemReporting.buildProblem(
|
||||
@@ -1462,117 +1454,12 @@ class Resolver {
|
||||
required BodyBuilderContext bodyBuilderContext,
|
||||
required AsyncMarker asyncModifier,
|
||||
required Statement? body,
|
||||
required List<Object /* Expression | NamedExpression */>?
|
||||
superParametersAsArguments,
|
||||
required _SuperParameterArguments? superParameterArguments,
|
||||
required Uri fileUri,
|
||||
required bool needsImplicitSuperInitializer,
|
||||
required ConstantContext constantContext,
|
||||
required List<Initializer> initializers,
|
||||
}) {
|
||||
AssignedVariables assignedVariables = context.assignedVariables;
|
||||
|
||||
/// Quotes below are from [Dart Programming Language Specification, 4th
|
||||
/// Edition](
|
||||
/// https://ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf).
|
||||
assert(
|
||||
() {
|
||||
if (superParametersAsArguments == null) {
|
||||
return true;
|
||||
}
|
||||
for (Object superParameterAsArgument in superParametersAsArguments) {
|
||||
if (superParameterAsArgument is! Expression &&
|
||||
superParameterAsArgument is! NamedExpression) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}(),
|
||||
"Expected 'superParametersAsArguments' "
|
||||
"to contain nothing but Expressions and NamedExpressions.",
|
||||
);
|
||||
assert(
|
||||
() {
|
||||
if (superParametersAsArguments == null) {
|
||||
return true;
|
||||
}
|
||||
int previousOffset = -1;
|
||||
for (Object superParameterAsArgument in superParametersAsArguments) {
|
||||
int offset;
|
||||
if (superParameterAsArgument is Expression) {
|
||||
offset = superParameterAsArgument.fileOffset;
|
||||
} else if (superParameterAsArgument is NamedExpression) {
|
||||
offset = superParameterAsArgument.value.fileOffset;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (previousOffset > offset) {
|
||||
return false;
|
||||
}
|
||||
previousOffset = offset;
|
||||
}
|
||||
return true;
|
||||
}(),
|
||||
"Expected 'superParametersAsArguments' "
|
||||
"to be sorted by occurrence in file.",
|
||||
);
|
||||
|
||||
Set<String>? namedSuperParameterNames;
|
||||
List<Expression>? positionalSuperParametersAsArguments;
|
||||
List<NamedExpression>? namedSuperParametersAsArguments;
|
||||
List<FormalParameterBuilder>? formals = bodyBuilderContext.formals;
|
||||
if (superParametersAsArguments != null) {
|
||||
for (Object superParameterAsArgument in superParametersAsArguments) {
|
||||
if (superParameterAsArgument is Expression) {
|
||||
(positionalSuperParametersAsArguments ??= <Expression>[]).add(
|
||||
superParameterAsArgument,
|
||||
);
|
||||
} else {
|
||||
NamedExpression namedSuperParameterAsArgument =
|
||||
superParameterAsArgument as NamedExpression;
|
||||
(namedSuperParametersAsArguments ??= <NamedExpression>[]).add(
|
||||
namedSuperParameterAsArgument,
|
||||
);
|
||||
(namedSuperParameterNames ??= <String>{}).add(
|
||||
namedSuperParameterAsArgument.name,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (formals != null) {
|
||||
for (FormalParameterBuilder formal in formals) {
|
||||
if (formal.isSuperInitializingFormal) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
if (formal.isNamed) {
|
||||
NamedExpression superParameterAsArgument = new NamedExpression(
|
||||
formal.name,
|
||||
_createVariableGet(
|
||||
assignedVariables: assignedVariables,
|
||||
variable: formal.variable as VariableDeclarationImpl,
|
||||
fileOffset: formal.fileOffset,
|
||||
),
|
||||
)..fileOffset = formal.fileOffset;
|
||||
(namedSuperParametersAsArguments ??= <NamedExpression>[]).add(
|
||||
superParameterAsArgument,
|
||||
);
|
||||
(namedSuperParameterNames ??= <String>{}).add(formal.name);
|
||||
(superParametersAsArguments ??= <Object>[]).add(
|
||||
superParameterAsArgument,
|
||||
);
|
||||
} else {
|
||||
Expression superParameterAsArgument = _createVariableGet(
|
||||
assignedVariables: assignedVariables,
|
||||
variable: formal.variable as VariableDeclarationImpl,
|
||||
fileOffset: formal.fileOffset,
|
||||
);
|
||||
(positionalSuperParametersAsArguments ??= <Expression>[]).add(
|
||||
superParameterAsArgument,
|
||||
);
|
||||
(superParametersAsArguments ??= <Object>[]).add(
|
||||
superParameterAsArgument,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_finishInitializers(
|
||||
compilerContext: compilerContext,
|
||||
problemReporting: problemReporting,
|
||||
@@ -1582,11 +1469,7 @@ class Resolver {
|
||||
typeInferrer: context.typeInferrer,
|
||||
fileUri: fileUri,
|
||||
initializers: initializers,
|
||||
namedSuperParameterNames: namedSuperParameterNames,
|
||||
positionalSuperParametersAsArguments:
|
||||
positionalSuperParametersAsArguments,
|
||||
namedSuperParametersAsArguments: namedSuperParametersAsArguments,
|
||||
superParametersAsArguments: superParametersAsArguments,
|
||||
superParameterArguments: superParameterArguments,
|
||||
needsImplicitSuperInitializer: needsImplicitSuperInitializer,
|
||||
asyncModifier: asyncModifier,
|
||||
asyncModifierFileOffset: body?.fileOffset,
|
||||
@@ -1636,16 +1519,11 @@ class Resolver {
|
||||
// Create variable get expressions for super parameters before finishing
|
||||
// the analysis of the assigned variables. Creating the expressions later
|
||||
// that point results in a flow analysis error.
|
||||
List<Object>? superParametersAsArguments;
|
||||
if (formals != null) {
|
||||
List<FormalParameterBuilder>? formalParameters = formals.parameters;
|
||||
if (formalParameters != null) {
|
||||
superParametersAsArguments = _createSuperParametersAsArguments(
|
||||
_SuperParameterArguments? superParameterArguments =
|
||||
_createSuperParameterArguments(
|
||||
assignedVariables: assignedVariables,
|
||||
formals: formalParameters,
|
||||
formals: formals?.parameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
assignedVariables.finish();
|
||||
|
||||
FunctionNode function = bodyBuilderContext.function;
|
||||
@@ -1715,7 +1593,7 @@ class Resolver {
|
||||
bodyBuilderContext: bodyBuilderContext,
|
||||
asyncModifier: asyncModifier,
|
||||
body: body,
|
||||
superParametersAsArguments: superParametersAsArguments,
|
||||
superParameterArguments: superParameterArguments,
|
||||
fileUri: fileUri,
|
||||
needsImplicitSuperInitializer: needsImplicitSuperInitializer,
|
||||
constantContext: constantContext,
|
||||
|
||||
@@ -327,3 +327,18 @@ class _InitializerBuilder {
|
||||
|
||||
List<Initializer> get initializers => _initializers;
|
||||
}
|
||||
|
||||
class _SuperParameterArguments {
|
||||
final List<Argument> arguments;
|
||||
final int positionalCount;
|
||||
final int firstPositionalOffset;
|
||||
|
||||
_SuperParameterArguments(
|
||||
this.arguments, {
|
||||
required this.positionalCount,
|
||||
required this.firstPositionalOffset,
|
||||
});
|
||||
|
||||
// Coverage-ignore(suite): Not run.
|
||||
int get namedCount => arguments.length - positionalCount;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import '../fragment/fragment.dart';
|
||||
import '../source/fragment_factory.dart';
|
||||
import '../source/source_type_parameter_builder.dart';
|
||||
import 'body_builder.dart';
|
||||
import 'internal_ast.dart';
|
||||
|
||||
/// The name for the synthesized field used to store information of
|
||||
/// unserializable exports in a [Library].
|
||||
@@ -364,3 +365,5 @@ class _DummyExtensionScope implements ExtensionScope {
|
||||
@override
|
||||
void forEachExtension(void Function(ExtensionBuilder) f) {}
|
||||
}
|
||||
|
||||
final Argument dummyArgument = new PositionalArgument(dummyExpression);
|
||||
|
||||
@@ -113,7 +113,7 @@ extension CheckHelper on ProblemReporting {
|
||||
LocatedMessage? checkArgumentsForFunction({
|
||||
required FunctionNode function,
|
||||
required TypeArguments? explicitTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required int fileOffset,
|
||||
required Uri fileUri,
|
||||
required List<TypeParameter> typeParameters,
|
||||
@@ -122,7 +122,7 @@ extension CheckHelper on ProblemReporting {
|
||||
int typeParameterCount = typeParameters.length;
|
||||
int requiredParameterCount = function.requiredParameterCount;
|
||||
int positionalParameterCount = function.positionalParameters.length;
|
||||
int positionalArgumentsCount = arguments.positional.length;
|
||||
int positionalArgumentsCount = arguments.positionalCount;
|
||||
if (extension != null) {
|
||||
// Extension member invocations have additional synthetic parameter for
|
||||
// `this`.
|
||||
@@ -140,22 +140,32 @@ extension CheckHelper on ProblemReporting {
|
||||
.withArgumentsOld(positionalParameterCount, positionalArgumentsCount)
|
||||
.withLocation(fileUri, arguments.fileOffset, noLength);
|
||||
}
|
||||
List<NamedExpression> named = arguments.named;
|
||||
if (named.isNotEmpty) {
|
||||
Set<String> argumentNames = {};
|
||||
if (arguments.namedCount > 0) {
|
||||
Set<String?> parameterNames = new Set.of(
|
||||
function.namedParameters.map((a) => a.name),
|
||||
);
|
||||
for (int i = 0; i < named.length; i++) {
|
||||
NamedExpression argument = named[i];
|
||||
if (!parameterNames.contains(argument.name)) {
|
||||
return codeNoSuchNamedParameter
|
||||
.withArgumentsOld(argument.name)
|
||||
.withLocation(fileUri, argument.fileOffset, argument.name.length);
|
||||
for (Argument argument in arguments.argumentList) {
|
||||
switch (argument) {
|
||||
case NamedArgument():
|
||||
NamedExpression namedExpression = argument.namedExpression;
|
||||
String name = namedExpression.name;
|
||||
argumentNames.add(name);
|
||||
if (!parameterNames.contains(name)) {
|
||||
return codeNoSuchNamedParameter
|
||||
.withArgumentsOld(name)
|
||||
.withLocation(
|
||||
fileUri,
|
||||
namedExpression.fileOffset,
|
||||
name.length,
|
||||
);
|
||||
}
|
||||
case PositionalArgument():
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (function.namedParameters.isNotEmpty) {
|
||||
Set<String> argumentNames = new Set.of(named.map((a) => a.name));
|
||||
for (int i = 0; i < function.namedParameters.length; i++) {
|
||||
VariableDeclaration parameter = function.namedParameters[i];
|
||||
if (parameter.isRequired && !argumentNames.contains(parameter.name)) {
|
||||
@@ -165,6 +175,7 @@ extension CheckHelper on ProblemReporting {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (explicitTypeArguments != null) {
|
||||
if (typeParameterCount != explicitTypeArguments.types.length) {
|
||||
// A wrong (non-zero) amount of type arguments given. That's an error.
|
||||
@@ -181,15 +192,15 @@ extension CheckHelper on ProblemReporting {
|
||||
LocatedMessage? checkArgumentsForType({
|
||||
required FunctionType function,
|
||||
required TypeArguments? explicitTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Uri fileUri,
|
||||
required int fileOffset,
|
||||
}) {
|
||||
int requiredPositionalParameterCountToReport =
|
||||
function.requiredParameterCount;
|
||||
int positionalParameterCountToReport = function.positionalParameters.length;
|
||||
int positionalArgumentCountToReport = arguments.positional.length;
|
||||
if (arguments.positional.length < function.requiredParameterCount) {
|
||||
int positionalArgumentCountToReport = arguments.positionalCount;
|
||||
if (positionalArgumentCountToReport < function.requiredParameterCount) {
|
||||
return codeTooFewArguments
|
||||
.withArgumentsOld(
|
||||
requiredPositionalParameterCountToReport,
|
||||
@@ -197,7 +208,8 @@ extension CheckHelper on ProblemReporting {
|
||||
)
|
||||
.withLocation(fileUri, arguments.fileOffset, noLength);
|
||||
}
|
||||
if (arguments.positional.length > function.positionalParameters.length) {
|
||||
if (positionalArgumentCountToReport >
|
||||
function.positionalParameters.length) {
|
||||
return codeTooManyArguments
|
||||
.withArgumentsOld(
|
||||
positionalParameterCountToReport,
|
||||
@@ -205,22 +217,32 @@ extension CheckHelper on ProblemReporting {
|
||||
)
|
||||
.withLocation(fileUri, arguments.fileOffset, noLength);
|
||||
}
|
||||
List<NamedExpression> named = arguments.named;
|
||||
if (named.isNotEmpty) {
|
||||
Set<String> argumentNames = {};
|
||||
if (arguments.namedCount > 0) {
|
||||
Set<String> names = new Set.of(
|
||||
function.namedParameters.map((a) => a.name),
|
||||
);
|
||||
for (int i = 0; i < named.length; i++) {
|
||||
NamedExpression argument = named[i];
|
||||
if (!names.contains(argument.name)) {
|
||||
return codeNoSuchNamedParameter
|
||||
.withArgumentsOld(argument.name)
|
||||
.withLocation(fileUri, argument.fileOffset, argument.name.length);
|
||||
for (Argument argument in arguments.argumentList) {
|
||||
switch (argument) {
|
||||
case NamedArgument():
|
||||
NamedExpression namedExpression = argument.namedExpression;
|
||||
String name = namedExpression.name;
|
||||
argumentNames.add(name);
|
||||
if (!names.contains(name)) {
|
||||
return codeNoSuchNamedParameter
|
||||
.withArgumentsOld(name)
|
||||
.withLocation(
|
||||
fileUri,
|
||||
namedExpression.fileOffset,
|
||||
name.length,
|
||||
);
|
||||
}
|
||||
case PositionalArgument():
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (function.namedParameters.isNotEmpty) {
|
||||
Set<String> argumentNames = new Set.of(named.map((a) => a.name));
|
||||
for (int i = 0; i < function.namedParameters.length; i++) {
|
||||
NamedType parameter = function.namedParameters[i];
|
||||
if (parameter.isRequired && !argumentNames.contains(parameter.name)) {
|
||||
@@ -364,7 +386,7 @@ extension CheckHelper on ProblemReporting {
|
||||
required FunctionType functionType,
|
||||
required String? localName,
|
||||
required List<DartType> explicitOrInferredTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Uri fileUri,
|
||||
required int fileOffset,
|
||||
required bool hasInferredTypeArguments,
|
||||
@@ -462,7 +484,7 @@ extension CheckHelper on ProblemReporting {
|
||||
required Name name,
|
||||
required Member? interfaceTarget,
|
||||
required List<DartType> explicitOrInferredTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required Uri fileUri,
|
||||
required int fileOffset,
|
||||
required bool hasInferredTypeArguments,
|
||||
@@ -718,7 +740,7 @@ extension CheckHelper on ProblemReporting {
|
||||
required CompilerContext compilerContext,
|
||||
required Member target,
|
||||
required TypeArguments? explicitTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required ActualArguments arguments,
|
||||
required int fileOffset,
|
||||
required Uri fileUri,
|
||||
}) {
|
||||
|
||||
@@ -45,10 +45,11 @@ class ValueKinds {
|
||||
const SingleValueKind<List<type.Expression>>();
|
||||
static const ValueKind AnnotationListOrNull =
|
||||
const SingleValueKind<List<type.Expression>>(NullValues.Metadata);
|
||||
static const ValueKind Argument = const SingleValueKind<type.Argument>();
|
||||
static const ValueKind Arguments =
|
||||
const SingleValueKind<type.ArgumentsImpl>();
|
||||
const SingleValueKind<type.ActualArguments>();
|
||||
static const ValueKind ArgumentsOrNull =
|
||||
const SingleValueKind<type.ArgumentsImpl>(NullValues.Arguments);
|
||||
const SingleValueKind<type.ActualArguments>(NullValues.Arguments);
|
||||
static const ValueKind ArgumentsTokenOrNull =
|
||||
const SingleValueKind<type.Token>(NullValues.Arguments);
|
||||
static const ValueKind AssignedVariablesNodeInfo =
|
||||
|
||||
@@ -114,6 +114,12 @@ abstract class InvocationInferenceResult {
|
||||
/// The explicit or inferred type arguments.
|
||||
List<DartType> get typeArguments;
|
||||
|
||||
/// The positional arguments.
|
||||
List<Expression> get positional;
|
||||
|
||||
/// The named arguments.
|
||||
List<NamedExpression> get named;
|
||||
|
||||
/// Applies the result of the inference to the expression being inferred.
|
||||
///
|
||||
/// A successful result leaves [expression] intact, and an error detected
|
||||
@@ -160,12 +166,20 @@ class SuccessfulInferenceResult implements InvocationInferenceResult {
|
||||
|
||||
final List<VariableDeclaration>? hoistedArguments;
|
||||
|
||||
@override
|
||||
final List<Expression> positional;
|
||||
|
||||
@override
|
||||
final List<NamedExpression> named;
|
||||
|
||||
final DartType? inferredReceiverType;
|
||||
|
||||
SuccessfulInferenceResult(
|
||||
this.inferredType,
|
||||
this.functionType,
|
||||
this.typeArguments, {
|
||||
SuccessfulInferenceResult({
|
||||
required this.inferredType,
|
||||
required this.functionType,
|
||||
required this.typeArguments,
|
||||
required this.positional,
|
||||
required this.named,
|
||||
required this.hoistedArguments,
|
||||
this.inferredReceiverType,
|
||||
});
|
||||
@@ -296,12 +310,20 @@ class WrapInProblemInferenceResult implements InvocationInferenceResult {
|
||||
|
||||
final List<VariableDeclaration>? hoistedArguments;
|
||||
|
||||
WrapInProblemInferenceResult(
|
||||
this.message,
|
||||
this.problemReporting,
|
||||
this.compilerContext, {
|
||||
@override
|
||||
final List<Expression> positional;
|
||||
|
||||
@override
|
||||
final List<NamedExpression> named;
|
||||
|
||||
WrapInProblemInferenceResult({
|
||||
required this.message,
|
||||
required this.problemReporting,
|
||||
required this.compilerContext,
|
||||
required this.isInapplicable,
|
||||
required this.hoistedArguments,
|
||||
required this.positional,
|
||||
required this.named,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -1460,7 +1460,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
) {
|
||||
ensureMemberType(node.target);
|
||||
TypeArguments? typeArguments = node.typeArguments;
|
||||
ArgumentsImpl arguments = node.arguments;
|
||||
ActualArguments arguments = node.arguments;
|
||||
bool hasInferredTypeArguments = typeArguments == null;
|
||||
FunctionType functionType = node.target.function.computeThisFunctionType(
|
||||
Nullability.nonNullable,
|
||||
@@ -1488,7 +1488,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
}
|
||||
Expression replacement = createConstructorInvocation(
|
||||
node.target,
|
||||
createArgumentsFromInternalNode(result.typeArguments, arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
arguments,
|
||||
),
|
||||
fileOffset: node.fileOffset,
|
||||
isConst: node.isConst,
|
||||
);
|
||||
@@ -2115,11 +2120,13 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
);
|
||||
|
||||
StaticInvocation replacement = createExtensionInvocation(
|
||||
node.fileOffset,
|
||||
target,
|
||||
receiver,
|
||||
result.typeArguments,
|
||||
node.arguments,
|
||||
invocationOffset: node.fileOffset,
|
||||
argumentsOffset: node.arguments.fileOffset,
|
||||
target: target,
|
||||
receiver: receiver,
|
||||
explicitOrInferredTypeArguments: result.typeArguments,
|
||||
positionalArguments: result.positional,
|
||||
namedArguments: result.named,
|
||||
);
|
||||
|
||||
return new ExpressionInferenceResult(
|
||||
@@ -2562,6 +2569,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
Expression resolvedExpression = _resolveRedirectingFactoryTarget(
|
||||
target: node.target,
|
||||
explicitOrInferredTypeArguments: result.typeArguments,
|
||||
positional: result.positional,
|
||||
named: result.named,
|
||||
arguments: node.arguments,
|
||||
fileOffset: node.fileOffset,
|
||||
isConst: node.isConst,
|
||||
@@ -2581,7 +2590,9 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
Expression? _resolveRedirectingFactoryTarget({
|
||||
required Procedure target,
|
||||
required List<DartType> explicitOrInferredTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required List<Expression> positional,
|
||||
required List<NamedExpression> named,
|
||||
required ActualArguments arguments,
|
||||
required int fileOffset,
|
||||
required bool isConst,
|
||||
required bool hasInferredTypeArguments,
|
||||
@@ -2622,6 +2633,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
: null,
|
||||
effectiveTarget: resolvedTarget,
|
||||
explicitOrInferredTypeArguments: typeArguments,
|
||||
positional: positional,
|
||||
named: named,
|
||||
arguments: arguments,
|
||||
isConst: isConst,
|
||||
fileOffset: fileOffset,
|
||||
@@ -2635,7 +2648,9 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
required Procedure? redirectingFactoryTarget,
|
||||
required Member effectiveTarget,
|
||||
required List<DartType> explicitOrInferredTypeArguments,
|
||||
required ArgumentsImpl arguments,
|
||||
required List<Expression> positional,
|
||||
required List<NamedExpression> named,
|
||||
required ActualArguments arguments,
|
||||
required bool isConst,
|
||||
required int fileOffset,
|
||||
required bool hasInferredTypeArguments,
|
||||
@@ -2675,6 +2690,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
effectiveTarget,
|
||||
createArgumentsFromInternalNode(
|
||||
explicitOrInferredTypeArguments,
|
||||
positional,
|
||||
named,
|
||||
arguments,
|
||||
),
|
||||
isConst: isConst,
|
||||
@@ -2725,6 +2742,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
effectiveTarget,
|
||||
createArgumentsFromInternalNode(
|
||||
explicitOrInferredTypeArguments,
|
||||
positional,
|
||||
named,
|
||||
arguments,
|
||||
),
|
||||
isConst: isConst,
|
||||
@@ -2893,6 +2912,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
_unaliasSingleTypeAliasedConstructorInvocation(
|
||||
node,
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
);
|
||||
Expression resultingExpression = result.applyResult(resolvedExpression);
|
||||
|
||||
@@ -2905,6 +2926,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
Expression _unaliasSingleTypeAliasedConstructorInvocation(
|
||||
TypeAliasedConstructorInvocation node,
|
||||
List<DartType> explicitOrInferredTypeArguments,
|
||||
List<Expression> positional,
|
||||
List<NamedExpression> named,
|
||||
) {
|
||||
DartType aliasedType = new TypedefType(
|
||||
node.typeAliasBuilder.typedef,
|
||||
@@ -2926,9 +2949,9 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
invocationTypeArguments = unaliasedType.typeArguments.toList();
|
||||
}
|
||||
Arguments invocationArguments = new Arguments(
|
||||
node.arguments.positional,
|
||||
positional,
|
||||
types: invocationTypeArguments,
|
||||
named: node.arguments.named,
|
||||
named: named,
|
||||
)..fileOffset = node.arguments.fileOffset;
|
||||
return new ConstructorInvocation(
|
||||
node.target,
|
||||
@@ -3026,6 +3049,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
Expression resolvedExpression = _unaliasSingleTypeAliasedFactoryInvocation(
|
||||
node,
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
)!;
|
||||
Expression resultExpression = result.applyResult(resolvedExpression);
|
||||
|
||||
@@ -3036,6 +3061,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
Expression? _unaliasSingleTypeAliasedFactoryInvocation(
|
||||
TypeAliasedFactoryInvocation node,
|
||||
List<DartType> explicitOrInferredTypeArguments,
|
||||
List<Expression> positional,
|
||||
List<NamedExpression> named,
|
||||
) {
|
||||
bool hasInferredTypeArguments = node.typeArguments == null;
|
||||
DartType aliasedType = new TypedefType(
|
||||
@@ -3062,6 +3089,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
explicitOrInferredTypeArguments:
|
||||
invocationTypeArguments ?? // Coverage-ignore(suite): Not run.
|
||||
[],
|
||||
positional: positional,
|
||||
named: named,
|
||||
arguments: node.arguments,
|
||||
fileOffset: node.fileOffset,
|
||||
isConst: node.isConst,
|
||||
@@ -8421,7 +8450,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
);
|
||||
StaticInvocation invocation = new StaticInvocation(
|
||||
member,
|
||||
createArgumentsFromInternalNode(result.typeArguments, node.arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
node.arguments,
|
||||
),
|
||||
);
|
||||
String targetName = member.name.text;
|
||||
if (member.enclosingClass != null) {
|
||||
@@ -12335,7 +12369,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
ensureMemberType(node.target);
|
||||
List<TypeParameter> classTypeParameters =
|
||||
node.target.enclosingClass.typeParameters;
|
||||
ArgumentsImpl arguments = node.arguments;
|
||||
ActualArguments arguments = node.arguments;
|
||||
// The redirecting initializer syntax doesn't include type arguments passed
|
||||
// to the target constructor so we synthesize them for calling
|
||||
// [inferInvocation].
|
||||
@@ -12386,7 +12420,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
result ??
|
||||
(new RedirectingInitializer(
|
||||
node.target,
|
||||
createArgumentsFromInternalNode([], arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
[],
|
||||
inferenceResult.positional,
|
||||
inferenceResult.named,
|
||||
arguments,
|
||||
),
|
||||
)..fileOffset = node.fileOffset),
|
||||
inferenceResult,
|
||||
);
|
||||
@@ -12425,6 +12464,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
staticTarget: node.target,
|
||||
);
|
||||
node.inferredTypeArguments = inferenceResult.typeArguments;
|
||||
node.positional = inferenceResult.positional;
|
||||
node.named = inferenceResult.named;
|
||||
|
||||
LocatedMessage? message = problemReporting.checkArgumentsForFunction(
|
||||
function: node.target.function,
|
||||
@@ -12720,7 +12761,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
FunctionType calleeType = node.target.function.computeFunctionType(
|
||||
Nullability.nonNullable,
|
||||
);
|
||||
ArgumentsImpl arguments = node.arguments;
|
||||
ActualArguments arguments = node.arguments;
|
||||
InvocationInferenceResult result = inferInvocation(
|
||||
this,
|
||||
typeContext,
|
||||
@@ -12747,7 +12788,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
);
|
||||
Expression replacement = createStaticInvocation(
|
||||
node.target,
|
||||
createArgumentsFromInternalNode(result.typeArguments, arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
arguments,
|
||||
),
|
||||
fileOffset: node.fileOffset,
|
||||
);
|
||||
flowAnalysis.forwardExpression(replacement, node);
|
||||
@@ -12848,7 +12894,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
result ??
|
||||
(new SuperInitializer(
|
||||
node.target,
|
||||
createArgumentsFromInternalNode([], node.arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
[],
|
||||
inferenceResult.positional,
|
||||
inferenceResult.named,
|
||||
node.arguments,
|
||||
),
|
||||
)
|
||||
..fileOffset = node.fileOffset
|
||||
..isSynthetic = node.isSynthetic),
|
||||
@@ -16335,7 +16386,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
);
|
||||
expr = new StaticInvocation(
|
||||
member,
|
||||
createArgumentsFromInternalNode(result.typeArguments, node.arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
node.arguments,
|
||||
),
|
||||
)..fileOffset = node.fileOffset;
|
||||
return new ExpressionInferenceResult(
|
||||
result.inferredType,
|
||||
@@ -16411,7 +16467,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
);
|
||||
expr = new ConstructorInvocation(
|
||||
constructor,
|
||||
createArgumentsFromInternalNode(result.typeArguments, node.arguments),
|
||||
createArgumentsFromInternalNode(
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
node.arguments,
|
||||
),
|
||||
isConst: node.isConst,
|
||||
)..fileOffset = node.fileOffset;
|
||||
return new ExpressionInferenceResult(
|
||||
@@ -16453,6 +16514,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
expr = _resolveRedirectingFactoryTarget(
|
||||
target: constructor,
|
||||
explicitOrInferredTypeArguments: result.typeArguments,
|
||||
positional: result.positional,
|
||||
named: result.named,
|
||||
arguments: node.arguments,
|
||||
fileOffset: node.fileOffset,
|
||||
isConst: node.isConst,
|
||||
@@ -16463,6 +16526,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
constructor,
|
||||
createArgumentsFromInternalNode(
|
||||
result.typeArguments,
|
||||
result.positional,
|
||||
result.named,
|
||||
node.arguments,
|
||||
),
|
||||
isConst: node.isConst,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -142,7 +142,7 @@ sealed class InvocationTargetType {
|
||||
/// [typeArguments] and [arguments].
|
||||
FunctionType computeFunctionTypeForInference(
|
||||
List<DartType>? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class InvocationTargetFunctionType extends InvocationTargetType {
|
||||
@override
|
||||
FunctionType computeFunctionTypeForInference(
|
||||
List<DartType>? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
) {
|
||||
return functionType;
|
||||
}
|
||||
@@ -285,19 +285,18 @@ sealed class InvocationTargetNonFunctionType extends InvocationTargetType {
|
||||
@override
|
||||
FunctionType computeFunctionTypeForInference(
|
||||
List<DartType>? typeArguments,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
) {
|
||||
return new FunctionType(
|
||||
new List<DartType>.filled(
|
||||
arguments.positional.length,
|
||||
const DynamicType(),
|
||||
),
|
||||
new List<DartType>.filled(arguments.positionalCount, const DynamicType()),
|
||||
this.returnType,
|
||||
Nullability.nonNullable,
|
||||
namedParameters: <NamedType>[
|
||||
for (NamedExpression namedExpression in arguments.named)
|
||||
new NamedType(namedExpression.name, const DynamicType()),
|
||||
],
|
||||
namedParameters: arguments.namedCount > 0
|
||||
? arguments.argumentList
|
||||
.whereType<NamedArgument>()
|
||||
.map((a) => new NamedType(a.name, const DynamicType()))
|
||||
.toList()
|
||||
: [],
|
||||
typeParameters: [
|
||||
if (typeArguments != null)
|
||||
for (DartType _ in typeArguments)
|
||||
|
||||
@@ -269,7 +269,8 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
required FunctionType targetType,
|
||||
}) {
|
||||
InferenceVisitorBase visitor = _createInferenceVisitor(fileUri: fileUri);
|
||||
List<Expression> positionalArguments = <Expression>[];
|
||||
List<Argument> arguments = [];
|
||||
int positionalCount = 0;
|
||||
for (VariableDeclaration parameter
|
||||
in redirectingFactoryFunction.positionalParameters) {
|
||||
flowAnalysis.declare(
|
||||
@@ -277,9 +278,10 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
new SharedTypeView(parameter.type),
|
||||
initialized: true,
|
||||
);
|
||||
positionalArguments.add(new VariableGet(parameter));
|
||||
Expression variableGet = new VariableGet(parameter);
|
||||
arguments.add(new PositionalArgument(variableGet));
|
||||
positionalCount++;
|
||||
}
|
||||
List<NamedExpression> namedArguments = <NamedExpression>[];
|
||||
for (VariableDeclaration parameter
|
||||
in redirectingFactoryFunction.namedParameters) {
|
||||
flowAnalysis.declare(
|
||||
@@ -287,15 +289,18 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
new SharedTypeView(parameter.type),
|
||||
initialized: true,
|
||||
);
|
||||
namedArguments.add(
|
||||
new NamedExpression(parameter.name!, new VariableGet(parameter)),
|
||||
NamedExpression namedExpression = new NamedExpression(
|
||||
parameter.name!,
|
||||
new VariableGet(parameter),
|
||||
);
|
||||
arguments.add(new NamedArgument(namedExpression));
|
||||
}
|
||||
// If arguments are created using [ArgumentsImpl], and the
|
||||
// type arguments are omitted, they are to be inferred.
|
||||
ArgumentsImpl targetInvocationArguments = new ArgumentsImpl(
|
||||
positionalArguments,
|
||||
named: namedArguments,
|
||||
ActualArguments targetInvocationArguments = new ActualArguments(
|
||||
argumentList: arguments,
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: positionalCount,
|
||||
)..fileOffset = fileOffset;
|
||||
|
||||
InvocationInferenceResult result = visitor.inferInvocation(
|
||||
|
||||
@@ -246,7 +246,7 @@ mixin BodyBuilderTestMixin on BodyBuilderImpl {
|
||||
TypeDeclarationBuilder? type,
|
||||
Token nameToken,
|
||||
Token nameLastToken,
|
||||
ArgumentsImpl arguments,
|
||||
ActualArguments arguments,
|
||||
String name,
|
||||
List<TypeBuilder>? typeArgumentBuilders,
|
||||
TypeArguments? typeArguments,
|
||||
|
||||
@@ -76,7 +76,12 @@ Future<void> main() async {
|
||||
CoreTypes coreTypes = new CoreTypes(component);
|
||||
ClassHierarchy hierarchy = new ClassHierarchy(component, coreTypes);
|
||||
|
||||
ArgumentsImpl arguments = new ArgumentsImpl([new StringLiteral("arg")]);
|
||||
Expression argument = new StringLiteral("arg");
|
||||
ActualArguments arguments = new ActualArguments(
|
||||
argumentList: [new PositionalArgument(argument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
);
|
||||
Expression expression = new VariableGet(
|
||||
new VariableDeclaration("expression"),
|
||||
);
|
||||
|
||||
+199
-63
@@ -648,7 +648,7 @@ void _testFactoryConstructorInvocation() {
|
||||
new FactoryConstructorInvocation(
|
||||
factoryConstructor,
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isConst: false,
|
||||
),
|
||||
'''
|
||||
@@ -661,7 +661,7 @@ new library test:dummy::Class()''',
|
||||
new FactoryConstructorInvocation(
|
||||
factoryConstructor,
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isConst: true,
|
||||
),
|
||||
'''
|
||||
@@ -670,13 +670,20 @@ const Class()''',
|
||||
const library test:dummy::Class()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(0);
|
||||
NamedExpression namedArgument = new NamedExpression('bar', new IntLiteral(1));
|
||||
|
||||
testExpression(
|
||||
new FactoryConstructorInvocation(
|
||||
factoryConstructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isConst: false,
|
||||
),
|
||||
@@ -691,9 +698,13 @@ new library test:dummy::Class<void>(0, bar: 1)''',
|
||||
new FactoryConstructorInvocation(
|
||||
factoryConstructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isConst: false,
|
||||
),
|
||||
@@ -746,7 +757,7 @@ void _testTypeAliasedConstructorInvocation(CompilerContext c) {
|
||||
typeAliasBuilder,
|
||||
constructor,
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
),
|
||||
'''
|
||||
new Typedef()''',
|
||||
@@ -754,14 +765,21 @@ new Typedef()''',
|
||||
new library test:dummy::Typedef()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(0);
|
||||
NamedExpression namedArgument = new NamedExpression('bar', new IntLiteral(1));
|
||||
|
||||
testExpression(
|
||||
new TypeAliasedConstructorInvocation(
|
||||
typeAliasBuilder,
|
||||
constructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
@@ -776,9 +794,13 @@ new library test:dummy::Typedef<void>(0, bar: 1)''',
|
||||
typeAliasBuilder,
|
||||
constructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
@@ -793,9 +815,13 @@ new library test:dummy::Typedef<void>.foo(0, bar: 1)''',
|
||||
typeAliasBuilder,
|
||||
constructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isConst: true,
|
||||
),
|
||||
@@ -849,7 +875,7 @@ void _testTypeAliasedFactoryInvocation(CompilerContext c) {
|
||||
typeAliasBuilder,
|
||||
factoryConstructor,
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isConst: false,
|
||||
),
|
||||
'''
|
||||
@@ -858,14 +884,21 @@ new Typedef()''',
|
||||
new library test:dummy::Typedef()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(0);
|
||||
NamedExpression namedArgument = new NamedExpression('bar', new IntLiteral(1));
|
||||
|
||||
testExpression(
|
||||
new TypeAliasedFactoryInvocation(
|
||||
typeAliasBuilder,
|
||||
factoryConstructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isConst: false,
|
||||
),
|
||||
@@ -881,9 +914,13 @@ new library test:dummy::Typedef<void>(0, bar: 1)''',
|
||||
typeAliasBuilder,
|
||||
factoryConstructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isConst: false,
|
||||
),
|
||||
@@ -899,9 +936,13 @@ new library test:dummy::Typedef<void>.foo(0, bar: 1)''',
|
||||
typeAliasBuilder,
|
||||
factoryConstructor,
|
||||
new TypeArguments([const VoidType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(0)],
|
||||
named: [new NamedExpression('bar', new IntLiteral(1))],
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isConst: true,
|
||||
),
|
||||
@@ -943,23 +984,36 @@ void _testInternalMethodInvocation() {
|
||||
new IntLiteral(0),
|
||||
new Name('boz'),
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isNullAware: false,
|
||||
),
|
||||
'''
|
||||
0.boz()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(1);
|
||||
NamedExpression namedArgument1 = new NamedExpression(
|
||||
'foo',
|
||||
new IntLiteral(2),
|
||||
);
|
||||
NamedExpression namedArgument2 = new NamedExpression(
|
||||
'bar',
|
||||
new IntLiteral(3),
|
||||
);
|
||||
|
||||
testExpression(
|
||||
new MethodInvocation(
|
||||
new IntLiteral(0),
|
||||
new Name('boz'),
|
||||
new TypeArguments([const VoidType(), const DynamicType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(1)],
|
||||
named: [
|
||||
new NamedExpression('foo', new IntLiteral(2)),
|
||||
new NamedExpression('bar', new IntLiteral(3)),
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument1),
|
||||
new NamedArgument(namedArgument2),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: false,
|
||||
),
|
||||
@@ -971,7 +1025,7 @@ void _testInternalMethodInvocation() {
|
||||
new IntLiteral(0),
|
||||
new Name('boz'),
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isNullAware: true,
|
||||
),
|
||||
'''
|
||||
@@ -982,12 +1036,14 @@ void _testInternalMethodInvocation() {
|
||||
new IntLiteral(0),
|
||||
new Name('boz'),
|
||||
new TypeArguments([const VoidType(), const DynamicType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(1)],
|
||||
named: [
|
||||
new NamedExpression('foo', new IntLiteral(2)),
|
||||
new NamedExpression('bar', new IntLiteral(3)),
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument1),
|
||||
new NamedArgument(namedArgument2),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: true,
|
||||
),
|
||||
@@ -1040,20 +1096,37 @@ void _testPropertySet() {
|
||||
|
||||
void _testExpressionInvocation() {
|
||||
testExpression(
|
||||
new ExpressionInvocation(new IntLiteral(0), null, new ArgumentsImpl([])),
|
||||
new ExpressionInvocation(
|
||||
new IntLiteral(0),
|
||||
null,
|
||||
new ActualArguments.empty(),
|
||||
),
|
||||
'''
|
||||
0()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(1);
|
||||
NamedExpression namedArgument1 = new NamedExpression(
|
||||
'foo',
|
||||
new IntLiteral(2),
|
||||
);
|
||||
NamedExpression namedArgument2 = new NamedExpression(
|
||||
'bar',
|
||||
new IntLiteral(3),
|
||||
);
|
||||
|
||||
testExpression(
|
||||
new ExpressionInvocation(
|
||||
new IntLiteral(0),
|
||||
new TypeArguments([const VoidType(), const DynamicType()]),
|
||||
new ArgumentsImpl(
|
||||
[new IntLiteral(1)],
|
||||
named: [
|
||||
new NamedExpression('foo', new IntLiteral(2)),
|
||||
new NamedExpression('bar', new IntLiteral(3)),
|
||||
new ActualArguments(
|
||||
argumentList: [
|
||||
new PositionalArgument(positionalArgument),
|
||||
new NamedArgument(namedArgument1),
|
||||
new NamedArgument(namedArgument2),
|
||||
],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
@@ -1067,7 +1140,7 @@ void _testMethodInvocation() {
|
||||
new IntLiteral(0),
|
||||
new Name('foo'),
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isNullAware: false,
|
||||
),
|
||||
'''
|
||||
@@ -1079,7 +1152,7 @@ void _testMethodInvocation() {
|
||||
new IntLiteral(0),
|
||||
new Name('foo'),
|
||||
null,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
isNullAware: true,
|
||||
),
|
||||
'''
|
||||
@@ -1155,10 +1228,23 @@ void _testLoadLibraryImpl() {
|
||||
library,
|
||||
'pre',
|
||||
);
|
||||
testExpression(new LoadLibraryImpl(dependency, new ArgumentsImpl([])), '''
|
||||
pre.loadLibrary()''');
|
||||
testExpression(
|
||||
new LoadLibraryImpl(dependency, new ArgumentsImpl([new IntLiteral(0)])),
|
||||
new LoadLibraryImpl(dependency, new ActualArguments.empty()),
|
||||
'''
|
||||
pre.loadLibrary()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(0);
|
||||
|
||||
testExpression(
|
||||
new LoadLibraryImpl(
|
||||
dependency,
|
||||
new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
pre.loadLibrary(0)''',
|
||||
);
|
||||
@@ -2645,6 +2731,8 @@ void _testExtensionGetterInvocation() {
|
||||
);
|
||||
library.addProcedure(method);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(1);
|
||||
|
||||
testExpression(
|
||||
new ExtensionGetterInvocation.explicit(
|
||||
extension: extension,
|
||||
@@ -2654,7 +2742,11 @@ void _testExtensionGetterInvocation() {
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: false,
|
||||
),
|
||||
'''
|
||||
@@ -2670,7 +2762,11 @@ Extension(0).foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: true,
|
||||
),
|
||||
'''
|
||||
@@ -2686,7 +2782,11 @@ Extension(0)?.foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: false,
|
||||
),
|
||||
'''
|
||||
@@ -2702,7 +2802,11 @@ Extension<void>(0).foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: true,
|
||||
),
|
||||
'''
|
||||
@@ -2722,7 +2826,11 @@ Extension<void>(0)?.foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
0.foo(1)''',
|
||||
@@ -2746,6 +2854,8 @@ void _testExtensionMethodInvocation() {
|
||||
);
|
||||
library.addProcedure(method);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(1);
|
||||
|
||||
testExpression(
|
||||
new ExtensionMethodInvocation.explicit(
|
||||
extension: extension,
|
||||
@@ -2755,7 +2865,11 @@ void _testExtensionMethodInvocation() {
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: false,
|
||||
),
|
||||
'''
|
||||
@@ -2771,7 +2885,11 @@ Extension(0).foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: true,
|
||||
),
|
||||
'''
|
||||
@@ -2787,7 +2905,11 @@ Extension(0)?.foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: false,
|
||||
),
|
||||
'''
|
||||
@@ -2803,7 +2925,11 @@ Extension<void>(0).foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
isNullAware: true,
|
||||
),
|
||||
'''
|
||||
@@ -2823,7 +2949,11 @@ Extension<void>(0)?.foo(1)''',
|
||||
name: name,
|
||||
target: method,
|
||||
typeArguments: null,
|
||||
arguments: new ArgumentsImpl([new IntLiteral(1)]),
|
||||
arguments: new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
0.foo(1)''',
|
||||
@@ -3533,16 +3663,22 @@ void _testExtensionTypeRedirectingInitializer() {
|
||||
testInitializer(
|
||||
new ExtensionTypeRedirectingInitializer(
|
||||
unnamedTarget,
|
||||
new ArgumentsImpl([]),
|
||||
new ActualArguments.empty(),
|
||||
),
|
||||
'''
|
||||
this()''',
|
||||
);
|
||||
|
||||
Expression positionalArgument = new IntLiteral(0);
|
||||
|
||||
testInitializer(
|
||||
new ExtensionTypeRedirectingInitializer(
|
||||
namedTarget,
|
||||
new ArgumentsImpl([new IntLiteral(0)]),
|
||||
new ActualArguments(
|
||||
argumentList: [new PositionalArgument(positionalArgument)],
|
||||
hasNamedBeforePositional: false,
|
||||
positionalCount: 1,
|
||||
),
|
||||
),
|
||||
'''
|
||||
this.named(0)''',
|
||||
|
||||
@@ -9,7 +9,7 @@ class Super extends core::Object {
|
||||
}
|
||||
class SubNamed extends self::Super {
|
||||
constructor namedAnywhere(core::double x, core::String z, {core::bool y = #C1}) → self::SubNamed
|
||||
: final core::String #t1 = z, final core::bool #t2 = y, super self::Super::named(x, z: #t1, y: #t2)
|
||||
: final core::bool #t1 = y, final core::String #t2 = z, super self::Super::named(x, y: #t1, z: #t2)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class Super extends core::Object {
|
||||
}
|
||||
class SubNamed extends self::Super {
|
||||
constructor namedAnywhere(core::double x, core::String z, {core::bool y = #C1}) → self::SubNamed
|
||||
: final core::String #t1 = z, final core::bool #t2 = y, super self::Super::named(x, z: #t1, y: #t2)
|
||||
: final core::bool #t1 = y, final core::String #t2 = z, super self::Super::named(x, y: #t1, z: #t2)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class Super extends core::Object {
|
||||
}
|
||||
class SubNamed extends self::Super {
|
||||
constructor namedAnywhere(core::double x, core::String z, {core::bool y = #C1}) → self::SubNamed
|
||||
: final core::String #t1 = z, final core::bool #t2 = y, super self::Super::named(x, z: #t1, y: #t2)
|
||||
: final core::bool #t1 = y, final core::String #t2 = z, super self::Super::named(x, y: #t1, z: #t2)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -20,12 +20,9 @@ library;
|
||||
// c.instance2(z:z,,);
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: No named parameter with the name '#1'.
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: Too many positional arguments: 0 allowed, but 1 found.
|
||||
// Try removing the extra positional arguments.
|
||||
// c.instance1(z:z,,);
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:20:16: Error: Too few positional arguments: 1 required, 0 given.
|
||||
// c.instance2(z:z,,);
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
@@ -43,16 +40,15 @@ class Bad extends core::Object {
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: No named parameter with the name '#1'.
|
||||
let final core::int #t1 = self::z in invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: Too many positional arguments: 0 allowed, but 1 found.
|
||||
Try removing the extra positional arguments.
|
||||
c.instance1(z:z,,);
|
||||
^^" in self::c.{self::C::instance1}{<inapplicable>}.(z: self::z, #1: invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:21: Error: Expected named argument.
|
||||
^" in self::c.{self::C::instance1}{<inapplicable>}.(invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:21: Error: This couldn't be parsed.
|
||||
c.instance1(z:z,,);
|
||||
^"){({z: invalid-type, #1: invalid-type}) → invalid-type};
|
||||
invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:16: Error: Too few positional arguments: 1 required, 0 given.
|
||||
^", z: #t1){(invalid-type, {z: invalid-type}) → invalid-type};
|
||||
let final self::C #t2 = self::c in let final core::int #t3 = self::z in #t2.{self::C::instance2}(invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:21: Error: This couldn't be parsed.
|
||||
c.instance2(z:z,,);
|
||||
^" in self::c.{self::C::instance2}{<inapplicable>}.(z: self::z, #1: invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:21: Error: Expected named argument.
|
||||
c.instance2(z:z,,);
|
||||
^"){({z: invalid-type, #1: invalid-type}) → invalid-type};
|
||||
^", z: #t3){(dynamic, {z: dynamic}) → void};
|
||||
}
|
||||
}
|
||||
static field self::C c = new self::C::•();
|
||||
|
||||
@@ -20,12 +20,9 @@ library;
|
||||
// c.instance2(z:z,,);
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: No named parameter with the name '#1'.
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: Too many positional arguments: 0 allowed, but 1 found.
|
||||
// Try removing the extra positional arguments.
|
||||
// c.instance1(z:z,,);
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:20:16: Error: Too few positional arguments: 1 required, 0 given.
|
||||
// c.instance2(z:z,,);
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
@@ -43,16 +40,15 @@ class Bad extends core::Object {
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: No named parameter with the name '#1'.
|
||||
let final core::int #t1 = self::z in invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: Too many positional arguments: 0 allowed, but 1 found.
|
||||
Try removing the extra positional arguments.
|
||||
c.instance1(z:z,,);
|
||||
^^" in self::c.{self::C::instance1}{<inapplicable>}.(z: self::z, #1: invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:21: Error: Expected named argument.
|
||||
^" in self::c.{self::C::instance1}{<inapplicable>}.(invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:21: Error: This couldn't be parsed.
|
||||
c.instance1(z:z,,);
|
||||
^"){({z: invalid-type, #1: invalid-type}) → invalid-type};
|
||||
invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:16: Error: Too few positional arguments: 1 required, 0 given.
|
||||
^", z: #t1){(invalid-type, {z: invalid-type}) → invalid-type};
|
||||
let final self::C #t2 = self::c in let final core::int #t3 = self::z in #t2.{self::C::instance2}(invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:21: Error: This couldn't be parsed.
|
||||
c.instance2(z:z,,);
|
||||
^" in self::c.{self::C::instance2}{<inapplicable>}.(z: self::z, #1: invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:21: Error: Expected named argument.
|
||||
c.instance2(z:z,,);
|
||||
^"){({z: invalid-type, #1: invalid-type}) → invalid-type};
|
||||
^", z: #t3){(dynamic, {z: dynamic}) → void};
|
||||
}
|
||||
}
|
||||
static field self::C c = new self::C::•();
|
||||
|
||||
@@ -20,12 +20,9 @@ library;
|
||||
// c.instance2(z:z,,);
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: No named parameter with the name '#1'.
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: Too many positional arguments: 0 allowed, but 1 found.
|
||||
// Try removing the extra positional arguments.
|
||||
// c.instance1(z:z,,);
|
||||
// ^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/trailing_comma1.dart:20:16: Error: Too few positional arguments: 1 required, 0 given.
|
||||
// c.instance2(z:z,,);
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
@@ -43,16 +40,15 @@ class Bad extends core::Object {
|
||||
: super core::Object::•()
|
||||
;
|
||||
method method() → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: No named parameter with the name '#1'.
|
||||
let final core::int #t1 = self::z in invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:16: Error: Too many positional arguments: 0 allowed, but 1 found.
|
||||
Try removing the extra positional arguments.
|
||||
c.instance1(z:z,,);
|
||||
^^" in self::c.{self::C::instance1}{<inapplicable>}.(z: self::z, #1: invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:21: Error: Expected named argument.
|
||||
^" in self::c.{self::C::instance1}{<inapplicable>}.(invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:19:21: Error: This couldn't be parsed.
|
||||
c.instance1(z:z,,);
|
||||
^"){({z: invalid-type, #1: invalid-type}) → invalid-type};
|
||||
invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:16: Error: Too few positional arguments: 1 required, 0 given.
|
||||
^", z: #t1){(invalid-type, {z: invalid-type}) → invalid-type};
|
||||
let final self::C #t2 = self::c in let final core::int #t3 = self::z in #t2.{self::C::instance2}(invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:21: Error: This couldn't be parsed.
|
||||
c.instance2(z:z,,);
|
||||
^" in self::c.{self::C::instance2}{<inapplicable>}.(z: self::z, #1: invalid-expression "pkg/front_end/testcases/general/trailing_comma1.dart:20:21: Error: Expected named argument.
|
||||
c.instance2(z:z,,);
|
||||
^"){({z: invalid-type, #1: invalid-type}) → invalid-type};
|
||||
^", z: #t3){(dynamic, {z: dynamic}) → void};
|
||||
}
|
||||
}
|
||||
static field self::C c = new self::C::•();
|
||||
|
||||
@@ -42,10 +42,10 @@ class A1 extends core::Object {
|
||||
}
|
||||
class B1 extends self::A1 {
|
||||
constructor foo({dynamic x = #C1}) → self::B1
|
||||
: super self::A1::•(y: new self::Test::foo(), x: x)
|
||||
: super self::A1::•(x: x, y: new self::Test::foo())
|
||||
;
|
||||
constructor bar({dynamic x = #C1}) → self::B1
|
||||
: super self::A1::•(y: self::Test::bar(), x: x)
|
||||
: super self::A1::•(x: x, y: self::Test::bar())
|
||||
;
|
||||
}
|
||||
class A2 extends core::Object {
|
||||
@@ -68,10 +68,10 @@ class A3 extends core::Object {
|
||||
}
|
||||
class B3 extends self::A3 {
|
||||
constructor foo({dynamic y = #C1}) → self::B3
|
||||
: super self::A3::•(new self::Test::foo(), y: y)
|
||||
: final dynamic #t1 = y, super self::A3::•(new self::Test::foo(), y: #t1)
|
||||
;
|
||||
constructor bar({dynamic y = #C1}) → self::B3
|
||||
: super self::A3::•(self::Test::bar(), y: y)
|
||||
: final dynamic #t2 = y, super self::A3::•(self::Test::bar(), y: #t2)
|
||||
;
|
||||
}
|
||||
class A4 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -81,10 +81,10 @@ class A4 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B4 extends self::A4 {
|
||||
constructor foo({dynamic x = #C1}) → self::B4
|
||||
: super self::A4::•(y: new self::Test::foo(), x: x)
|
||||
: super self::A4::•(x: x, y: new self::Test::foo())
|
||||
;
|
||||
constructor bar({dynamic x = #C1}) → self::B4
|
||||
: super self::A4::•(y: self::Test::bar(), x: x)
|
||||
: super self::A4::•(x: x, y: self::Test::bar())
|
||||
;
|
||||
}
|
||||
class A5 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -107,10 +107,10 @@ class A6 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B6 extends self::A6 {
|
||||
constructor foo({dynamic y = #C1}) → self::B6
|
||||
: super self::A6::•(new self::Test::foo(), y: y)
|
||||
: final dynamic #t3 = y, super self::A6::•(new self::Test::foo(), y: #t3)
|
||||
;
|
||||
constructor bar({dynamic y = #C1}) → self::B6
|
||||
: super self::A6::•(self::Test::bar(), y: y)
|
||||
: final dynamic #t4 = y, super self::A6::•(self::Test::bar(), y: #t4)
|
||||
;
|
||||
}
|
||||
class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -120,14 +120,14 @@ class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B7 extends self::A7 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic x = #C1}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
const B7.foo({super.x}) : super(y: new Test.foo()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
const constructor bar({dynamic x = #C1}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
const B7.bar({super.x}) : super(y: new Test.bar()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
}
|
||||
class A8 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -154,14 +154,14 @@ class A9 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B9 extends self::A9 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic y = #C1}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t5 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
const B9.foo({super.y}) : super(new Test.foo()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t5)
|
||||
;
|
||||
const constructor bar({dynamic y = #C1}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t6 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
const B9.bar({super.y}) : super(new Test.bar()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t6)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -42,10 +42,10 @@ class A1 extends core::Object {
|
||||
}
|
||||
class B1 extends self::A1 {
|
||||
constructor foo({dynamic x = #C1}) → self::B1
|
||||
: super self::A1::•(y: new self::Test::foo(), x: x)
|
||||
: super self::A1::•(x: x, y: new self::Test::foo())
|
||||
;
|
||||
constructor bar({dynamic x = #C1}) → self::B1
|
||||
: super self::A1::•(y: self::Test::bar(), x: x)
|
||||
: super self::A1::•(x: x, y: self::Test::bar())
|
||||
;
|
||||
}
|
||||
class A2 extends core::Object {
|
||||
@@ -68,10 +68,10 @@ class A3 extends core::Object {
|
||||
}
|
||||
class B3 extends self::A3 {
|
||||
constructor foo({dynamic y = #C1}) → self::B3
|
||||
: super self::A3::•(new self::Test::foo(), y: y)
|
||||
: final dynamic #t1 = y, super self::A3::•(new self::Test::foo(), y: #t1)
|
||||
;
|
||||
constructor bar({dynamic y = #C1}) → self::B3
|
||||
: super self::A3::•(self::Test::bar(), y: y)
|
||||
: final dynamic #t2 = y, super self::A3::•(self::Test::bar(), y: #t2)
|
||||
;
|
||||
}
|
||||
class A4 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -81,10 +81,10 @@ class A4 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B4 extends self::A4 {
|
||||
constructor foo({dynamic x = #C1}) → self::B4
|
||||
: super self::A4::•(y: new self::Test::foo(), x: x)
|
||||
: super self::A4::•(x: x, y: new self::Test::foo())
|
||||
;
|
||||
constructor bar({dynamic x = #C1}) → self::B4
|
||||
: super self::A4::•(y: self::Test::bar(), x: x)
|
||||
: super self::A4::•(x: x, y: self::Test::bar())
|
||||
;
|
||||
}
|
||||
class A5 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -107,10 +107,10 @@ class A6 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B6 extends self::A6 {
|
||||
constructor foo({dynamic y = #C1}) → self::B6
|
||||
: super self::A6::•(new self::Test::foo(), y: y)
|
||||
: final dynamic #t3 = y, super self::A6::•(new self::Test::foo(), y: #t3)
|
||||
;
|
||||
constructor bar({dynamic y = #C1}) → self::B6
|
||||
: super self::A6::•(self::Test::bar(), y: y)
|
||||
: final dynamic #t4 = y, super self::A6::•(self::Test::bar(), y: #t4)
|
||||
;
|
||||
}
|
||||
class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -120,14 +120,14 @@ class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B7 extends self::A7 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic x = #C1}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
const B7.foo({super.x}) : super(y: new Test.foo()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
const constructor bar({dynamic x = #C1}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
const B7.bar({super.x}) : super(y: new Test.bar()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
}
|
||||
class A8 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -154,14 +154,14 @@ class A9 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B9 extends self::A9 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic y = #C1}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t5 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
const B9.foo({super.y}) : super(new Test.foo()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t5)
|
||||
;
|
||||
const constructor bar({dynamic y = #C1}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t6 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
const B9.bar({super.y}) : super(new Test.bar()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t6)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -105,14 +105,14 @@ class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B7 extends self::A7 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic x = null}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
const B7.foo({super.x}) : super(y: new Test.foo()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
const constructor bar({dynamic x = null}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
const B7.bar({super.x}) : super(y: new Test.bar()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
}
|
||||
class A8 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -139,14 +139,14 @@ class A9 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B9 extends self::A9 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic y = null}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t1 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
const B9.foo({super.y}) : super(new Test.foo()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t1)
|
||||
;
|
||||
const constructor bar({dynamic y = null}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t2 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
const B9.bar({super.y}) : super(new Test.bar()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t2)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic
|
||||
|
||||
+16
-16
@@ -42,10 +42,10 @@ class A1 extends core::Object {
|
||||
}
|
||||
class B1 extends self::A1 {
|
||||
constructor foo({dynamic x = #C1}) → self::B1
|
||||
: super self::A1::•(y: new self::Test::foo(), x: x)
|
||||
: super self::A1::•(x: x, y: new self::Test::foo())
|
||||
;
|
||||
constructor bar({dynamic x = #C1}) → self::B1
|
||||
: super self::A1::•(y: self::Test::bar(), x: x)
|
||||
: super self::A1::•(x: x, y: self::Test::bar())
|
||||
;
|
||||
}
|
||||
class A2 extends core::Object {
|
||||
@@ -68,10 +68,10 @@ class A3 extends core::Object {
|
||||
}
|
||||
class B3 extends self::A3 {
|
||||
constructor foo({dynamic y = #C1}) → self::B3
|
||||
: super self::A3::•(new self::Test::foo(), y: y)
|
||||
: final dynamic #t1 = y, super self::A3::•(new self::Test::foo(), y: #t1)
|
||||
;
|
||||
constructor bar({dynamic y = #C1}) → self::B3
|
||||
: super self::A3::•(self::Test::bar(), y: y)
|
||||
: final dynamic #t2 = y, super self::A3::•(self::Test::bar(), y: #t2)
|
||||
;
|
||||
}
|
||||
class A4 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -81,10 +81,10 @@ class A4 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B4 extends self::A4 {
|
||||
constructor foo({dynamic x = #C1}) → self::B4
|
||||
: super self::A4::•(y: new self::Test::foo(), x: x)
|
||||
: super self::A4::•(x: x, y: new self::Test::foo())
|
||||
;
|
||||
constructor bar({dynamic x = #C1}) → self::B4
|
||||
: super self::A4::•(y: self::Test::bar(), x: x)
|
||||
: super self::A4::•(x: x, y: self::Test::bar())
|
||||
;
|
||||
}
|
||||
class A5 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -107,10 +107,10 @@ class A6 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B6 extends self::A6 {
|
||||
constructor foo({dynamic y = #C1}) → self::B6
|
||||
: super self::A6::•(new self::Test::foo(), y: y)
|
||||
: final dynamic #t3 = y, super self::A6::•(new self::Test::foo(), y: #t3)
|
||||
;
|
||||
constructor bar({dynamic y = #C1}) → self::B6
|
||||
: super self::A6::•(self::Test::bar(), y: y)
|
||||
: final dynamic #t4 = y, super self::A6::•(self::Test::bar(), y: #t4)
|
||||
;
|
||||
}
|
||||
class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -120,14 +120,14 @@ class A7 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B7 extends self::A7 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic x = #C1}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:69:38: Error: New expression is not a constant expression.
|
||||
const B7.foo({super.x}) : super(y: new Test.foo()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
const constructor bar({dynamic x = #C1}) → self::B7
|
||||
: super self::A7::•(y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
: super self::A7::•(x: x, y: invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:70:38: Error: New expression is not a constant expression.
|
||||
const B7.bar({super.x}) : super(y: new Test.bar()); // Error.
|
||||
^^^", x: x)
|
||||
^^^")
|
||||
;
|
||||
}
|
||||
class A8 extends core::Object /*hasConstConstructor*/ {
|
||||
@@ -154,14 +154,14 @@ class A9 extends core::Object /*hasConstConstructor*/ {
|
||||
}
|
||||
class B9 extends self::A9 /*hasConstConstructor*/ {
|
||||
const constructor foo({dynamic y = #C1}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t5 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:87:35: Error: New expression is not a constant expression.
|
||||
const B9.foo({super.y}) : super(new Test.foo()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t5)
|
||||
;
|
||||
const constructor bar({dynamic y = #C1}) → self::B9
|
||||
: super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
: final dynamic #t6 = y, super self::A9::•(invalid-expression "pkg/front_end/testcases/super_parameters/issue48642.dart:88:35: Error: New expression is not a constant expression.
|
||||
const B9.bar({super.y}) : super(new Test.bar()); // Error.
|
||||
^^^", y: y)
|
||||
^^^", y: #t6)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -189,14 +189,14 @@ class A7 extends core::Object {
|
||||
}
|
||||
class B7 extends self::A7 {
|
||||
constructor •({required dynamic x1, required dynamic x2, required <X extends core::Object? = dynamic>(core::Object) → X% f1, required <X extends core::Object? = dynamic>(core::Object) → X% f2, required <X extends core::Object? = dynamic>(X%) → void g1, required <X extends core::Object? = dynamic>(X%) → void g2}) → self::B7
|
||||
: super self::A7::•(x2: x2 as{TypeError,ForDynamic} core::int, f2: f2<core::bool>, g2: g2<dynamic>, x1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:73:30: Error: The argument type 'dynamic' can't be assigned to the parameter type 'int'.
|
||||
: super self::A7::•(x1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:73:30: Error: The argument type 'dynamic' can't be assigned to the parameter type 'int'.
|
||||
B7({required dynamic super.x1, // Error.
|
||||
^" in x1 as{TypeError} core::int, f1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:75:44: Error: The argument type 'X Function<X>(Object)' can't be assigned to the parameter type 'bool Function(Object)'.
|
||||
- 'Object' is from 'dart:core'.
|
||||
required X Function<X>(Object) super.f1, // Error.
|
||||
^" in f1 as{TypeError} (core::Object) → core::bool, g1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:77:42: Error: The argument type 'void Function<X>(X)' can't be assigned to the parameter type 'void Function(dynamic)'.
|
||||
required void Function<X>(X) super.g1, // Error.
|
||||
^" in g1 as{TypeError} (dynamic) → void)
|
||||
^" in g1 as{TypeError} (dynamic) → void, x2: x2 as{TypeError,ForDynamic} core::int, f2: f2<core::bool>, g2: g2<dynamic>)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -189,14 +189,14 @@ class A7 extends core::Object {
|
||||
}
|
||||
class B7 extends self::A7 {
|
||||
constructor •({required dynamic x1, required dynamic x2, required <X extends core::Object? = dynamic>(core::Object) → X% f1, required <X extends core::Object? = dynamic>(core::Object) → X% f2, required <X extends core::Object? = dynamic>(X%) → void g1, required <X extends core::Object? = dynamic>(X%) → void g2}) → self::B7
|
||||
: super self::A7::•(x2: x2 as{TypeError,ForDynamic} core::int, f2: f2<core::bool>, g2: g2<dynamic>, x1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:73:30: Error: The argument type 'dynamic' can't be assigned to the parameter type 'int'.
|
||||
: super self::A7::•(x1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:73:30: Error: The argument type 'dynamic' can't be assigned to the parameter type 'int'.
|
||||
B7({required dynamic super.x1, // Error.
|
||||
^" in x1 as{TypeError} core::int, f1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:75:44: Error: The argument type 'X Function<X>(Object)' can't be assigned to the parameter type 'bool Function(Object)'.
|
||||
- 'Object' is from 'dart:core'.
|
||||
required X Function<X>(Object) super.f1, // Error.
|
||||
^" in f1 as{TypeError} (core::Object) → core::bool, g1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:77:42: Error: The argument type 'void Function<X>(X)' can't be assigned to the parameter type 'void Function(dynamic)'.
|
||||
required void Function<X>(X) super.g1, // Error.
|
||||
^" in g1 as{TypeError} (dynamic) → void)
|
||||
^" in g1 as{TypeError} (dynamic) → void, x2: x2 as{TypeError,ForDynamic} core::int, f2: f2<core::bool>, g2: g2<dynamic>)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
+2
-2
@@ -189,14 +189,14 @@ class A7 extends core::Object {
|
||||
}
|
||||
class B7 extends self::A7 {
|
||||
constructor •({required dynamic x1, required dynamic x2, required <X extends core::Object? = dynamic>(core::Object) → X% f1, required <X extends core::Object? = dynamic>(core::Object) → X% f2, required <X extends core::Object? = dynamic>(X%) → void g1, required <X extends core::Object? = dynamic>(X%) → void g2}) → self::B7
|
||||
: super self::A7::•(x2: x2 as{TypeError,ForDynamic} core::int, f2: f2<core::bool>, g2: g2<dynamic>, x1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:73:30: Error: The argument type 'dynamic' can't be assigned to the parameter type 'int'.
|
||||
: super self::A7::•(x1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:73:30: Error: The argument type 'dynamic' can't be assigned to the parameter type 'int'.
|
||||
B7({required dynamic super.x1, // Error.
|
||||
^" in x1 as{TypeError} core::int, f1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:75:44: Error: The argument type 'X Function<X>(Object)' can't be assigned to the parameter type 'bool Function(Object)'.
|
||||
- 'Object' is from 'dart:core'.
|
||||
required X Function<X>(Object) super.f1, // Error.
|
||||
^" in f1 as{TypeError} (core::Object) → core::bool, g1: invalid-expression "pkg/front_end/testcases/super_parameters/no_coercions.dart:77:42: Error: The argument type 'void Function<X>(X)' can't be assigned to the parameter type 'void Function(dynamic)'.
|
||||
required void Function<X>(X) super.g1, // Error.
|
||||
^" in g1 as{TypeError} (dynamic) → void)
|
||||
^" in g1 as{TypeError} (dynamic) → void, x2: x2 as{TypeError,ForDynamic} core::int, f2: f2<core::bool>, g2: g2<dynamic>)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -10,11 +10,6 @@ library;
|
||||
// // @dart=2.15
|
||||
// ^^^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/opt_out.dart:14:3: Error: The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
// Try adding an explicit super initializer with the required arguments.
|
||||
// B(super.field);
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -26,10 +21,7 @@ class A extends core::Object {
|
||||
}
|
||||
class B extends self::A {
|
||||
constructor •(core::int field) → self::B
|
||||
: invalid-initializer "pkg/front_end/testcases/super_parameters/opt_out.dart:14:3: Error: The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
Try adding an explicit super initializer with the required arguments.
|
||||
B(super.field);
|
||||
^"
|
||||
: super self::A::•(field)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -10,11 +10,6 @@ library;
|
||||
// // @dart=2.15
|
||||
// ^^^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/opt_out.dart:14:3: Error: The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
// Try adding an explicit super initializer with the required arguments.
|
||||
// B(super.field);
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -26,10 +21,7 @@ class A extends core::Object {
|
||||
}
|
||||
class B extends self::A {
|
||||
constructor •(core::int field) → self::B
|
||||
: invalid-initializer "pkg/front_end/testcases/super_parameters/opt_out.dart:14:3: Error: The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
Try adding an explicit super initializer with the required arguments.
|
||||
B(super.field);
|
||||
^"
|
||||
: super self::A::•(field)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
@@ -10,11 +10,6 @@ library;
|
||||
// // @dart=2.15
|
||||
// ^^^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/opt_out.dart:14:3: Error: The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
// Try adding an explicit super initializer with the required arguments.
|
||||
// B(super.field);
|
||||
// ^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
@@ -26,10 +21,7 @@ class A extends core::Object {
|
||||
}
|
||||
class B extends self::A {
|
||||
constructor •(core::int field) → self::B
|
||||
: invalid-initializer "pkg/front_end/testcases/super_parameters/opt_out.dart:14:3: Error: The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
Try adding an explicit super initializer with the required arguments.
|
||||
B(super.field);
|
||||
^"
|
||||
: super self::A::•(field)
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
+5
-5
@@ -2,9 +2,9 @@ library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:22: Error: Duplicated named argument 'foo'.
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:36: Error: Duplicated named argument 'foo'.
|
||||
// C1({required super.foo}) : super(foo: foo); // Error.
|
||||
// ^^^
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:25:37: Error: No named parameter with the name 'baz'.
|
||||
// B2() : super(foo: 42, bar: "bar", baz: false); // Error.
|
||||
@@ -30,9 +30,9 @@ class B1 extends self::A1 {
|
||||
}
|
||||
class C1 extends self::A1 {
|
||||
constructor •({required core::int foo}) → self::C1
|
||||
: super self::A1::•(foo: invalid-expression "pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:22: Error: Duplicated named argument 'foo'.
|
||||
: super self::A1::•(foo: invalid-expression "pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:36: Error: Duplicated named argument 'foo'.
|
||||
C1({required super.foo}) : super(foo: foo); // Error.
|
||||
^^^" in block {
|
||||
^^^" in block {
|
||||
foo;
|
||||
} =>foo)
|
||||
;
|
||||
@@ -58,7 +58,7 @@ class C2 extends self::A2 {
|
||||
^"
|
||||
;
|
||||
constructor other({required core::int foo}) → self::C2
|
||||
: super self::A2::•(bar: "bar", foo: foo)
|
||||
: super self::A2::•(foo: foo, bar: "bar")
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
+5
-5
@@ -2,9 +2,9 @@ library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:22: Error: Duplicated named argument 'foo'.
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:36: Error: Duplicated named argument 'foo'.
|
||||
// C1({required super.foo}) : super(foo: foo); // Error.
|
||||
// ^^^
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:25:37: Error: No named parameter with the name 'baz'.
|
||||
// B2() : super(foo: 42, bar: "bar", baz: false); // Error.
|
||||
@@ -30,9 +30,9 @@ class B1 extends self::A1 {
|
||||
}
|
||||
class C1 extends self::A1 {
|
||||
constructor •({required core::int foo}) → self::C1
|
||||
: super self::A1::•(foo: invalid-expression "pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:22: Error: Duplicated named argument 'foo'.
|
||||
: super self::A1::•(foo: invalid-expression "pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:36: Error: Duplicated named argument 'foo'.
|
||||
C1({required super.foo}) : super(foo: foo); // Error.
|
||||
^^^" in block {
|
||||
^^^" in block {
|
||||
foo;
|
||||
} =>foo)
|
||||
;
|
||||
@@ -58,7 +58,7 @@ class C2 extends self::A2 {
|
||||
^"
|
||||
;
|
||||
constructor other({required core::int foo}) → self::C2
|
||||
: super self::A2::•(bar: "bar", foo: foo)
|
||||
: super self::A2::•(foo: foo, bar: "bar")
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
+5
-5
@@ -2,9 +2,9 @@ library;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:22: Error: Duplicated named argument 'foo'.
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:36: Error: Duplicated named argument 'foo'.
|
||||
// C1({required super.foo}) : super(foo: foo); // Error.
|
||||
// ^^^
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:25:37: Error: No named parameter with the name 'baz'.
|
||||
// B2() : super(foo: 42, bar: "bar", baz: false); // Error.
|
||||
@@ -30,9 +30,9 @@ class B1 extends self::A1 {
|
||||
}
|
||||
class C1 extends self::A1 {
|
||||
constructor •({required core::int foo}) → self::C1
|
||||
: super self::A1::•(foo: invalid-expression "pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:22: Error: Duplicated named argument 'foo'.
|
||||
: super self::A1::•(foo: invalid-expression "pkg/front_end/testcases/super_parameters/simple_named_super_parameters.dart:15:36: Error: Duplicated named argument 'foo'.
|
||||
C1({required super.foo}) : super(foo: foo); // Error.
|
||||
^^^" in block {
|
||||
^^^" in block {
|
||||
foo;
|
||||
} =>foo)
|
||||
;
|
||||
@@ -58,7 +58,7 @@ class C2 extends self::A2 {
|
||||
^"
|
||||
;
|
||||
constructor other({required core::int foo}) → self::C2
|
||||
: super self::A2::•(bar: "bar", foo: foo)
|
||||
: super self::A2::•(foo: foo, bar: "bar")
|
||||
;
|
||||
}
|
||||
static method main() → dynamic {}
|
||||
|
||||
Reference in New Issue
Block a user