Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 | 4 |
| 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be | 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be |
| 6 // refactored to fit into analyzer. | 6 // refactored to fit into analyzer. |
| 7 library analyzer.src.task.strong.rules; | 7 library analyzer.src.task.strong.rules; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 : provider = provider, | 50 : provider = provider, |
| 51 objectMembers = getObjectMemberMap(provider) { | 51 objectMembers = getObjectMemberMap(provider) { |
| 52 inferrer = new DownwardsInference(this); | 52 inferrer = new DownwardsInference(this); |
| 53 } | 53 } |
| 54 | 54 |
| 55 /// Given a type t, if t is an interface type with a call method | 55 /// Given a type t, if t is an interface type with a call method |
| 56 /// defined, return the function type for the call method, otherwise | 56 /// defined, return the function type for the call method, otherwise |
| 57 /// return null. | 57 /// return null. |
| 58 FunctionType getCallMethodType(DartType t) { | 58 FunctionType getCallMethodType(DartType t) { |
| 59 if (t is InterfaceType) { | 59 if (t is InterfaceType) { |
| 60 ClassElement element = t.element; | 60 MethodElement callMethod = t.lookUpMethod("call", null); |
| 61 InheritanceManager manager = new InheritanceManager(element.library); | 61 return callMethod != null ? callMethod.type : null; |
|
Paul Berry
2015/10/29 16:29:59
Similar nit here.
| |
| 62 FunctionType callType = manager.lookupMemberType(t, "call"); | |
| 63 return callType; | |
| 64 } | 62 } |
| 65 return null; | 63 return null; |
| 66 } | 64 } |
| 67 | 65 |
| 68 /// Given an expression, return its type assuming it is | 66 /// Given an expression, return its type assuming it is |
| 69 /// in the caller position of a call (that is, accounting | 67 /// in the caller position of a call (that is, accounting |
| 70 /// for the possibility of a call method). Returns null | 68 /// for the possibility of a call method). Returns null |
| 71 /// if expression is not statically callable. | 69 /// if expression is not statically callable. |
| 72 FunctionType getTypeAsCaller(Expression applicand) { | 70 FunctionType getTypeAsCaller(Expression applicand) { |
| 73 var t = getStaticType(applicand); | 71 var t = getStaticType(applicand); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 var entries = e.entries; | 763 var entries = e.entries; |
| 766 bool inferEntry(MapLiteralEntry entry) { | 764 bool inferEntry(MapLiteralEntry entry) { |
| 767 return _inferExpression(entry.key, kType, errors) && | 765 return _inferExpression(entry.key, kType, errors) && |
| 768 _inferExpression(entry.value, vType, errors); | 766 _inferExpression(entry.value, vType, errors); |
| 769 } | 767 } |
| 770 var b = entries.every(inferEntry); | 768 var b = entries.every(inferEntry); |
| 771 if (b) annotateMapLiteral(e, targs); | 769 if (b) annotateMapLiteral(e, targs); |
| 772 return b; | 770 return b; |
| 773 } | 771 } |
| 774 } | 772 } |
| OLD | NEW |