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

Unified Diff: pkg/analyzer/test/src/summary/linker_test.dart

Issue 2002353006: Fix some corner cases of inferring type parameters from bounds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/summary/link.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/src/summary/linker_test.dart
diff --git a/pkg/analyzer/test/src/summary/linker_test.dart b/pkg/analyzer/test/src/summary/linker_test.dart
index c067a9e682e5d2a94f98bedb3c5ce92711300ab3..f64a448299b0729bc58f51372df2d86de7789816 100644
--- a/pkg/analyzer/test/src/summary/linker_test.dart
+++ b/pkg/analyzer/test/src/summary/linker_test.dart
@@ -508,6 +508,56 @@ class D extends C {
'int');
}
+ void test_instantiate_param_of_param_to_bounds() {
+ createLinker('''
+class C<T> {}
+class D<T extends num> {}
+final x = new C<D>();
+''');
+ LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
+ library.libraryCycleForLink.ensureLinked();
+ PropertyAccessorElementForLink_Variable x = library.getContainedName('x');
+ ParameterizedType type1 = x.returnType;
+ expect(type1.element.name, 'C');
+ expect(type1.typeArguments, hasLength(1));
+ ParameterizedType type2 = type1.typeArguments[0];
+ expect(type2.element.name, 'D');
+ expect(type2.typeArguments, hasLength(1));
+ DartType type3 = type2.typeArguments[0];
+ expect(type3.toString(), 'num');
+ }
+
+ void test_instantiate_param_to_bounds_class() {
+ createLinker('''
+class C<T extends num> {}
+final x = new C();
+''');
+ LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
+ library.libraryCycleForLink.ensureLinked();
+ PropertyAccessorElementForLink_Variable x = library.getContainedName('x');
+ ParameterizedType type1 = x.returnType;
+ expect(type1.element.name, 'C');
+ expect(type1.typeArguments, hasLength(1));
+ DartType type2 = type1.typeArguments[0];
+ expect(type2.toString(), 'num');
+ }
+
+ void test_instantiate_param_to_bounds_typedef() {
+ createLinker('''
+typedef T F<T extends num>();
+final x = new List<F>();
+''');
+ LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
+ library.libraryCycleForLink.ensureLinked();
+ PropertyAccessorElementForLink_Variable x = library.getContainedName('x');
+ ParameterizedType type1 = x.returnType;
+ expect(type1.element.name, 'List');
+ expect(type1.typeArguments, hasLength(1));
+ FunctionType type2 = type1.typeArguments[0];
+ expect(type2.element.name, 'F');
+ expect(type2.returnType.toString(), 'num');
+ }
+
void test_leastUpperBound_functionAndClass() {
createLinker('''
class C {}
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698