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

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

Issue 2795893002: Fix missing partial type in downwards map inference. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30188ffc31d455753ac985047284c67a8afc3de1..dab4bab51d151d4ae5e9d66093f72b1d1d335bbc 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -1074,6 +1074,47 @@ class StrongModeLocalInferenceTest extends ResolverTestCase {
_isFutureOfNull(invoke.staticType);
}
+ test_generic_partial() async {
+ // Test that upward and downward type inference handles partial
+ // type schemas correctly. Downwards inference in a partial context
+ // (e.g. Map<String, ?>) should still allow upwards inference to fill
+ // in the missing information.
+ String code = r'''
+class A<T> {
+ A(T x);
+ A.fromA(A<T> a) {}
+ A.fromMap(Map<String, T> m) {}
+ A.fromList(List<T> m) {}
+ A.fromT(T t) {}
+ A.fromB(B<T, String> a) {}
+}
+
+class B<S, T> {
+ B(S s);
+}
+
+void test() {
+ var a0 = new A.fromA(new A(3));
+ var a1 = new A.fromMap({'hello' : 3});
+ var a2 = new A.fromList([3]);
+ var a3 = new A.fromT(3);
+ var a4 = new A.fromB(new B(3));
+}
+ ''';
+ CompilationUnit unit = await resolveSource(code);
+ Element elementA = AstFinder.getClass(unit, "A").element;
+ List<Statement> statements =
+ AstFinder.getStatementsInTopLevelFunction(unit, "test");
+ DartType check(int i) {
+ VariableDeclarationStatement stmt = statements[i];
+ VariableDeclaration decl = stmt.variables.variables[0];
+ Expression init = decl.initializer;
+ _isInstantiationOf(_hasElement(elementA))([_isInt])(init.staticType);
+ }
+
+ for (var i = 0; i < 5; i++) check(i);
+ }
+
test_inferConstructor_unknownTypeLowerBound() async {
Source source = addSource(r'''
class C<T> {
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698