a782dd82db
- Detect null safety when not specified before isolate
initialization
- for source files by having CFE parse the source file
for @dart annotations
- for kernel files by sniffing the kernel file for
compilation mode
- for appJIT files by sniffing the feature string
- for AOT snapshots by sniffing the feature string
- Remove workaround of returning null safety to false during
bootstrapping
- Add a new Dart C API call for detecting null safety
Bug: 41766
Change-Id: Ia8cf264323a2d0d58c2855ce6491456aa6f1da07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150089
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
40 lines
1.4 KiB
Dart
40 lines
1.4 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "dart:io";
|
|
import "detect_nullsafety_helper.dart";
|
|
|
|
void main() {
|
|
// Create temporary directory.
|
|
var tmpDir = Directory.systemTemp.createTempSync();
|
|
var tmpDirPath = tmpDir.path;
|
|
String sourcePath = "$tmpDirPath/strong.dart";
|
|
String dillPath = "$tmpDirPath/strong.dill";
|
|
String jitPath = "$tmpDirPath/strong.appjit";
|
|
|
|
// Generate code for an isolate to run in strong mode.
|
|
generateIsolateSource(sourcePath, "");
|
|
generateKernel(sourcePath, dillPath);
|
|
generateAppJIT(sourcePath, jitPath);
|
|
|
|
try {
|
|
// Running from Source.
|
|
testNullSafetyMode(sourcePath, 'Strong Mode');
|
|
// Without the enable experiment option it will be in weak mode.
|
|
testNullSafetyMode1(sourcePath, 'Weak Mode');
|
|
|
|
// Running from Kernel File.
|
|
testNullSafetyMode(dillPath, 'Strong Mode');
|
|
// Without the enable experiment option it will be inferred to strong.
|
|
testNullSafetyMode1(dillPath, 'Strong Mode');
|
|
|
|
// Running from app JIT File.
|
|
testNullSafetyMode(jitPath, 'Strong Mode');
|
|
// Without the enable experiment option it will be inferred to strong.
|
|
testNullSafetyMode1(jitPath, 'Strong Mode');
|
|
} finally {
|
|
tmpDir.deleteSync(recursive: true);
|
|
}
|
|
}
|