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

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

Issue 1658253002: Serialize constant instance creation of generic classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove the special case for unnamed constructors from _getElementReferenceId(). 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.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 3f891590f51f252d6d1a11e0cdee14547c4faf5f..868fab4234c19aa06c4e0e61213c304715f25760 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -1552,6 +1552,185 @@ class E {}
]);
}
+ test_constExpr_invokeConstructor_generic_named() {
+ UnlinkedVariable variable = serializeVariableText('''
+class C<K, V> {
+ const C.named();
+}
+const v = const C<int, String>.named();
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) {
+ checkTypeRef(r, null, null, 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
+ numTypeParameters: 2)
+ ],
+ allowTypeParameters: true);
+ checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
+ }
+ ]);
+ }
+
+ test_constExpr_invokeConstructor_generic_named_imported() {
+ addNamedSource(
+ '/a.dart',
+ '''
+class C<K, V> {
+ const C.named();
+}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart';
+const v = const C<int, String>.named();
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) {
+ checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
+ numTypeParameters: 2)
+ ],
+ allowTypeParameters: true);
+ checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
+ }
+ ]);
+ }
+
+ test_constExpr_invokeConstructor_generic_named_imported_withPrefix() {
+ addNamedSource(
+ '/a.dart',
+ '''
+class C<K, V> {
+ const C.named();
+}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart' as p;
+const v = const p.C<int, String>.named();
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) {
+ checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
+ numTypeParameters: 2),
+ new _PrefixExpectation(ReferenceKind.prefix, 'p',
+ inLibraryDefiningUnit: true)
+ ],
+ allowTypeParameters: true);
+ checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
+ }
+ ]);
+ }
+
+ test_constExpr_invokeConstructor_generic_unnamed() {
+ UnlinkedVariable variable = serializeVariableText('''
+class C<K, V> {
+ const C();
+}
+const v = const C<int, String>();
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) {
+ checkTypeRef(r, null, null, 'C',
+ expectedKind: ReferenceKind.classOrEnum,
+ numTypeParameters: 2,
+ allowTypeParameters: true);
+ checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
+ }
+ ]);
+ }
+
+ test_constExpr_invokeConstructor_generic_unnamed_imported() {
+ addNamedSource(
+ '/a.dart',
+ '''
+class C<K, V> {
+ const C();
+}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart';
+const v = const C<int, String>();
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) {
+ checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
+ expectedKind: ReferenceKind.classOrEnum,
+ numTypeParameters: 2,
+ allowTypeParameters: true);
+ checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
+ }
+ ]);
+ }
+
+ test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() {
+ addNamedSource(
+ '/a.dart',
+ '''
+class C<K, V> {
+ const C();
+}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart' as p;
+const v = const p.C<int, String>();
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) {
+ checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
+ expectedKind: ReferenceKind.classOrEnum,
+ numTypeParameters: 2,
+ allowTypeParameters: true,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.prefix, 'p',
+ inLibraryDefiningUnit: true)
+ ]);
+ checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int');
+ checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String');
+ }
+ ]);
+ }
+
test_constExpr_invokeConstructor_named() {
UnlinkedVariable variable = serializeVariableText('''
class C {
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698