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

Unified Diff: pkg/analyzer/test/generated/strong_mode_test.dart

Issue 1906413004: Fix missing downwards inference on fields, report more inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/test/generated/strong_mode_test.dart
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index 8a5521249976ee46aa761e23ee5e83080f23af06..7bc5ed14206069b9e9cc3ee6130f3d83db46694c 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -681,6 +681,41 @@ class StrongModeDownwardsInferenceTest extends ResolverTestCase {
verify([source]);
}
+ void test_inferredFieldDeclaration_propagation() {
+ // Regression test for https://github.com/dart-lang/sdk/issues/25546
+ String code = r'''
+ abstract class A {
+ Map<int, List<int>> get map;
+ }
+ class B extends A {
+ var map = { 42: [] };
+ }
+ class C extends A {
+ get map => { 43: [] };
+ }
+ ''';
+ CompilationUnit unit = resolveSource(code);
+
+ Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt);
+ Asserter<InterfaceType> assertMapOfIntToListOfInt =
+ _isMapOf(_isInt, assertListOfInt);
+
+ VariableDeclaration mapB = AstFinder.getFieldInClass(unit, "B", "map");
+ MethodDeclaration mapC = AstFinder.getMethodInClass(unit, "C", "map");
+ assertMapOfIntToListOfInt(mapB.element.type);
+ assertMapOfIntToListOfInt(mapC.element.returnType);
+
+ MapLiteral mapLiteralB = mapB.initializer;
+ MapLiteral mapLiteralC = (mapC.body as ExpressionFunctionBody).expression;
+ assertMapOfIntToListOfInt(mapLiteralB.staticType);
+ assertMapOfIntToListOfInt(mapLiteralC.staticType);
+
+ ListLiteral listLiteralB = mapLiteralB.entries[0].value;
+ ListLiteral listLiteralC = mapLiteralC.entries[0].value;
+ assertListOfInt(listLiteralB.staticType);
+ assertListOfInt(listLiteralC.staticType);
+ }
+
void test_instanceCreation() {
String code = r'''
class A<S, T> {
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698