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

Side by Side Diff: lib/transformations/erasure.dart

Issue 2492453002: Erasure fix: Replace type parameters with dynamic instead of Object. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library kernel.transformations.erasure; 4 library kernel.transformations.erasure;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../type_algebra.dart'; 7 import '../type_algebra.dart';
8 8
9 /// This pass is a temporary measure to run strong mode code in the VM, which 9 /// This pass is a temporary measure to run strong mode code in the VM, which
10 /// does not yet have the necessary runtime support. 10 /// does not yet have the necessary runtime support.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 // Skip the visitFunctionNode but traverse body. 70 // Skip the visitFunctionNode but traverse body.
71 node.function.transformChildren(this); 71 node.function.transformChildren(this);
72 node.function.typeParameters.forEach(constantSubstitution.remove); 72 node.function.typeParameters.forEach(constantSubstitution.remove);
73 } else { 73 } else {
74 node.transformChildren(this); 74 node.transformChildren(this);
75 } 75 }
76 return node; 76 return node;
77 } 77 }
78 78
79 bool isObject(DartType type) {
80 return type is InterfaceType && type.classNode.supertype == null;
81 }
82
79 @override 83 @override
80 visitFunctionNode(FunctionNode node) { 84 visitFunctionNode(FunctionNode node) {
81 for (var parameter in node.typeParameters) { 85 for (var parameter in node.typeParameters) {
82 substitution[parameter] = const DynamicType(); 86 substitution[parameter] = const DynamicType();
83 } 87 }
84 for (var parameter in node.typeParameters) { 88 for (var parameter in node.typeParameters) {
85 substitution[parameter] = substitute(parameter.bound, substitution); 89 if (!isObject(parameter.bound)) {
90 substitution[parameter] = substitute(parameter.bound, substitution);
91 }
86 } 92 }
87 node.transformChildren(this); 93 node.transformChildren(this);
88 node.typeParameters.forEach(substitution.remove); 94 node.typeParameters.forEach(substitution.remove);
89 node.typeParameters.clear(); 95 node.typeParameters.clear();
90 return node; 96 return node;
91 } 97 }
92 98
93 @override 99 @override
94 visitStaticInvocation(StaticInvocation node) { 100 visitStaticInvocation(StaticInvocation node) {
95 if (node.target.kind != ProcedureKind.Factory) { 101 if (node.target.kind != ProcedureKind.Factory) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 138 }
133 139
134 @override 140 @override
135 visitMapLiteral(MapLiteral node) { 141 visitMapLiteral(MapLiteral node) {
136 if (node.isConst) pushConstantContext(); 142 if (node.isConst) pushConstantContext();
137 node.transformChildren(this); 143 node.transformChildren(this);
138 if (node.isConst) popConstantContext(); 144 if (node.isConst) popConstantContext();
139 return node; 145 return node;
140 } 146 }
141 } 147 }
OLDNEW
« 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