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

Unified Diff: sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart

Issue 11365150: Relax some type annotations in concrete type inference. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Restrict the string hack to tests Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/cpa_inference_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
index 56658682213286a0da77225de9891bd4435efc1f..b74315b274762ceae19cc7ee6ae95464bafdd841 100644
--- a/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
@@ -366,6 +366,14 @@ class ConcreteTypesInferrer {
final Compiler compiler;
/**
+ * When true, the string litteral [:"__dynamic_for_test":] is inferred to
+ * have the unknown type.
+ */
+ // TODO(polux): get rid of this hack once we have a natural way of inferring
+ // the unknown type.
+ bool testMode = false;
+
+ /**
* Constants representing builtin base types. Initialized in [analyzeMain]
* and not in the constructor because the compiler elements are not yet
* populated.
@@ -479,9 +487,9 @@ class ConcreteTypesInferrer {
/**
* Returns all the members with name [methodName].
*/
- List<FunctionElement> getMembersByName(SourceString methodName) {
+ List<Element> getMembersByName(SourceString methodName) {
// TODO(polux): make this faster!
- var result = new List<FunctionElement>();
+ var result = new List<Element>();
for (ClassElement cls in compiler.enqueuer.resolution.seenClasses) {
Element elem = cls.lookupLocalMember(methodName);
if (elem != null) {
@@ -1029,7 +1037,7 @@ class TypeInferrerVisitor extends ResolvedVisitor<ConcreteType> {
}
if (receiverType.isUnkown()) {
- for (FunctionElement member in inferrer.getMembersByName(source)) {
+ for (Element member in inferrer.getMembersByName(source)) {
Element classElem = member.getEnclosingClass();
BaseType baseReceiverType = new ClassBaseType(classElem);
augmentField(baseReceiverType, member);
@@ -1098,6 +1106,12 @@ class TypeInferrerVisitor extends ResolvedVisitor<ConcreteType> {
}
ConcreteType visitLiteralString(LiteralString node) {
+ // TODO(polux): get rid of this hack once we have a natural way of inferring
+ // the unknown type.
+ if (inferrer.testMode
+ && node.dartString.slowToString() == "__dynamic_for_test") {
+ return new ConcreteType.unknown();
+ }
return new ConcreteType.singleton(inferrer.baseTypes.stringBaseType);
}
@@ -1403,9 +1417,13 @@ class TypeInferrerVisitor extends ResolvedVisitor<ConcreteType> {
ConcreteType result = new ConcreteType.empty();
if (receiverType.isUnkown()) {
- List<FunctionElement> methods =
+ List<Element> methods =
inferrer.getMembersByName(canonicalizedMethodName);
- for (FunctionElement method in methods) {
+ for (Element element in methods) {
+ // TODO(polux): when we handle closures, we must handle sends to fields
+ // that are closures.
+ if (!element.isFunction()) continue;
+ FunctionElement method = element;
inferrer.addCaller(method, currentMethod);
Element classElem = method.enclosingElement;
ClassBaseType baseReceiverType = new ClassBaseType(classElem);
« no previous file with comments | « no previous file | tests/compiler/dart2js/cpa_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698