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

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

Issue 2757143002: The parameter of synthetic setters should inherit 'covariant'. (Closed)
Patch Set: Created 3 years, 9 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
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 analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/error/listener.dart'; 9 import 'package:analyzer/error/listener.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 7699 matching lines...) Expand 10 before | Expand all | Expand 10 after
7710 } 7710 }
7711 7711
7712 test_field() { 7712 test_field() {
7713 UnlinkedClass cls = serializeClassText('class C { int i; }'); 7713 UnlinkedClass cls = serializeClassText('class C { int i; }');
7714 UnlinkedVariable variable = findVariable('i', variables: cls.fields); 7714 UnlinkedVariable variable = findVariable('i', variables: cls.fields);
7715 expect(variable, isNotNull); 7715 expect(variable, isNotNull);
7716 expect(variable.isConst, isFalse); 7716 expect(variable.isConst, isFalse);
7717 expect(variable.isStatic, isFalse); 7717 expect(variable.isStatic, isFalse);
7718 expect(variable.isFinal, isFalse); 7718 expect(variable.isFinal, isFalse);
7719 expect(variable.initializer, isNull); 7719 expect(variable.initializer, isNull);
7720 expect(variable.inheritsCovariantSlot, isNot(0));
7720 expect(findExecutable('i', executables: cls.executables), isNull); 7721 expect(findExecutable('i', executables: cls.executables), isNull);
7721 expect(findExecutable('i=', executables: cls.executables), isNull); 7722 expect(findExecutable('i=', executables: cls.executables), isNull);
7722 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 7723 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
7723 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); 7724 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C');
7724 expect(unlinkedUnits[0].publicNamespace.names[0].members, isEmpty); 7725 expect(unlinkedUnits[0].publicNamespace.names[0].members, isEmpty);
7725 } 7726 }
7726 7727
7727 test_field_const() { 7728 test_field_const() {
7728 UnlinkedVariable variable = 7729 UnlinkedVariable variable =
7729 serializeClassText('class C { static const int i = 0; }').fields[0]; 7730 serializeClassText('class C { static const int i = 0; }').fields[0];
7730 expect(variable.isConst, isTrue); 7731 expect(variable.isConst, isTrue);
7732 expect(variable.inheritsCovariantSlot, 0);
7731 assertUnlinkedConst(variable.initializer.bodyExpr, 7733 assertUnlinkedConst(variable.initializer.bodyExpr,
7732 operators: [UnlinkedExprOperation.pushInt], ints: [0]); 7734 operators: [UnlinkedExprOperation.pushInt], ints: [0]);
7733 } 7735 }
7734 7736
7735 test_field_documented() { 7737 test_field_documented() {
7736 if (!includeInformative) return; 7738 if (!includeInformative) return;
7737 String text = ''' 7739 String text = '''
7738 class C { 7740 class C {
7739 /** 7741 /**
7740 * Docs 7742 * Docs
7741 */ 7743 */
7742 var v; 7744 var v;
7743 }'''; 7745 }''';
7744 UnlinkedVariable variable = serializeClassText(text).fields[0]; 7746 UnlinkedVariable variable = serializeClassText(text).fields[0];
7745 expect(variable.documentationComment, isNotNull); 7747 expect(variable.documentationComment, isNotNull);
7746 checkDocumentationComment(variable.documentationComment, text); 7748 checkDocumentationComment(variable.documentationComment, text);
7747 } 7749 }
7748 7750
7749 test_field_final() { 7751 test_field_final() {
7750 UnlinkedVariable variable = 7752 UnlinkedVariable variable =
7751 serializeClassText('class C { final int i = 0; }').fields[0]; 7753 serializeClassText('class C { final int i = 0; }').fields[0];
7752 expect(variable.isFinal, isTrue); 7754 expect(variable.isFinal, isTrue);
7755 expect(variable.inheritsCovariantSlot, 0);
7753 assertUnlinkedConst(variable.initializer.bodyExpr, 7756 assertUnlinkedConst(variable.initializer.bodyExpr,
7754 operators: [UnlinkedExprOperation.pushInt], ints: [0]); 7757 operators: [UnlinkedExprOperation.pushInt], ints: [0]);
7755 } 7758 }
7756 7759
7757 test_field_final_notConstExpr() { 7760 test_field_final_notConstExpr() {
7758 UnlinkedVariable variable = serializeClassText(r''' 7761 UnlinkedVariable variable = serializeClassText(r'''
7759 class C { 7762 class C {
7760 final int f = 1 + m(); 7763 final int f = 1 + m();
7761 static int m() => 42; 7764 static int m() => 42;
7762 }''').fields[0]; 7765 }''').fields[0];
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
7864 UnlinkedVariable v = 7867 UnlinkedVariable v =
7865 serializeClassText('class C { static var v; }').fields[0]; 7868 serializeClassText('class C { static var v; }').fields[0];
7866 expect(v.inferredTypeSlot, 0); 7869 expect(v.inferredTypeSlot, 0);
7867 } 7870 }
7868 7871
7869 test_field_static() { 7872 test_field_static() {
7870 UnlinkedVariable variable = 7873 UnlinkedVariable variable =
7871 serializeClassText('class C { static int i; }').fields[0]; 7874 serializeClassText('class C { static int i; }').fields[0];
7872 expect(variable.isStatic, isTrue); 7875 expect(variable.isStatic, isTrue);
7873 expect(variable.initializer, isNull); 7876 expect(variable.initializer, isNull);
7877 expect(variable.inheritsCovariantSlot, 0);
7874 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 7878 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
7875 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); 7879 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C');
7876 expect(unlinkedUnits[0].publicNamespace.names[0].members, hasLength(1)); 7880 expect(unlinkedUnits[0].publicNamespace.names[0].members, hasLength(1));
7877 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].name, 'i'); 7881 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].name, 'i');
7878 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].kind, 7882 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].kind,
7879 ReferenceKind.propertyAccessor); 7883 ReferenceKind.propertyAccessor);
7880 expect( 7884 expect(
7881 unlinkedUnits[0].publicNamespace.names[0].members[0].numTypeParameters, 7885 unlinkedUnits[0].publicNamespace.names[0].members[0].numTypeParameters,
7882 0); 7886 0);
7883 expect( 7887 expect(
7884 unlinkedUnits[0].publicNamespace.names[0].members[0].members, isEmpty); 7888 unlinkedUnits[0].publicNamespace.names[0].members[0].members, isEmpty);
7885 } 7889 }
7886 7890
7887 test_field_static_final() { 7891 test_field_static_final() {
7888 UnlinkedVariable variable = 7892 UnlinkedVariable variable =
7889 serializeClassText('class C { static final int i = 0; }').fields[0]; 7893 serializeClassText('class C { static final int i = 0; }').fields[0];
7890 expect(variable.isStatic, isTrue); 7894 expect(variable.isStatic, isTrue);
7891 expect(variable.isFinal, isTrue); 7895 expect(variable.isFinal, isTrue);
7892 expect(variable.initializer.bodyExpr, isNull); 7896 expect(variable.initializer.bodyExpr, isNull);
7897 expect(variable.inheritsCovariantSlot, 0);
7893 } 7898 }
7894 7899
7895 test_field_static_final_untyped() { 7900 test_field_static_final_untyped() {
7896 UnlinkedVariable variable = 7901 UnlinkedVariable variable =
7897 serializeClassText('class C { static final x = 0; }').fields[0]; 7902 serializeClassText('class C { static final x = 0; }').fields[0];
7898 expect(variable.initializer.bodyExpr, isNotNull); 7903 expect(variable.initializer.bodyExpr, isNotNull);
7904 expect(variable.inheritsCovariantSlot, 0);
7899 } 7905 }
7900 7906
7901 test_field_untyped() { 7907 test_field_untyped() {
7902 UnlinkedVariable variable = 7908 UnlinkedVariable variable =
7903 serializeClassText('class C { var x = 0; }').fields[0]; 7909 serializeClassText('class C { var x = 0; }').fields[0];
7904 expect(variable.initializer.bodyExpr, isNotNull); 7910 expect(variable.initializer.bodyExpr, isNotNull);
7911 expect(variable.inheritsCovariantSlot, isNot(0));
7905 } 7912 }
7906 7913
7907 test_fully_linked_references_follow_other_references() { 7914 test_fully_linked_references_follow_other_references() {
7908 if (!strongMode || skipFullyLinkedData) { 7915 if (!strongMode || skipFullyLinkedData) {
7909 return; 7916 return;
7910 } 7917 }
7911 serializeLibraryText('final x = 0; String y;'); 7918 serializeLibraryText('final x = 0; String y;');
7912 checkLinkedTypeSlot( 7919 checkLinkedTypeSlot(
7913 unlinkedUnits[0].variables[0].inferredTypeSlot, 'dart:core', 'int'); 7920 unlinkedUnits[0].variables[0].inferredTypeSlot, 'dart:core', 'int');
7914 checkTypeRef(unlinkedUnits[0].variables[1].type, 'dart:core', 'String'); 7921 checkTypeRef(unlinkedUnits[0].variables[1].type, 'dart:core', 'String');
(...skipping 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after
10608 */ 10615 */
10609 class _PrefixExpectation { 10616 class _PrefixExpectation {
10610 final ReferenceKind kind; 10617 final ReferenceKind kind;
10611 final String name; 10618 final String name;
10612 final String absoluteUri; 10619 final String absoluteUri;
10613 final int numTypeParameters; 10620 final int numTypeParameters;
10614 10621
10615 _PrefixExpectation(this.kind, this.name, 10622 _PrefixExpectation(this.kind, this.name,
10616 {this.absoluteUri, this.numTypeParameters: 0}); 10623 {this.absoluteUri, this.numTypeParameters: 0});
10617 } 10624 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/strong_mode_driver_test.dart ('k') | pkg/analyzer/test/src/summary/top_level_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698