Skip to content

Commit 3f32196

Browse files
lrhncommit-bot@chromium.org
authored andcommitted
Make LateInitialziationError abstract and uninstantiable.
Change-Id: I82ad71f3db9a7c04d87cad62662760f1b104ad68 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126733 Reviewed-by: Erik Ernst <[email protected]> Commit-Queue: Lasse R.H. Nielsen <[email protected]>
1 parent 5013ce6 commit 3f32196

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

sdk/lib/core/errors.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,18 @@ class CyclicInitializationError extends Error {
590590
}
591591

592592
/**
593-
* Error thrown when a late field is set or get when it shouldn't be.
593+
* Error thrown when a late variable is accessed in an invalid manner.
594+
*
595+
* A late variable must be initialized before it's read.
596+
* If a late variable has no initializer expression and has not
597+
* been written to, then reading it will throw a
598+
* late initialization error.
599+
*
600+
* A late final variable with no initializer expression may only
601+
* be written to once.
602+
* If it is written to again, the writing will throw a
603+
* late initialization error.
594604
*/
595-
class LateInitializationError extends Error {}
605+
abstract class LateInitializationError extends Error {
606+
factory LateInitializationError._() => throw UnsupportedError("");
607+
}

sdk_nnbd/lib/core/errors.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,18 @@ class CyclicInitializationError extends Error {
592592
}
593593

594594
/**
595-
* Error thrown when a late field is set or get when it shouldn't be.
595+
* Error thrown when a late variable is accessed in an invalid manner.
596+
*
597+
* A late variable must be initialized before it's read.
598+
* If a late variable has no initializer expression and has not
599+
* been written to, then reading it will throw a
600+
* late initialization error.
601+
*
602+
* A late final variable with no initializer expression may only
603+
* be written to once.
604+
* If it is written to again, the writing will throw a
605+
* late initialization error.
596606
*/
597-
class LateInitializationError extends Error {}
607+
abstract class LateInitializationError extends Error {
608+
factory LateInitializationError._() => throw UnsupportedError("");
609+
}

0 commit comments

Comments
 (0)