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

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

Issue 2661793002: Infer UnlinkedExprOperation.pushThis as dynamic. (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
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_common.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 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 5943 matching lines...) Expand 10 before | Expand all | Expand 10 after
5954 expect(param.initializer, isNotNull); 5954 expect(param.initializer, isNotNull);
5955 expect(param.defaultValueCode, 'foo'); 5955 expect(param.defaultValueCode, 'foo');
5956 assertUnlinkedConst(param.initializer.bodyExpr, operators: [ 5956 assertUnlinkedConst(param.initializer.bodyExpr, operators: [
5957 UnlinkedExprOperation.pushReference 5957 UnlinkedExprOperation.pushReference
5958 ], referenceValidators: [ 5958 ], referenceValidators: [
5959 (EntityRef r) => checkTypeRef(r, null, null, 'foo', 5959 (EntityRef r) => checkTypeRef(r, null, null, 'foo',
5960 expectedKind: ReferenceKind.topLevelFunction) 5960 expectedKind: ReferenceKind.topLevelFunction)
5961 ]); 5961 ]);
5962 } 5962 }
5963 5963
5964 test_executable_param_isFinal() {
5965 String text = 'f(x, final y) {}';
5966 UnlinkedExecutable executable = serializeExecutableText(text);
5967 expect(executable.parameters, hasLength(2));
5968 expect(executable.parameters[0].name, 'x');
5969 expect(executable.parameters[0].isFinal, isFalse);
5970 expect(executable.parameters[1].name, 'y');
5971 expect(executable.parameters[1].isFinal, isTrue);
5972 }
5973
5964 test_executable_param_kind_named() { 5974 test_executable_param_kind_named() {
5965 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); 5975 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}');
5966 UnlinkedParam param = executable.parameters[0]; 5976 UnlinkedParam param = executable.parameters[0];
5967 expect(param.kind, UnlinkedParamKind.named); 5977 expect(param.kind, UnlinkedParamKind.named);
5968 expect(param.initializer, isNull); 5978 expect(param.initializer, isNull);
5969 expect(param.defaultValueCode, isEmpty); 5979 expect(param.defaultValueCode, isEmpty);
5970 } 5980 }
5971 5981
5972 test_executable_param_kind_named_withDefault() { 5982 test_executable_param_kind_named_withDefault() {
5973 UnlinkedExecutable executable = serializeExecutableText('f({x: 42}) {}'); 5983 UnlinkedExecutable executable = serializeExecutableText('f({x: 42}) {}');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6014 test_executable_param_name() { 6024 test_executable_param_name() {
6015 String text = 'f(x) {}'; 6025 String text = 'f(x) {}';
6016 UnlinkedExecutable executable = serializeExecutableText(text); 6026 UnlinkedExecutable executable = serializeExecutableText(text);
6017 expect(executable.parameters, hasLength(1)); 6027 expect(executable.parameters, hasLength(1));
6018 expect(executable.parameters[0].name, 'x'); 6028 expect(executable.parameters[0].name, 'x');
6019 if (includeInformative) { 6029 if (includeInformative) {
6020 expect(executable.parameters[0].nameOffset, text.indexOf('x')); 6030 expect(executable.parameters[0].nameOffset, text.indexOf('x'));
6021 } 6031 }
6022 } 6032 }
6023 6033
6024 test_executable_param_isFinal() {
6025 String text = 'f(x, final y) {}';
6026 UnlinkedExecutable executable = serializeExecutableText(text);
6027 expect(executable.parameters, hasLength(2));
6028 expect(executable.parameters[0].name, 'x');
6029 expect(executable.parameters[0].isFinal, isFalse);
6030 expect(executable.parameters[1].name, 'y');
6031 expect(executable.parameters[1].isFinal, isTrue);
6032 }
6033
6034 test_executable_param_no_flags() { 6034 test_executable_param_no_flags() {
6035 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); 6035 UnlinkedExecutable executable = serializeExecutableText('f(x) {}');
6036 expect(executable.parameters[0].isFunctionTyped, isFalse); 6036 expect(executable.parameters[0].isFunctionTyped, isFalse);
6037 expect(executable.parameters[0].isInitializingFormal, isFalse); 6037 expect(executable.parameters[0].isInitializingFormal, isFalse);
6038 } 6038 }
6039 6039
6040 test_executable_param_non_function_typed() { 6040 test_executable_param_non_function_typed() {
6041 UnlinkedExecutable executable = serializeExecutableText('f(g) {}'); 6041 UnlinkedExecutable executable = serializeExecutableText('f(g) {}');
6042 expect(executable.parameters[0].isFunctionTyped, isFalse); 6042 expect(executable.parameters[0].isFunctionTyped, isFalse);
6043 } 6043 }
(...skipping 1658 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_this() {
7713 if (skipNonConstInitializers) {
7714 return;
7715 }
7716 UnlinkedVariable variable = serializeVariableText('''
7717 final v = this;
7718 ''');
7719 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
7720 UnlinkedExprOperation.pushThis,
7721 ]);
7722 }
7723
7712 test_expr_throwException() { 7724 test_expr_throwException() {
7713 if (skipNonConstInitializers) { 7725 if (skipNonConstInitializers) {
7714 return; 7726 return;
7715 } 7727 }
7716 UnlinkedVariable variable = serializeVariableText(''' 7728 UnlinkedVariable variable = serializeVariableText('''
7717 final v = throw 1 + 2; 7729 final v = throw 1 + 2;
7718 '''); 7730 ''');
7719 assertUnlinkedConst(variable.initializer.bodyExpr, 7731 assertUnlinkedConst(variable.initializer.bodyExpr,
7720 isValidConst: false, 7732 isValidConst: false,
7721 operators: [ 7733 operators: [
(...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after
10627 class _PrefixExpectation { 10639 class _PrefixExpectation {
10628 final ReferenceKind kind; 10640 final ReferenceKind kind;
10629 final String name; 10641 final String name;
10630 final String absoluteUri; 10642 final String absoluteUri;
10631 final String relativeUri; 10643 final String relativeUri;
10632 final int numTypeParameters; 10644 final int numTypeParameters;
10633 10645
10634 _PrefixExpectation(this.kind, this.name, 10646 _PrefixExpectation(this.kind, this.name,
10635 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 10647 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
10636 } 10648 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_common.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698