236f3f820d
The handling of null shorting in the variable initializer interfered with the declaration of the variable, making subsequent flow potentially losing track of promotions. Closes #42504 Change-Id: Idb17920ffe8746983825714f76160abcca54751b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152760 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
37 lines
855 B
Dart
37 lines
855 B
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.
|
|
|
|
abstract class ImageStreamCompleter {
|
|
void addListener();
|
|
}
|
|
|
|
class _LiveImage {
|
|
factory _LiveImage(ImageStreamCompleter a) => throw UnimplementedError();
|
|
}
|
|
|
|
abstract class Foo {
|
|
dynamic get _pendingImages;
|
|
|
|
ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter loader()) {
|
|
assert(key != null);
|
|
assert(loader != null);
|
|
ImageStreamCompleter? result = _pendingImages[key]?.completer;
|
|
if (result != null) {
|
|
return result;
|
|
}
|
|
try {
|
|
result = loader();
|
|
_LiveImage(result);
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
|
|
result.addListener();
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
main() {}
|