Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f396236

Browse files
nshahancommit-bot@chromium.org
authored andcommitted
[ddc] Add language version to test files
Avoids breaks that appear when enabling the `nnbd` experiment by default as seen in: https://dart-review.googlesource.com/c/sdk/+/166790 Some of these synthetic files are created as packages but the expression compiler wasn't designed to handle that information. In the future we should support language versioning better in the expression compiler or setup similar tests for opted in code since in reality the language versioning might be handled by the dev build system. Fixes: dart-lang/sdk#43843 Change-Id: Icfac40d1c9b47e75fb92d7672700e066ac372267 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168441 Reviewed-by: Anna Gringauze <annagrin@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
1 parent 92704cf commit f396236

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ void main() {
262262

263263
group('Expression compiler tests in extension method:', () {
264264
const source = '''
265+
// @dart = 2.9
265266
extension NumberParsing on String {
266267
int parseInt() {
267268
var ret = int.parse(this);
@@ -312,6 +313,7 @@ void main() {
312313

313314
group('Expression compiler tests in method:', () {
314315
const source = '''
316+
// @dart = 2.9
315317
extension NumberParsing on String {
316318
int parseInt() {
317319
return int.parse(this);
@@ -565,6 +567,7 @@ void main() {
565567

566568
group('Expression compiler tests in method with no field access:', () {
567569
const source = '''
570+
// @dart = 2.9
568571
extension NumberParsing on String {
569572
int parseInt() {
570573
return int.parse(this);
@@ -726,6 +729,7 @@ void main() {
726729

727730
group('Expression compiler tests in async method:', () {
728731
const source = '''
732+
// @dart = 2.9
729733
class C {
730734
C(int this.field, int this._field);
731735
@@ -786,6 +790,7 @@ void main() {
786790

787791
group('Expression compiler tests in global function:', () {
788792
const source = '''
793+
// @dart = 2.9
789794
extension NumberParsing on String {
790795
int parseInt() {
791796
return int.parse(this);
@@ -1044,6 +1049,7 @@ void main() {
10441049

10451050
group('Expression compiler tests in closures:', () {
10461051
const source = r'''
1052+
// @dart = 2.9
10471053
int globalFunction() {
10481054
int x = 15;
10491055
var c = C(1, 2);
@@ -1108,6 +1114,7 @@ void main() {
11081114

11091115
group('Expression compiler tests in method with no type use', () {
11101116
const source = '''
1117+
// @dart = 2.9
11111118
abstract class Key {
11121119
const factory Key(String value) = ValueKey;
11131120
const Key.empty();

pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,14 @@ _testPackage:lib/
102102
File.fromUri(main)
103103
..createSync(recursive: true)
104104
..writeAsStringSync('''
105+
// @dart = 2.9
105106
import 'package:_testPackage/test_library.dart';
106107
107108
var global = 0;
108109
109110
void main() {
110111
var count = 0;
111-
// line 7
112+
// line 8
112113
print('Global is: \${++global}');
113114
print('Count is: \${++count}');
114115
@@ -120,10 +121,11 @@ void main() {
120121
File.fromUri(testLibrary)
121122
..createSync()
122123
..writeAsStringSync('''
124+
// @dart = 2.9
123125
import 'package:_testPackage/test_library2.dart';
124126
125127
int testLibraryFunction(int formal) {
126-
return formal; // line 4
128+
return formal; // line 5
127129
}
128130
129131
int callLibraryFunction2(int formal) {
@@ -139,8 +141,9 @@ class B {
139141
File.fromUri(testLibrary2)
140142
..createSync()
141143
..writeAsStringSync('''
144+
// @dart = 2.9
142145
int testLibraryFunction2(int formal) {
143-
return formal; // line 2
146+
return formal; // line 3
144147
}
145148
146149
class C {
@@ -259,7 +262,7 @@ void main() async {
259262
requestController.add({
260263
'command': 'CompileExpression',
261264
'expression': 'formal',
262-
'line': 4,
265+
'line': 5,
263266
'column': 1,
264267
'jsModules': {},
265268
'jsScope': {'formal': 'formal'},
@@ -291,7 +294,7 @@ void main() async {
291294
requestController.add({
292295
'command': 'CompileExpression',
293296
'expression': 'count',
294-
'line': 7,
297+
'line': 8,
295298
'column': 1,
296299
'jsModules': {},
297300
'jsScope': {'count': 'count'},
@@ -324,7 +327,7 @@ void main() async {
324327
requestController.add({
325328
'command': 'CompileExpression',
326329
'expression': 'B().c().getNumber()',
327-
'line': 7,
330+
'line': 8,
328331
'column': 1,
329332
'jsModules': {},
330333
'jsScope': {},
@@ -445,7 +448,7 @@ void main() async {
445448
requestController.add({
446449
'command': 'CompileExpression',
447450
'expression': 'formal',
448-
'line': 4,
451+
'line': 5,
449452
'column': 1,
450453
'jsModules': {},
451454
'jsScope': {'formal': 'formal'},
@@ -477,7 +480,7 @@ void main() async {
477480
requestController.add({
478481
'command': 'CompileExpression',
479482
'expression': 'count',
480-
'line': 7,
483+
'line': 8,
481484
'column': 1,
482485
'jsModules': {},
483486
'jsScope': {'count': 'count'},

0 commit comments

Comments
 (0)