[ddc] Opt code in nullable inference test

Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Change-Id: Idaf69b40c27336c8601cb143741f79604d2647e7
Fixes: https://github.com/dart-lang/sdk/issues/43843
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168583
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/test/nullable_inference_test.dart b/pkg/dev_compiler/test/nullable_inference_test.dart
index 4c9d9a2..315dca1 100644
--- a/pkg/dev_compiler/test/nullable_inference_test.dart
+++ b/pkg/dev_compiler/test/nullable_inference_test.dart
@@ -497,6 +497,7 @@
 /// to be produced in the set of expressions that cannot be null by DDC's null
 /// inference.
 Future expectNotNull(String code, String expectedNotNull) async {
+  code = '// @dart = 2.9\n$code';
   var result = await kernelCompile(code);
   var collector = NotNullCollector(result.librariesFromDill);
   result.component.accept(collector);
@@ -525,6 +526,7 @@
 
 /// Given the Dart [code], expects all the expressions inferred to be not-null.
 Future expectAllNotNull(String code) async {
+  code = '// @dart = 2.9\n$code';
   var result = (await kernelCompile(code));
   result.component.accept(ExpectAllNotNull(result.librariesFromDill));
 }