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

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

Issue 2661803002: Issue 28491. Add support for UnlinkedExprOperation.pushSuper even though it is not allowed. (Closed)
Patch Set: Created 3 years, 10 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 7691 matching lines...) Expand 10 before | Expand all | Expand 10 after
7702 ], 7702 ],
7703 referenceValidators: [ 7703 referenceValidators: [
7704 (EntityRef r) => checkTypeRef(r, null, null, 'f', 7704 (EntityRef r) => checkTypeRef(r, null, null, 'f',
7705 expectedKind: ReferenceKind.topLevelFunction, 7705 expectedKind: ReferenceKind.topLevelFunction,
7706 numTypeParameters: 2), 7706 numTypeParameters: 2),
7707 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int'), 7707 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int'),
7708 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String') 7708 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String')
7709 ]); 7709 ]);
7710 } 7710 }
7711 7711
7712 test_expr_super() {
7713 if (skipNonConstInitializers) {
7714 return;
7715 }
7716 UnlinkedVariable variable = serializeVariableText('''
7717 final v = super;
7718 ''');
7719 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
7720 UnlinkedExprOperation.pushSuper,
7721 ]);
7722 }
7723
7712 test_expr_this() { 7724 test_expr_this() {
7713 if (skipNonConstInitializers) { 7725 if (skipNonConstInitializers) {
7714 return; 7726 return;
7715 } 7727 }
7716 UnlinkedVariable variable = serializeVariableText(''' 7728 UnlinkedVariable variable = serializeVariableText('''
7717 final v = this; 7729 final v = this;
7718 '''); 7730 ''');
7719 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 7731 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
7720 UnlinkedExprOperation.pushThis, 7732 UnlinkedExprOperation.pushThis,
7721 ]); 7733 ]);
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
9197 .parameters[0] 9209 .parameters[0]
9198 .annotations); 9210 .annotations);
9199 } 9211 }
9200 9212
9201 test_metadata_importDirective() { 9213 test_metadata_importDirective() {
9202 addNamedSource('/foo.dart', 'const b = null;'); 9214 addNamedSource('/foo.dart', 'const b = null;');
9203 serializeLibraryText('@a import "foo.dart"; const a = b;'); 9215 serializeLibraryText('@a import "foo.dart"; const a = b;');
9204 checkAnnotationA(unlinkedUnits[0].imports[0].annotations); 9216 checkAnnotationA(unlinkedUnits[0].imports[0].annotations);
9205 } 9217 }
9206 9218
9219 test_metadata_invalid_instanceCreation_argument_super() {
9220 List<UnlinkedExpr> annotations = serializeClassText('''
9221 class A {
9222 const A(_);
9223 }
9224
9225 @A(super)
9226 class C {}
9227 ''').annotations;
9228 expect(annotations, hasLength(1));
9229 assertUnlinkedConst(annotations[0], operators: [
9230 UnlinkedExprOperation.pushSuper,
9231 UnlinkedExprOperation.invokeConstructor,
9232 ], ints: [
9233 0,
9234 1
9235 ], referenceValidators: [
9236 (EntityRef r) => checkTypeRef(r, null, null, 'A',
9237 expectedKind: ReferenceKind.classOrEnum)
9238 ]);
9239 }
9240
9207 test_metadata_invalid_instanceCreation_argument_this() { 9241 test_metadata_invalid_instanceCreation_argument_this() {
9208 List<UnlinkedExpr> annotations = serializeClassText(''' 9242 List<UnlinkedExpr> annotations = serializeClassText('''
9209 class A { 9243 class A {
9210 const A(_); 9244 const A(_);
9211 } 9245 }
9212 9246
9213 @A(this) 9247 @A(this)
9214 class C {} 9248 class C {}
9215 ''').annotations; 9249 ''').annotations;
9216 expect(annotations, hasLength(1)); 9250 expect(annotations, hasLength(1));
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
10639 class _PrefixExpectation { 10673 class _PrefixExpectation {
10640 final ReferenceKind kind; 10674 final ReferenceKind kind;
10641 final String name; 10675 final String name;
10642 final String absoluteUri; 10676 final String absoluteUri;
10643 final String relativeUri; 10677 final String relativeUri;
10644 final int numTypeParameters; 10678 final int numTypeParameters;
10645 10679
10646 _PrefixExpectation(this.kind, this.name, 10680 _PrefixExpectation(this.kind, this.name,
10647 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 10681 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
10648 } 10682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698