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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1993333003: Fix for resynthesizing default values referencing type parameters. (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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/constant/value.dart'; 10 import 'package:analyzer/dart/constant/value.dart';
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // to check that their constructor initializers match, because that 508 // to check that their constructor initializers match, because that
509 // could lead to infinite regress. 509 // could lead to infinite regress.
510 compareElements( 510 compareElements(
511 rConstructor.staticElement, oConstructor.staticElement, desc); 511 rConstructor.staticElement, oConstructor.staticElement, desc);
512 TypeName oType = oConstructor.type; 512 TypeName oType = oConstructor.type;
513 TypeName rType = rConstructor.type; 513 TypeName rType = rConstructor.type;
514 expect(oType, isNotNull, reason: desc); 514 expect(oType, isNotNull, reason: desc);
515 expect(rType, isNotNull, reason: desc); 515 expect(rType, isNotNull, reason: desc);
516 compareConstAsts(rType.name, oType.name, desc); 516 compareConstAsts(rType.name, oType.name, desc);
517 compareConstAsts(rConstructor.name, oConstructor.name, desc); 517 compareConstAsts(rConstructor.name, oConstructor.name, desc);
518 compareConstAstLists(rType.typeArguments?.arguments, 518 // In strong mode type inference is performed, so that
519 oType.typeArguments?.arguments, desc); 519 // `C<int> v = new C();` is serialized as `C<int> v = new C<int>();`.
520 // So, if there are not type arguments originally, not need to check.
521 if (oType.typeArguments?.arguments?.isNotEmpty ?? false) {
522 compareConstAstLists(rType.typeArguments?.arguments,
523 oType.typeArguments?.arguments, desc);
524 }
520 compareConstAstLists( 525 compareConstAstLists(
521 r.argumentList.arguments, o.argumentList.arguments, desc); 526 r.argumentList.arguments, o.argumentList.arguments, desc);
522 } else if (o is AnnotationImpl && r is AnnotationImpl) { 527 } else if (o is AnnotationImpl && r is AnnotationImpl) {
523 expect(o.atSign.lexeme, r.atSign.lexeme, reason: desc); 528 expect(o.atSign.lexeme, r.atSign.lexeme, reason: desc);
524 Identifier rName = r.name; 529 Identifier rName = r.name;
525 Identifier oName = o.name; 530 Identifier oName = o.name;
526 if (oName is PrefixedIdentifier && o.constructorName != null) { 531 if (oName is PrefixedIdentifier && o.constructorName != null) {
527 // E.g. `@prefix.cls.ctor`. This gets resynthesized as `@cls.ctor`, 532 // E.g. `@prefix.cls.ctor`. This gets resynthesized as `@cls.ctor`,
528 // with `cls.ctor` represented as a PrefixedIdentifier. 533 // with `cls.ctor` represented as a PrefixedIdentifier.
529 expect(rName, new isInstanceOf<PrefixedIdentifier>(), reason: desc); 534 expect(rName, new isInstanceOf<PrefixedIdentifier>(), reason: desc);
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 2525
2521 test_constExpr_pushReference_staticMethod_simpleIdentifier() { 2526 test_constExpr_pushReference_staticMethod_simpleIdentifier() {
2522 checkLibrary(''' 2527 checkLibrary('''
2523 class C { 2528 class C {
2524 static const a = m; 2529 static const a = m;
2525 static m() {} 2530 static m() {}
2526 } 2531 }
2527 '''); 2532 ''');
2528 } 2533 }
2529 2534
2535 test_constructor_default_refers_to_generic_class() {
2536 checkLibrary('''
2537 class B<T> {
2538 const B();
2539 }
2540 class C<T> {
2541 const C([B<T> b = const B()]);
2542 }
2543 ''');
2544 }
2545
2546 test_constructor_default_refers_to_generic_class2() {
2547 checkLibrary('''
2548 abstract class A<T> {}
2549 class B<T> implements A<T> {
2550 const B();
2551 }
2552 class C<T> implements A<Iterable<T>> {
2553 const C([A<T> a = const B()]);
2554 }
2555 ''');
2556 }
2557
2530 test_constructor_documented() { 2558 test_constructor_documented() {
2531 checkLibrary(''' 2559 checkLibrary('''
2532 class C { 2560 class C {
2533 /** 2561 /**
2534 * Docs 2562 * Docs
2535 */ 2563 */
2536 C(); 2564 C();
2537 }'''); 2565 }''');
2538 } 2566 }
2539 2567
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 fail('Unexpectedly tried to get unlinked summary for $uri'); 4556 fail('Unexpectedly tried to get unlinked summary for $uri');
4529 } 4557 }
4530 return serializedUnit; 4558 return serializedUnit;
4531 } 4559 }
4532 4560
4533 @override 4561 @override
4534 bool hasLibrarySummary(String uri) { 4562 bool hasLibrarySummary(String uri) {
4535 return true; 4563 return true;
4536 } 4564 }
4537 } 4565 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698