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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_propagation.dart

Issue 1294083002: dart2js cps: Set proper receiver type for intercepted methods. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Go back to using parameter.hint due to issues with constructor bodies Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index 76eb580ead3f628f192064200b387874bd64d39d..c86b28ce3e389b78d02b44173ba14449c6899ee5 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -1833,6 +1833,8 @@ class TypePropagationVisitor implements Visitor {
TypeMaskSystem get typeSystem => lattice.typeSystem;
+ JavaScriptBackend get backend => typeSystem.backend;
+
AbstractValue get nothing => lattice.nothing;
AbstractValue nonConstant([TypeMask type]) => lattice.nonConstant(type);
@@ -1933,11 +1935,23 @@ class TypePropagationVisitor implements Visitor {
void visit(Node node) { node.accept(this); }
void visitFunctionDefinition(FunctionDefinition node) {
- if (node.thisParameter != null) {
+ int firstActualParameter = 0;
+ if (backend.isInterceptedMethod(node.element)) {
+ setValue(node.thisParameter, nonConstant(typeSystem.nonNullType));
+ setValue(node.parameters[0],
+ nonConstant(typeSystem.getReceiverType(node.element)));
+ firstActualParameter = 1;
+ } else if (node.thisParameter != null) {
setValue(node.thisParameter,
nonConstant(typeSystem.getReceiverType(node.element)));
}
- node.parameters.forEach(visit);
+ for (Parameter param in node.parameters.skip(firstActualParameter)) {
+ // TODO(karlklose): remove reference to the element model.
+ TypeMask type = param.hint is ParameterElement
+ ? typeSystem.getParameterType(param.hint)
+ : typeSystem.dynamicType;
+ setValue(param, nonConstant(type));
+ }
push(node.body);
}
@@ -2299,39 +2313,9 @@ class TypePropagationVisitor implements Visitor {
}
void visitMutableVariable(MutableVariable node) {
- // [MutableVariable]s are bound either as parameters to
- // [FunctionDefinition]s, by [LetMutable].
- if (node.parent is FunctionDefinition) {
- // Just like immutable parameters, the values of mutable parameters are
- // never constant.
- // TODO(karlklose): remove reference to the element model.
- Entity source = node.hint;
- TypeMask type = (source is ParameterElement)
- ? typeSystem.getParameterType(source)
- : typeSystem.dynamicType;
- setValue(node, nonConstant(type));
- } else if (node.parent is LetMutable) {
- // Mutable values bound by LetMutable could have known values.
- } else {
- internalError(node.hint, "Unexpected parent of MutableVariable");
- }
}
void visitParameter(Parameter node) {
- Entity source = node.hint;
- // TODO(karlklose): remove reference to the element model.
- TypeMask type = (source is ParameterElement)
- ? typeSystem.getParameterType(source)
- : typeSystem.dynamicType;
- if (node.parent is FunctionDefinition) {
- // Functions may escape and thus their parameters must be non-constant.
- setValue(node, nonConstant(type));
- } else if (node.parent is Continuation) {
- // Continuations on the other hand are local, and parameters can have
- // some other abstract value than non-constant.
- } else {
- internalError(node.hint, "Unexpected parent of Parameter: ${node.parent}");
- }
}
void visitContinuation(Continuation node) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698