[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: https://github.com/dart-lang/sdk/issues/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>
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
index f3e46aa..5636b5f 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
@@ -262,6 +262,7 @@
 
   group('Expression compiler tests in extension method:', () {
     const source = '''
+      // @dart = 2.9
       extension NumberParsing on String {
         int parseInt() {
           var ret = int.parse(this);
@@ -312,6 +313,7 @@
 
   group('Expression compiler tests in method:', () {
     const source = '''
+      // @dart = 2.9
       extension NumberParsing on String {
         int parseInt() {
           return int.parse(this);
@@ -565,6 +567,7 @@
 
   group('Expression compiler tests in method with no field access:', () {
     const source = '''
+      // @dart = 2.9
       extension NumberParsing on String {
         int parseInt() {
           return int.parse(this);
@@ -726,6 +729,7 @@
 
   group('Expression compiler tests in async method:', () {
     const source = '''
+      // @dart = 2.9
       class C {
         C(int this.field, int this._field);
 
@@ -786,6 +790,7 @@
 
   group('Expression compiler tests in global function:', () {
     const source = '''
+      // @dart = 2.9
       extension NumberParsing on String {
         int parseInt() {
           return int.parse(this);
@@ -1044,6 +1049,7 @@
 
   group('Expression compiler tests in closures:', () {
     const source = r'''
+      // @dart = 2.9
       int globalFunction() {
       int x = 15;
       var c = C(1, 2);
@@ -1108,6 +1114,7 @@
 
   group('Expression compiler tests in method with no type use', () {
     const source = '''
+      // @dart = 2.9
       abstract class Key {
         const factory Key(String value) = ValueKey;
         const Key.empty();
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
index 1e649aa..65167c7 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_worker_test.dart
@@ -102,13 +102,14 @@
     File.fromUri(main)
       ..createSync(recursive: true)
       ..writeAsStringSync('''
+// @dart = 2.9
 import 'package:_testPackage/test_library.dart';
 
 var global = 0;
 
 void main() {
   var count = 0;
-  // line 7
+  // line 8
   print('Global is: \${++global}');
   print('Count is: \${++count}');
 
@@ -120,10 +121,11 @@
     File.fromUri(testLibrary)
       ..createSync()
       ..writeAsStringSync('''
+// @dart = 2.9
 import 'package:_testPackage/test_library2.dart';
 
 int testLibraryFunction(int formal) {
-  return formal; // line 4
+  return formal; // line 5
 }
 
 int callLibraryFunction2(int formal) {
@@ -139,8 +141,9 @@
     File.fromUri(testLibrary2)
       ..createSync()
       ..writeAsStringSync('''
+// @dart = 2.9
 int testLibraryFunction2(int formal) {
-  return formal; // line 2
+  return formal; // line 3
 }
 
 class C {
@@ -259,7 +262,7 @@
       requestController.add({
         'command': 'CompileExpression',
         'expression': 'formal',
-        'line': 4,
+        'line': 5,
         'column': 1,
         'jsModules': {},
         'jsScope': {'formal': 'formal'},
@@ -291,7 +294,7 @@
       requestController.add({
         'command': 'CompileExpression',
         'expression': 'count',
-        'line': 7,
+        'line': 8,
         'column': 1,
         'jsModules': {},
         'jsScope': {'count': 'count'},
@@ -324,7 +327,7 @@
       requestController.add({
         'command': 'CompileExpression',
         'expression': 'B().c().getNumber()',
-        'line': 7,
+        'line': 8,
         'column': 1,
         'jsModules': {},
         'jsScope': {},
@@ -445,7 +448,7 @@
       requestController.add({
         'command': 'CompileExpression',
         'expression': 'formal',
-        'line': 4,
+        'line': 5,
         'column': 1,
         'jsModules': {},
         'jsScope': {'formal': 'formal'},
@@ -477,7 +480,7 @@
       requestController.add({
         'command': 'CompileExpression',
         'expression': 'count',
-        'line': 7,
+        'line': 8,
         'column': 1,
         'jsModules': {},
         'jsScope': {'count': 'count'},