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

Unified Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2491533002: Don't ovewrite method types of a resynthesized library in TypeResolverVisitor. (Closed)
Patch Set: Created 4 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
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;
« pkg/analyzer/lib/src/generated/resolver.dart ('K') | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698