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

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

Issue 1902593005: In summary linker, drop trailing type args of type `dynamic`. (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
« 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/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index cfde5e914235cb605781ff1f3de86bad8442111f..3768185d4c2acc5bf93e3344f65e6f451fbec5cf 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -7298,6 +7298,21 @@ p.B b;
expect(unlinkedUnits[0].imports[0].uri, 'dart:async');
}
+ test_inferred_type_keeps_leading_dynamic() {
+ if (!strongMode || skipFullyLinkedData) {
+ return;
+ }
+ UnlinkedClass cls =
+ serializeClassText('class C { final x = <dynamic, int>{}; }');
+ EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot);
+ // Check that x has inferred type `Map<dynamic, int>`.
+ checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map',
+ allowTypeArguments: true, numTypeParameters: 2);
+ expect(type.typeArguments, hasLength(2));
+ checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic');
+ checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int');
+ }
+
test_inferred_type_refers_to_bound_type_param() {
if (!strongMode || skipFullyLinkedData) {
return;
@@ -7435,6 +7450,32 @@ p.B b;
checkReferenceIndex(linkedReference.containingReference, null, null, 'D');
}
+ test_inferred_type_skips_trailing_dynamic() {
+ if (!strongMode || skipFullyLinkedData) {
+ return;
+ }
+ UnlinkedClass cls =
+ serializeClassText('class C { final x = <int, dynamic>{}; }');
+ EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot);
+ // Check that x has inferred type `Map<int>`. The trailing type argument
+ // `dynamic` is omitted.
+ checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map',
+ allowTypeArguments: true, numTypeParameters: 2);
+ expect(type.typeArguments, hasLength(1));
+ checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ }
+
+ test_inferred_type_skips_unnecessary_dynamic() {
+ if (!strongMode || skipFullyLinkedData) {
+ return;
+ }
+ UnlinkedClass cls = serializeClassText('class C { final x = []; }');
+ EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot);
+ // Check that x has inferred type `List`, not `List<dynamic>`.
+ checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List',
+ numTypeParameters: 1);
+ }
+
test_initializer_executable_with_bottom_return_type() {
// The synthetic executable for `v` has type `() => Bottom`.
UnlinkedVariable variable = serializeVariableText('int v = null;');
« 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