mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:07:06 +00:00
Use TypeVariableInConstExpression in place of Unspecified
Change-Id: Ib0f902979c33e97fa46660f0c0a4e98b092c274c Reviewed-on: https://dart-review.googlesource.com/65240 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
6927e30cac
commit
3dba24bda2
|
@ -250,6 +250,7 @@ const List<ErrorCode> errorCodeValues = const [
|
|||
CompileTimeErrorCode.THIS_ACCESS_FROM_INITIALIZER,
|
||||
CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
|
||||
CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
|
||||
CompileTimeErrorCode.TYPE_PARAMETER_IN_CONST_EXPRESSION,
|
||||
CompileTimeErrorCode.TYPE_PARAMETER_ON_CONSTRUCTOR,
|
||||
CompileTimeErrorCode.UNDEFINED_ANNOTATION,
|
||||
CompileTimeErrorCode.UNDEFINED_CLASS,
|
||||
|
|
|
@ -2474,6 +2474,10 @@ class CompileTimeErrorCode extends ErrorCode {
|
|||
"Typedefs can't reference themselves directly or recursively via "
|
||||
"another typedef.");
|
||||
|
||||
static const CompileTimeErrorCode TYPE_PARAMETER_IN_CONST_EXPRESSION =
|
||||
const CompileTimeErrorCode.fromFasta(
|
||||
'TYPE_PARAMETER_IN_CONST_EXPRESSION');
|
||||
|
||||
static const CompileTimeErrorCode TYPE_PARAMETER_ON_CONSTRUCTOR =
|
||||
const CompileTimeErrorCode.fromFasta('TYPE_PARAMETER_ON_CONSTRUCTOR');
|
||||
|
||||
|
|
|
@ -6533,6 +6533,40 @@ Message _withArgumentsTypeVariableDuplicatedNameCause(String name) {
|
|||
arguments: {'name': name});
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Template<
|
||||
Message Function(
|
||||
String name,
|
||||
DartType
|
||||
_type)> templateTypeVariableInConstExpression = const Template<
|
||||
Message Function(String name, DartType _type)>(
|
||||
messageTemplate:
|
||||
r"""Type variable '#name' can't be used as a constant expression '#type'.""",
|
||||
withArguments: _withArgumentsTypeVariableInConstExpression);
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Message Function(String name, DartType _type)>
|
||||
codeTypeVariableInConstExpression =
|
||||
const Code<Message Function(String name, DartType _type)>(
|
||||
"TypeVariableInConstExpression", templateTypeVariableInConstExpression,
|
||||
analyzerCode: "TYPE_PARAMETER_IN_CONST_EXPRESSION",
|
||||
dart2jsCode: "*fatal*",
|
||||
severity: Severity.error);
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
Message _withArgumentsTypeVariableInConstExpression(
|
||||
String name, DartType _type) {
|
||||
NameSystem nameSystem = new NameSystem();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
new Printer(buffer, syntheticNames: nameSystem).writeNode(_type);
|
||||
String type = '$buffer';
|
||||
|
||||
return new Message(codeTypeVariableInConstExpression,
|
||||
message:
|
||||
"""Type variable '${name}' can't be used as a constant expression '${type}'.""",
|
||||
arguments: {'name': name, 'type': _type});
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> codeTypeVariableInStaticContext =
|
||||
messageTypeVariableInStaticContext;
|
||||
|
|
|
@ -4203,10 +4203,12 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
|
|||
}
|
||||
return const InvalidType();
|
||||
} else if (constantContext != ConstantContext.none) {
|
||||
deprecated_addCompileTimeError(
|
||||
int length = type.parameter.name.length;
|
||||
addCompileTimeError(
|
||||
fasta.templateTypeVariableInConstExpression
|
||||
.withArguments(type.parameter.name, type),
|
||||
offset,
|
||||
"Type variable '${type.parameter.name}' can't be used as a constant "
|
||||
"expression $type.");
|
||||
length);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -348,6 +348,7 @@ TypeArgumentMismatch/example: Fail
|
|||
TypeArgumentsOnTypeVariable/script1: Fail
|
||||
TypeNotFound/example: Fail
|
||||
TypeVariableDuplicatedName/example: Fail
|
||||
TypeVariableInConstExpression/example: Fail
|
||||
TypeVariableInStaticContext/example: Fail
|
||||
TypeVariableSameNameAsEnclosing/example: Fail
|
||||
TypedefNotFunction/example: Fail
|
||||
|
|
|
@ -2147,6 +2147,12 @@ FinalInstanceVariableAlreadyInitializedCause:
|
|||
template: "'#name' was initialized here."
|
||||
severity: CONTEXT
|
||||
|
||||
TypeVariableInConstExpression:
|
||||
template: "Type variable '#name' can't be used as a constant expression '#type'."
|
||||
severity: ERROR
|
||||
analyzerCode: TYPE_PARAMETER_IN_CONST_EXPRESSION
|
||||
dart2jsCode: "*fatal*"
|
||||
|
||||
TypeVariableInStaticContext:
|
||||
template: "Type variables can't be used in static members."
|
||||
severity: ERROR_LEGACY_WARNING
|
||||
|
|
Loading…
Reference in a new issue