Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I'm not 100% sure this is the right approach. Is it possible for the user to provide their own implementation of
AssetBundle.load
? If not, maybe it would be better to change the type ofdata
to aByteData
(removing the?
on line 666) and just remove this check.Actually, that might be a reasonable approach anyhow, even if it is user-overridable, since the user will still get an exception when
data
gets dereferenced on line 682; the only difference will be that the exception will be marginally less comprehensible, and the key won't be evicted from the image cache. But maybe that's ok.Anyhow, I'm open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
?
could be removed. But for now I would keep theif (data==null)
for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can probably just drop this. If the method is not supposed to return null, we can assume it's handled by throwing an exception.
I'm not quite clear though on when weak checking would be used. Could you explain a bit more about how that would happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnfield
Weak checking is when the user's app contains some files that are opted in to null safety (e.g. flutter) and others that aren't (e.g. their app and packages). It does all the static checks for null safety, but the type system is fundamentally unsound at the boundary between opted in and opted out code. For example, if you invoke an abstract method in an opted-in class that has a return type of
int
, that's supposed to guarantee that you'll never receivenull
as a result. But if the concrete implementation of that abstract method is in opted-out code, it could returnnull
without causing a compile time errors. That's the sense in which it's unsound: your opted-in code can have a variable of type non-nullableint
that contains anull
value. Effectively, non-nullable types can't be completely trusted if there is some opted-out code somewhere in the program. Once the entire program has been migrated to null safety, the unsoundness goes away andint
s are reallyint
s.Because of this, we have code in Flutter that looks to be dead code, but we want to keep it around until most users have upgraded their apps to null safety, so that we can continue reporting useful exceptions to them if they pass
null
to us where they shouldn't. The type system thinks that code is dead but the reality is it's not, so we have to add the// ignore:
comment. The reason I'm having to make this CL now is because fixing a bug in the analyzer that was preventing some of the "supposedly dead" code from being recognized.Does that help? If not, I'm happy to discuss over VC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh ok that makes sense. Yeah we should leave this then.