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

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

Issue 2963763002: Change how unresolved super sends are handled. (Closed)
Patch Set: Rebased on 6cb702b723184ef8875871e4c15004d1ea0a8460. 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index bec7393f04bcdcd55c7f061ab9338ca0ee1aebfc..37d5f8c7345f878bcfd7f6358d90f026ef76ebe2 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -901,35 +901,35 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
@override
Expression toSuperMethodInvocation(MethodInvocation node) {
Member target = lookupSuperMember(node.name);
- bool isNoSuchMethod = target == null;
- if (target is Procedure) {
- if (!target.isAccessor) {
- if (areArgumentsCompatible(target.function, node.arguments)) {
- Expression result = new KernelDirectMethodInvocation(
- new KernelThisExpression()..fileOffset = node.fileOffset,
- target,
- node.arguments)
- ..fileOffset = node.fileOffset;
- // TODO(ahe): Use [DirectMethodInvocation] when possible, that is,
- // remove the next line:
- result =
- new KernelSuperMethodInvocation(node.name, node.arguments, target)
- ..fileOffset = node.fileOffset;
- return result;
- } else {
- isNoSuchMethod = true;
- }
- }
- }
- if (isNoSuchMethod) {
- return invokeSuperNoSuchMethod(
- node.name.name, node.arguments, node.fileOffset);
+ if (target == null || (target is Procedure && !target.isAccessor)) {
+ if (target == null) {
+ warnUnresolvedSuperMethod(node.name, node.fileOffset);
+ } else if (!areArgumentsCompatible(target.function, node.arguments)) {
+ target = null;
+ warning(
+ "Super class doesn't have a method named '${node.name.name}' "
+ "with matching arguments.",
+ node.fileOffset);
+ }
+ Expression result;
+ if (target != null) {
+ result = new KernelDirectMethodInvocation(
+ new KernelThisExpression()..fileOffset = node.fileOffset,
+ target,
+ node.arguments);
+ }
+ // TODO(ahe): Use [DirectMethodInvocation] when possible, that is,
+ // make the next line conditional:
+ result =
+ new KernelSuperMethodInvocation(node.name, node.arguments, target);
+ return result..fileOffset = node.fileOffset;
}
+
Expression receiver = new KernelDirectPropertyGet(
new KernelThisExpression()..fileOffset = node.fileOffset, target)
..fileOffset = node.fileOffset;
- // TODO(ahe): Use [DirectPropertyGet] when possible, that is, remove the
- // next line:
+ // TODO(ahe): Use [DirectPropertyGet] when possible, that is, make the next
+ // line conditional:
receiver = new KernelSuperPropertyGet(node.name, target)
..fileOffset = node.fileOffset;
return buildMethodInvocation(
@@ -977,51 +977,18 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
@override
- Expression invokeSuperNoSuchMethod(
- String name, Arguments arguments, int charOffset,
- {bool isGetter: false, bool isSetter: false}) {
- String errorName = "super.$name";
- String message;
- if (isGetter) {
- message = "Getter not found: '$errorName'.";
- name = "get:$name";
- } else if (isSetter) {
- message = "Setter not found: '$errorName'.";
- name = "set:$name";
- } else {
- message = "Method not found: '$errorName'.";
- }
- warning(message, charOffset);
- VariableDeclaration value;
- if (isSetter) {
- value = new VariableDeclaration.forValue(arguments.positional.single,
- isFinal: true)
- ..fileOffset = charOffset;
- arguments = new Arguments(<Expression>[
- new VariableGet(value)..fileOffset = arguments.fileOffset
- ]);
- }
- Expression result = new SuperMethodInvocation(
- noSuchMethodName,
- new Arguments(<Expression>[
- library.loader.instantiateInvocation(
- new KernelThisExpression()..fileOffset = charOffset,
- name,
- arguments,
- charOffset,
- true)
- ])
- ..fileOffset = arguments.fileOffset);
- if (isSetter) {
- result = new Let(
- value,
- new Let(
- new VariableDeclaration.forValue(result, isFinal: true)
- ..fileOffset = charOffset,
- new VariableGet(value)..fileOffset = value.fileOffset))
- ..fileOffset = charOffset;
- }
- return result;
+ void warnUnresolvedSuperGet(Name name, int charOffset) {
+ warning("Super class has no getter named '${name.name}'.", charOffset);
+ }
+
+ @override
+ void warnUnresolvedSuperSet(Name name, int charOffset) {
+ warning("Super class has no setter named '${name.name}'.", charOffset);
+ }
+
+ @override
+ void warnUnresolvedSuperMethod(Name name, int charOffset) {
+ warning("Super class has no method named '${name.name}'.", charOffset);
}
@override
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698