-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Dart version: Dart SDK version: 2.18.7 (stable) (Unknown timestamp) on "linux_x64"
working on Ubuntu 22.04
Let's consider the following main.dart
file:
import 'dart:async';
class A with B {}
mixin B {
static DateTime? lastTick;
static Timer? checkActiveTimer;
void startTimer() {
checkActiveTimer = Timer.periodic(Duration(seconds: 1), (timer) {
lastTick = DateTime.now();
print(lastTick); //break point here
});
}
bool lastActiveIsNull() {
return lastActive == null;
}
}
Future<void> main(List<String> arguments) async {
var a = A();
a.startTimer();
}
-
I've ran this file using the command
/usr/lib/dart/bin/dart --enable-vm-service:34213 main.dart
and got into the devtools to debug it. When the execution pauses at the break point. thelastTick
member is evaluated inside the debugger asnull
. It's being printed and used inside the code correctly but the debugger is evaluating it wrongly asnull
.
If I asked the debugger to evaluateB.lastTick
it'll view it's value correctly, or If I usedlastActiveIsNull()
it'll return false so only calling the member directly in the watches will shownull
including for exampleprint(lastTick)
, evaluating it will print null but calling it actually from the code will print it. shouldn't the two of them evaluate and work as the same value? -
If I tried to evaluate
this
or call any kind of member instance method from inside the function inside the timer it'll throw outoptimized out
which is ok. I understand why. But if we call instance method likelastActiveIsNull()
it'll throwNoSuchMethodError: Class 'String' has no instance method 'lastActiveIsNull'.
which is not as clear. shouldn't it showoptimized out
or similiar errors rather than theString
related error?