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

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

Issue 1306313002: Implement instance member inference (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address more comments and fix bug Created 5 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 6fe292ae7bb080e3ab0050adf1156820a35d321f..8fff9629095c869cf432e34472874a75caf485fd 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -10706,6 +10706,11 @@ class ResolverVisitor extends ScopedVisitor {
@override
Object visitDefaultFormalParameter(DefaultFormalParameter node) {
super.visitDefaultFormalParameter(node);
+ ParameterElement element = node.element;
+ if (element.initializer != null && node.defaultValue != null) {
+ (element.initializer as FunctionElementImpl).returnType =
+ node.defaultValue.staticType;
+ }
FormalParameterList parent = node.parent;
AstNode grandparent = parent.parent;
if (grandparent is ConstructorDeclaration &&
@@ -11131,6 +11136,10 @@ class ResolverVisitor extends ScopedVisitor {
Object visitVariableDeclaration(VariableDeclaration node) {
super.visitVariableDeclaration(node);
VariableElement element = node.element;
+ if (element.initializer != null && node.initializer != null) {
+ (element.initializer as FunctionElementImpl).returnType =
+ node.initializer.staticType;
+ }
// Note: in addition to cloning the initializers for const variables, we
// have to clone the initializers for non-static final fields (because if
// they occur in a class with a const constructor, they will be needed to
@@ -14673,6 +14682,12 @@ abstract class TypeSystem {
* Compute the least upper bound of two types.
*/
DartType getLeastUpperBound(DartType type1, DartType type2);
+
+ /**
+ * Return `true` if the [leftType] is a subtype of the [rightType] (that is,
+ * if leftType <: rightType).
+ */
+ bool isSubtypeOf(DartType leftType, DartType rightType);
}
/**
@@ -14762,6 +14777,11 @@ class TypeSystemImpl implements TypeSystem {
return typeProvider.dynamicType;
}
}
+
+ @override
+ bool isSubtypeOf(DartType leftType, DartType rightType) {
+ return leftType.isSubtypeOf(rightType);
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698