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

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart

Issue 875163004: Support [AssumeDynamic] and [TrustTypeAnnotations] in the inferrer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart ('k') | pkg/expect/lib/expect.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index 36aee0981eb1eaabfd400c8b0578118df48170fb..6a9610dd3a04fe90f936cc68af39cbb1fd851451 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -392,8 +392,11 @@ class MemberTypeInformation extends ElementTypeInformation
TypeMask handleSpecialCases(TypeGraphInferrerEngine inferrer) {
if (element.isField &&
- !inferrer.compiler.backend.canBeUsedForGlobalOptimizations(element)) {
- // Do not infer types for fields being assigned by synthesized calls.
+ (!inferrer.backend.canBeUsedForGlobalOptimizations(element) ||
+ inferrer.annotations.assumeDynamic(element))) {
+ // Do not infer types for fields that have a corresponding annotation or
+ // are assigned by synthesized calls
+
giveUp(inferrer);
return safeType(inferrer);
}
@@ -437,7 +440,9 @@ class MemberTypeInformation extends ElementTypeInformation
TypeMask potentiallyNarrowType(TypeMask mask,
TypeGraphInferrerEngine inferrer) {
Compiler compiler = inferrer.compiler;
- if (!compiler.trustTypeAnnotations && !compiler.enableTypeAssertions) {
+ if (!compiler.trustTypeAnnotations &&
+ !compiler.enableTypeAssertions &&
+ !inferrer.annotations.trustTypeAnnotations(element)) {
return mask;
}
if (element.isGenerativeConstructor ||
@@ -496,6 +501,7 @@ class MemberTypeInformation extends ElementTypeInformation
*/
class ParameterTypeInformation extends ElementTypeInformation {
ParameterElement get element => super.element;
+ FunctionElement get declaration => element.functionDeclaration;
ParameterTypeInformation._internal(ParameterElement element,
TypeInformationSystem types)
@@ -522,9 +528,10 @@ class ParameterTypeInformation extends ElementTypeInformation {
// TODO(herhut): Cleanup into one conditional.
TypeMask handleSpecialCases(TypeGraphInferrerEngine inferrer) {
- if (!inferrer.compiler.backend.canBeUsedForGlobalOptimizations(element)) {
- // Do not infer types for fields and parameters being assigned
- // by synthesized calls.
+ if (!inferrer.backend.canBeUsedForGlobalOptimizations(element) ||
+ inferrer.annotations.assumeDynamic(declaration)) {
+ // Do not infer types for parameters that have a correspondign annotation
+ // or that are assigned by synthesized calls.
giveUp(inferrer);
return safeType(inferrer);
}
@@ -567,7 +574,8 @@ class ParameterTypeInformation extends ElementTypeInformation {
TypeMask potentiallyNarrowType(TypeMask mask,
TypeGraphInferrerEngine inferrer) {
Compiler compiler = inferrer.compiler;
- if (!compiler.trustTypeAnnotations) {
+ if (!compiler.trustTypeAnnotations &&
+ !inferrer.annotations.trustTypeAnnotations(declaration)) {
return mask;
}
// When type assertions are enabled (aka checked mode), we have to always
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart ('k') | pkg/expect/lib/expect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698