Smart casts and nullability in single-threaded contexts

Correct, this is very common. But it is also common to have mutable state. And the compiler cannot determine what you are doing without completely analyzing your program and all its dependencies.

Yes, I realize that, and I don’t particularly mind the compiler “paranoia” being the default… What I think is sorely missing is an option of turning it off in a simple way for an entire class/file (see the “hundreds of times over one week” above)… Not only is it stressful to get so many false error reports, but it also make the code look ugly and/or needlessly verbose in the end.

That is not true for all cases. A getter does not mean that the value never changes. It means that the value is read-only for you.

I know :slight_smile: However, the compiler already has a notion of a const getter (the ‘initialize a val in constructor’ case). I’d be quite useful (again, for preventing false errors, but also as a form of documentation) if you could mark other getters as const as well…

Here is an attempt […]

I get the idea, but in addition to VALIDATED, you’d need yet another class DBDATA for sending stuff from dbValidation() to performMutation()… I understand that it would indeed silence the compiler errors, but having to create two extra classes (per mutation, so hundreds of extra classes in the entire project) to achieve that just seems like extra confirmation that something like @AssumeSingleThreadedAccess is missing in the language/compiler…