-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dart2js] Compiler crash 'classNode' was called on null #47691
Comments
How is |
@fishythefish I tried to break it down as much as possible. The compiler only crashes when the method is injected via riverpod (using stable version 1.0.0 here). Again, iterating over import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final loadElementsProvider = Provider((ref) {
return LoadElements();
});
class LoadElements {
Future<List> call() => Future.value([]);
}
final viewModelProvider = Provider((ref) {
return ViewModel(ref.read(loadElementsProvider))..init();
});
class ViewModel {
ViewModel(this._loadElements);
final LoadElements _loadElements;
void init() async {
final elements = await _loadElements();
for (final element in elements) {
print(element);
}
}
}
void main() {
runApp(const ProviderScope(child: Example()));
}
class Example extends ConsumerWidget {
const Example({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final model = ref.watch(viewModelProvider);
return const SizedBox();
}
} Stack trace
|
Here's a repro without dependencies: class LoadElements {
Future<List> call() => Future.value([]);
}
class ViewModel {
ViewModel(this._loadElements);
final LoadElements _loadElements;
void init() async {
final elements = await _loadElements();
for (final element in elements) {
print(element);
}
}
}
void main() {
ViewModel(LoadElements()).init();
} Attempting to compile with or without null-safety should produce the crash. I'll try to investigate further. |
Looks like the core issue is that |
Bug: #47691 Change-Id: I14a0b5f027b6a5ed74dd22b63e3c103b380823eb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220780 Reviewed-by: Sigmund Cherem <sigmund@google.com>
The following method causes a compiler crash when building without null safety. (
The getter 'classNode' was called on null
)Iterating over
i
instead will resolve it.Building without sound null safety
OS: macOS Big Sur 11.4 (20F71)
Dart SDK: 2.14.4
The text was updated successfully, but these errors were encountered: