mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:35:01 +00:00
[vm/nnbd] Avoid passing null as a non-nullable argument of _AssertionError._create
In kernel files assertion conditions are specified as a range of source positions. Sometimes source texts are not available and VM cannot extract assertion condition text, so Script::GetSnippet returns null. With null safety it is no longer valid to pass null as a non-nullable argument '_failedAssertion' of _AssertionError._create constructor, so we should provide a valid String. This change converts 'null' assertion condition text to "<optimized out>", similarly to AOT mode. Issue https://github.com/flutter/flutter/issues/63513 Issue https://github.com/dart-lang/sdk/issues/34586 Change-Id: I9c5791e98fdef358068f3f5ddc4cfe98e8c7ed36 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158162 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
eaa9603b7c
commit
274b4d3ecb
|
@ -90,10 +90,13 @@ DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 0, 3) {
|
|||
script.GetTokenLocation(assertion_start, &from_line, &from_column);
|
||||
intptr_t to_line, to_column;
|
||||
script.GetTokenLocation(assertion_end, &to_line, &to_column);
|
||||
// The snippet will extract the correct assertion code even if the source
|
||||
// is generated.
|
||||
args.SetAt(0, String::Handle(script.GetSnippet(from_line, from_column,
|
||||
to_line, to_column)));
|
||||
// Extract the assertion condition text (if source is available).
|
||||
auto& condition_text = String::Handle(
|
||||
script.GetSnippet(from_line, from_column, to_line, to_column));
|
||||
if (condition_text.IsNull()) {
|
||||
condition_text = Symbols::OptimizedOut().raw();
|
||||
}
|
||||
args.SetAt(0, condition_text);
|
||||
|
||||
// Initialize location arguments starting at position 1.
|
||||
// Do not set a column if the source has been generated as it will be wrong.
|
||||
|
|
Loading…
Reference in a new issue