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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2252183002: Fix calling object methods and properties on function types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix calling object methods and properties on function types Created 4 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
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 71d2e7b9ee3e69c16de835b4b74fadfe759730eb..aef1d881cd77f3bbfe49fba85d48b479f07be3fe 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -9613,13 +9613,69 @@ abstract class TypeProvider {
* Return the type representing typenames that can't be resolved.
*/
DartType get undefinedType;
+
+ /**
+ * Return 'true' if [id] is the name of a getter on
+ * the Object type.
+ */
+ bool isObjectGetter(SimpleIdentifier id);
Jennifer Messerly 2016/08/17 21:26:24 maybe pass in the String name here? it seems like
Leaf 2016/08/17 22:07:05 Done.
+
+ /**
+ * Return 'true' if [id] is the name of a method on
+ * the Object type.
+ */
+ bool isObjectMethod(SimpleIdentifier id);
+
+ /**
+ * Return 'true' if [id] is the name of a method or getter on
+ * the Object type.
+ */
+ bool isObjectProperty(SimpleIdentifier id);
Brian Wilkerson 2016/08/17 21:24:15 I think the analyzer code is generally fairly cons
Leaf 2016/08/17 22:07:05 Done.
+}
+
+/**
+ * Provide common functionality shared by the various TypeProvider
+ * implementations
Jennifer Messerly 2016/08/17 21:26:24 nit: should end with period
Leaf 2016/08/17 22:07:05 Done.
+ */
+abstract class TypeProviderBaseMixin {
+ InterfaceType get boolType;
Brian Wilkerson 2016/08/17 21:24:15 Should this just implement TypeProvider (rather th
Leaf 2016/08/17 22:07:05 Nice. Didn't realize you could do this, much bett
+ InterfaceType get doubleType;
+ InterfaceType get intType;
+ List<InterfaceType> get nonSubtypableTypes => <InterfaceType>[
+ nullType,
+ numType,
+ intType,
+ doubleType,
+ boolType,
+ stringType
+ ];
+ InterfaceType get nullType;
+ InterfaceType get numType;
+ InterfaceType get objectType;
+ InterfaceType get stringType;
+
+ bool isObjectGetter(SimpleIdentifier id) {
+ PropertyAccessorElement element = objectType.element.getGetter(id.name);
+ return (element != null && !element.isStatic);
+ }
+
+ bool isObjectMethod(SimpleIdentifier id) {
+ MethodElement element = objectType.element.getMethod(id.name);
+ return (element != null && !element.isStatic);
+ }
+
+ bool isObjectProperty(SimpleIdentifier id) {
+ return isObjectGetter(id) || isObjectMethod(id);
+ }
}
/**
* Instances of the class `TypeProviderImpl` provide access to types defined by the language
* by looking for those types in the element model for the core library.
*/
-class TypeProviderImpl implements TypeProvider {
+class TypeProviderImpl extends Object
+ with TypeProviderBaseMixin
Jennifer Messerly 2016/08/17 21:26:24 in current Dart, this is equivalent to "extends Ty
Leaf 2016/08/17 22:07:05 Done.
+ implements TypeProvider {
/**
* The type representing the built-in type 'bool'.
*/
@@ -9809,16 +9865,6 @@ class TypeProviderImpl implements TypeProvider {
InterfaceType get mapType => _mapType;
@override
- List<InterfaceType> get nonSubtypableTypes => <InterfaceType>[
- nullType,
- numType,
- intType,
- doubleType,
- boolType,
- stringType
- ];
-
- @override
DartObjectImpl get nullObject {
if (_nullObject == null) {
_nullObject = new DartObjectImpl(nullType, NullState.NULL_STATE);
« no previous file with comments | « pkg/analyzer/lib/src/generated/element_resolver.dart ('k') | pkg/analyzer/lib/src/generated/testing/test_type_provider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698