Complain about incorrect use of null-aware operations.
R=danrubel@google.com, johnniwinther@google.com Review-Url: https://codereview.chromium.org/2932723003 .
This commit is contained in:
@@ -123,6 +123,24 @@ FastaMessage _formatFactoryNotSync(Uri uri, int charOffset) {
|
||||
arguments: {});
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const FastaCode<_SuperNullAware> codeSuperNullAware =
|
||||
const FastaCode<_SuperNullAware>("SuperNullAware",
|
||||
template: r"'super' can't be null.",
|
||||
tip: r"Try replacing '?.' with '.'",
|
||||
dart2jsCode: "FASTA_IGNORED",
|
||||
format: _formatSuperNullAware);
|
||||
|
||||
typedef FastaMessage _SuperNullAware(Uri uri, int charOffset);
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
FastaMessage _formatSuperNullAware(Uri uri, int charOffset) {
|
||||
return new FastaMessage(uri, charOffset, codeSuperNullAware,
|
||||
message: "'super' can't be null.",
|
||||
tip: "Try replacing '?.' with '.'",
|
||||
arguments: {});
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const FastaCode<_PrivateNamedParameter> codePrivateNamedParameter =
|
||||
const FastaCode<_PrivateNamedParameter>("PrivateNamedParameter",
|
||||
|
||||
@@ -331,6 +331,10 @@ class ThisAccessor extends FastaAccessor {
|
||||
buildPropertyAccess(
|
||||
IncompleteSend send, int operatorOffset, bool isNullAware) {
|
||||
if (isInitializer && send is SendAccessor) {
|
||||
if (isNullAware) {
|
||||
helper.addCompileTimeError(
|
||||
operatorOffset, "Expected '.'\nTry removing '?'.");
|
||||
}
|
||||
return buildConstructorInitializer(
|
||||
offsetForToken(send.token), send.name, send.arguments);
|
||||
}
|
||||
@@ -484,6 +488,12 @@ class SendAccessor extends IncompleteSend {
|
||||
}
|
||||
if (receiver is PrefixBuilder) {
|
||||
PrefixBuilder prefix = receiver;
|
||||
if (isNullAware) {
|
||||
helper.addCompileTimeError(
|
||||
offsetForToken(token),
|
||||
"Library prefix '${prefix.name}' can't be used with null-aware "
|
||||
"operator.\nTry removing '?'.");
|
||||
}
|
||||
receiver = helper.scopeLookup(prefix.exports, name.name, token,
|
||||
isQualified: true, prefix: prefix);
|
||||
return helper.finishSend(receiver, arguments, offsetForToken(token));
|
||||
@@ -544,6 +554,12 @@ class IncompletePropertyAccessor extends IncompleteSend {
|
||||
}
|
||||
if (receiver is PrefixBuilder) {
|
||||
PrefixBuilder prefix = receiver;
|
||||
if (isNullAware) {
|
||||
helper.addCompileTimeError(
|
||||
offsetForToken(token),
|
||||
"Library prefix '${prefix.name}' can't be used with null-aware "
|
||||
"operator.\nTry removing '?'.");
|
||||
}
|
||||
return helper.scopeLookup(prefix.exports, name.name, token,
|
||||
isQualified: true, prefix: prefix);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import '../fasta_codes.dart'
|
||||
codeRequiredParameterWithDefault,
|
||||
codeSetterNotSync,
|
||||
codeStackOverflow,
|
||||
codeSuperNullAware,
|
||||
codeTypeAfterVar,
|
||||
codeTypeRequired,
|
||||
codeUnexpectedToken,
|
||||
@@ -3057,6 +3058,8 @@ class Parser {
|
||||
listener.handleNoTypeArguments(token);
|
||||
token = parseArguments(token);
|
||||
listener.endSend(beginToken, token);
|
||||
} else if (optional("?.", token)) {
|
||||
reportRecoverableErrorCode(token, codeSuperNullAware);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
@@ -429,3 +429,8 @@ CatchSyntax:
|
||||
template: "'catch' must be followed by '(identifier)' or '(identifier, identifier)'."
|
||||
tip: "No types are needed, the first is given by 'on', the second is always 'StackTrace'."
|
||||
dart2jsCode: FASTA_IGNORED
|
||||
|
||||
SuperNullAware:
|
||||
template: "'super' can't be null."
|
||||
tip: "Try replacing '?.' with '.'"
|
||||
dart2jsCode: FASTA_IGNORED
|
||||
|
||||
@@ -342,11 +342,6 @@ type_variable_bounds4_test/01: RuntimeError
|
||||
|
||||
[ $compiler == dartk || $compiler == dartkp ]
|
||||
compile_time_constant_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
conditional_method_invocation_test/11: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
conditional_property_access_test/09: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
conditional_property_assignment_test/20: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
conditional_property_assignment_test/21: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
conditional_property_assignment_test/22: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
const_constructor_mixin2_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
const_constructor_mixin3_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
const_constructor_mixin_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
@@ -413,23 +408,6 @@ ref_before_declaration_test/06: MissingCompileTimeError # Fixed in ahe's dev bra
|
||||
ref_before_declaration_test/07: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
regress_29349_test: CompileTimeError # Fixed in ahe's dev branch.
|
||||
scope_variable_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/02: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/03: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/04: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/05: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/06: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/07: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/08: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/09: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/10: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/11: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/12: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/13: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/14: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/15: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
super_conditional_operator_test/16: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
this_conditional_operator_test/01: MissingCompileTimeError # Fixed in ahe's dev branch.
|
||||
|
||||
[ $unchecked && ($compiler == dartk || $compiler == dartkp) ]
|
||||
const_conditional_test/08: MissingCompileTimeError # KernelVM bug: Constant evaluation.
|
||||
|
||||
Reference in New Issue
Block a user