Index: pkg/analyzer/test/src/dart/analysis/driver_test.dart |
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart |
index fc61b3d250b794ac6244c2169f1cf67679103b04..b488b30031e043b08a9934689a7d23287887f750 100644 |
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart |
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart |
@@ -432,6 +432,24 @@ class C { |
expect(_getClassFieldType(result.unit, 'C', 'f'), 'int'); |
} |
+ test_getResult_inferTypes_instanceMethod() async { |
+ _addTestFile( |
+ r''' |
+class A { |
+ int m(double p) => 1; |
+} |
+class B extends A { |
+ m(double p) => 2; |
+} |
+''', |
+ priority: true); |
+ await _waitForIdle(); |
+ |
+ AnalysisResult result = await driver.getResult(testFile); |
+ expect(_getClassMethodReturnType(result.unit, 'A', 'm'), 'int'); |
+ expect(_getClassMethodReturnType(result.unit, 'B', 'm'), 'int'); |
+ } |
+ |
test_getResult_mix_fileAndPackageUris() async { |
var a = _p('/test/bin/a.dart'); |
var b = _p('/test/bin/b.dart'); |
@@ -1033,6 +1051,29 @@ var A = B; |
return _getClassField(unit, className, fieldName).element.type.toString(); |
} |
+ MethodDeclaration _getClassMethod( |
+ CompilationUnit unit, String className, String methodName) { |
+ ClassDeclaration classDeclaration = _getClass(unit, className); |
+ for (ClassMember declaration in classDeclaration.members) { |
+ if (declaration is MethodDeclaration && |
+ declaration.name.name == methodName) { |
+ return declaration; |
+ } |
+ } |
+ fail('Cannot find the method $methodName in the class $className in\n' |
+ '$unit'); |
+ return null; |
+ } |
+ |
+ String _getClassMethodReturnType( |
+ CompilationUnit unit, String className, String fieldName) { |
+ return _getClassMethod(unit, className, fieldName) |
+ .element |
+ .type |
+ .returnType |
+ .toString(); |
+ } |
+ |
ImportElement _getImportElement(CompilationUnit unit, int directiveIndex) { |
var import = unit.directives[directiveIndex] as ImportDirective; |
return import.element as ImportElement; |