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

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

Issue 1585323003: fix #25486, promote from dynamic in strong mode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/resolver_test.dart
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index f23907e9e3a9e7dc439c213492331c748de5de36..17148e2ecb3226f4a6f96334002d9c2f54f4e983 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -2276,6 +2276,44 @@ class C {
}
}
+/**
+ * Tests for generic method and function resolution that do not use strong mode.
+ */
+@reflectiveTest
+class GenericMethodResolverTest extends _StaticTypeAnalyzer2TestShared {
+ void setUp() {
+ super.setUp();
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.enableGenericMethods = true;
+ resetWithOptions(options);
+ }
+
+ void test_genericMethod_propagatedType_promotion() {
+ // Regression test for:
+ // https://github.com/dart-lang/sdk/issues/25340
+ //
+ // Note, after https://github.com/dart-lang/sdk/issues/25486 the original
+ // strong mode example won't work, as we now compute a static type and
+ // therefore discard the propagated type.
+ //
+ // So this test does not use strong mode.
+ _resolveTestUnit(r'''
+abstract class Iter {
+ List<S> map<S>(S f(x));
+}
+class C {}
+C toSpan(dynamic element) {
+ if (element is Iter) {
+ var y = element.map(toSpan);
+ }
+ return null;
+}''');
+ SimpleIdentifier y = _findIdentifier('y = ');
+ expect(y.staticType.toString(), 'dynamic');
+ expect(y.propagatedType.toString(), 'List<dynamic>');
+ }
+}
+
@reflectiveTest
class HintCodeTest extends ResolverTestCase {
void fail_deadCode_statementAfterRehrow() {
@@ -13596,6 +13634,11 @@ class D extends C {
void test_genericMethod_propagatedType_promotion() {
// Regression test for:
// https://github.com/dart-lang/sdk/issues/25340
+
+ // Note, after https://github.com/dart-lang/sdk/issues/25486 the original
+ // example won't work, as we now compute a static type and therefore discard
+ // the propagated type. So a new test was created that doesn't run under
+ // strong mode.
_resolveTestUnit(r'''
abstract class Iter {
List/*<S>*/ map/*<S>*/(/*=S*/ f(x));
@@ -13608,8 +13651,8 @@ C toSpan(dynamic element) {
return null;
}''');
SimpleIdentifier y = _findIdentifier('y = ');
- expect(y.staticType.toString(), 'dynamic');
- expect(y.propagatedType.toString(), 'List<dynamic>');
+ expect(y.staticType.toString(), 'List<C>');
+ expect(y.propagatedType, isNull);
}
void test_genericMethod_tearoff() {
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.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