Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart

Issue 2932723003: Complain about incorrect use of null-aware operations. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
index e9dadd785fde5098cf96b6d54c24038d4daca17e..dabc038ae6e826462398cef27a812fd597e71b8f 100644
--- a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
@@ -321,6 +321,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);
}
@@ -473,6 +477,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));
@@ -530,6 +540,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);
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta_codes_generated.dart ('k') | pkg/front_end/lib/src/fasta/parser/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698