Replace more uses of Unspecified

Change-Id: I78aadfa055e2be90805e193abc1e3a23b5955caf
Reviewed-on: https://dart-review.googlesource.com/65574
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2018-07-18 19:59:03 +00:00 committed by commit-bot@chromium.org
parent 23c81964d9
commit 5a1d4c95eb
7 changed files with 62 additions and 20 deletions

View file

@ -159,6 +159,7 @@ const List<ErrorCode> errorCodeValues = const [
CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD,
CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD,
CompileTimeErrorCode.INITIALIZER_OUTSIDE_CONSTRUCTOR,
CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD,
CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD,
CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY,

View file

@ -1348,6 +1348,9 @@ class CompileTimeErrorCode extends ErrorCode {
"in a constructor can't be static.",
correction: "Try removing the initialization.");
static const CompileTimeErrorCode INITIALIZER_OUTSIDE_CONSTRUCTOR =
const CompileTimeErrorCode.fromFasta('INITIALIZER_OUTSIDE_CONSTRUCTOR');
/**
* 7.6.1 Generative Constructors: An initializing formal has the form
* <i>this.id</i>. It is a compile-time error if <i>id</i> is not the name of

View file

@ -180,20 +180,6 @@ class CompileTimeErrorCodeTest_Kernel extends CompileTimeErrorCodeTest_Driver {
return super.test_constConstructorWithMixinWithField_final();
}
@override
@failingTest
test_constConstructorWithNonConstSuper_explicit() async {
// UnimplementedError: For ShadowInvalidInitializer
await super.test_constConstructorWithNonConstSuper_explicit();
}
@override
@failingTest
test_constConstructorWithNonConstSuper_implicit() async {
// UnimplementedError: For ShadowInvalidInitializer
await super.test_constConstructorWithNonConstSuper_implicit();
}
@override
@failingTest
test_constConstructorWithNonFinalField_mixin() async {

View file

@ -948,6 +948,18 @@ const MessageCode messageConstConstructorWithBody = const MessageCode(
message: r"""A const constructor can't have a body.""",
tip: r"""Try removing either the 'const' keyword or the body.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeConstConstructorWithNonConstSuper =
messageConstConstructorWithNonConstSuper;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageConstConstructorWithNonConstSuper = const MessageCode(
"ConstConstructorWithNonConstSuper",
analyzerCode: "CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER",
dart2jsCode: "*fatal*",
message:
r"""Constant constructor can't call non-constant super constructors.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeConstEvalContext = messageConstEvalContext;
@ -3407,6 +3419,31 @@ const MessageCode messageInitializedVariableInForEach = const MessageCode(
tip:
r"""Try removing the initializer, or using a different kind of loop.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String
name)> templateInitializerOutsideConstructor = const Template<
Message Function(String name)>(
messageTemplate:
r"""Only constructors can have initializers, and '#name' is not a constructor.""",
withArguments: _withArgumentsInitializerOutsideConstructor);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)> codeInitializerOutsideConstructor =
const Code<Message Function(String name)>(
"InitializerOutsideConstructor", templateInitializerOutsideConstructor,
analyzerCode: "INITIALIZER_OUTSIDE_CONSTRUCTOR",
dart2jsCode: "*fatal*");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsInitializerOutsideConstructor(String name) {
return new Message(codeInitializerOutsideConstructor,
message:
"""Only constructors can have initializers, and '${name}' is not a constructor.""",
arguments: {'name': name});
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(

View file

@ -657,8 +657,11 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
if (member is KernelConstructorBuilder && !member.isExternal) {
member.addInitializer(initializer, _typeInferrer);
} else {
deprecated_addCompileTimeError(
token.charOffset, "Can't have initializers: ${member.name}");
addCompileTimeError(
fasta.templateInitializerOutsideConstructor
.withArguments(member.name),
token.charOffset,
member.name.length);
}
}
@ -1766,8 +1769,8 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
debugEvent("ReturnStatement");
Expression expression = hasExpression ? popForValue() : null;
if (expression != null && inConstructor) {
push(deprecated_buildCompileTimeErrorStatement(
"Can't return from a constructor.", beginToken.charOffset));
push(buildCompileTimeErrorStatement(
fasta.messageConstructorWithReturnType, beginToken.charOffset));
} else {
push(forest.returnStatement(beginToken, expression, endToken));
}
@ -4126,8 +4129,8 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
[int charOffset = -1]) {
if (member.isConst && !constructor.isConst) {
return buildInvalidInitializer(
deprecated_buildCompileTimeError(
"Super constructor isn't const.", charOffset),
buildCompileTimeError(fasta.messageConstConstructorWithNonConstSuper,
charOffset, member.name.length),
charOffset);
}
needsImplicitSuperInitializer = false;

View file

@ -54,6 +54,7 @@ ConstAndFinal/script1: Fail
ConstAndVar/script1: Fail
ConstConstructorInSubclassOfMixinApplication/example: Fail
ConstConstructorNonFinalField/example: Fail
ConstConstructorWithNonConstSuper/example: Fail
ConstEvalContext/analyzerCode: Fail # This is just used for displaying the context.
ConstEvalContext/example: Fail # This is just used for displaying the context.
ConstEvalDuplicateKey/dart2jsCode: Fail
@ -194,6 +195,7 @@ ImplementsBeforeExtends/script: Fail
ImplementsBeforeWith/script: Fail
ImplicitCallOfNonMethod/example: Fail
ImportAfterPart/script1: Fail
InitializerOutsideConstructor/example: Fail
InputFileNotFound/analyzerCode: Fail
InputFileNotFound/example: Fail
IntegerLiteralIsOutOfRange/example: Fail

View file

@ -630,6 +630,16 @@ ExternalField:
script:
- "class C { external var f; }"
InitializerOutsideConstructor:
template: "Only constructors can have initializers, and '#name' is not a constructor."
analyzerCode: INITIALIZER_OUTSIDE_CONSTRUCTOR
dart2jsCode: "*fatal*"
ConstConstructorWithNonConstSuper:
template: "Constant constructor can't call non-constant super constructors."
analyzerCode: CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
dart2jsCode: "*fatal*"
ExtraneousModifier:
template: "Can't have modifier '#lexeme' here."
tip: "Try removing '#lexeme'."