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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Issue 3010613003: Simplify annotations in runtime check tests. (Closed)
Patch Set: Address code review comment Created 3 years, 4 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/type_inference/type_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index 4e7db482776d8a7cc4fe9680529eb45e1f4414ed..8fb043d8d32160737c6e13c59ca3c3cb41769dc5 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -876,46 +876,15 @@ abstract class TypeInferrerImpl extends TypeInferrer {
? expression.fileOffset
: arguments.fileOffset;
if (receiver is ThisExpression) {
- // Calls to `this` are always typed.
- } else if (interfaceMember == null &&
- !(receiverType is FunctionType && methodName.name == 'call')) {
- // Dynamic invocation
- instrumentation.record(Uri.parse(uri), offset, 'checkCall',
- new InstrumentationValueLiteral('dynamic'));
- } else {
- var semiTypedArguments = <String>[];
- var function = interfaceMember?.function;
- int i = 0;
- _forEachArgument(arguments, (name, expression) {
- bool isSemiTyped;
- if (function == null) {
- // Invocation of a function-typed object; everything is semi-typed.
- isSemiTyped = true;
- } else {
- var formal = name != null
- ? _getNamedFormal(function, name)
- : _getPositionalFormal(function, i);
- if (formal != null) {
- isSemiTyped = _isFormalSemiSafe(formal);
- } else {
- // No matching formal parameter. An error should have already been
- // reported, so the code won't compile. Thus, it doesn't really
- // matter how we annotate the parameter.
- isSemiTyped = false;
- }
- }
- if (isSemiTyped) {
- semiTypedArguments.add(name ?? i.toString());
- }
- if (name == null) i++;
- });
- if (semiTypedArguments.isNotEmpty) {
- instrumentation.record(
- Uri.parse(uri),
- offset,
- 'checkCall',
- new InstrumentationValueLiteral(
- 'interface(semiTyped:${semiTypedArguments.join(',')})'));
+ instrumentation.record(Uri.parse(uri), offset, 'callKind',
+ new InstrumentationValueLiteral('this'));
+ } else if (interfaceMember == null) {
+ if (receiverType is FunctionType && methodName.name == 'call') {
+ instrumentation.record(Uri.parse(uri), offset, 'callKind',
+ new InstrumentationValueLiteral('closure'));
+ } else {
+ instrumentation.record(Uri.parse(uri), offset, 'callKind',
+ new InstrumentationValueLiteral('dynamic'));
}
}
}
@@ -1108,32 +1077,4 @@ abstract class TypeInferrerImpl extends TypeInferrer {
callback(namedExpression.name, namedExpression.value);
}
}
-
- /// Given a [FunctionNode], gets the named parameter identified by [name], or
- /// `null` if there is no parameter with the given name.
- VariableDeclaration _getNamedFormal(FunctionNode function, String name) {
- for (var formal in function.namedParameters) {
- if (formal.name == name) return formal;
- }
- return null;
- }
-
- /// Given a [FunctionNode], gets the [i]th positional formal parameter, or
- /// `null` if there is no parameter with that index.
- VariableDeclaration _getPositionalFormal(FunctionNode function, int i) {
- if (i < function.positionalParameters.length) {
- return function.positionalParameters[i];
- } else {
- return null;
- }
- }
-
- /// Determines if the given formal parameter is semi-safe.
- ///
- /// Eventually this information will be stored in the kernel representation,
- /// so this method will no longer be needed. TODO(paulberry): remove this
- /// when it's appropriate to do so.
- bool _isFormalSemiSafe(VariableDeclaration formal) {
- return formal is KernelVariableDeclaration && formal.isSemiSafe;
- }
}

Powered by Google App Engine
This is Rietveld 408576698