sdk
sdk copied to clipboard
Weird super parameters evaluation + assert breakpoints not triggering
Repro:
class One {
One(this.numbers)
: assert(numbers.map((e) => e).isNotEmpty, ''), //B5 (will explain below)
assert(numbers.isNotEmpty, ''); //B6 (will explain below)
List<int> numbers;
}
class Two extends One {
Two(super.numbers) // B1
: assert(numbers.map((e) => e).isNotEmpty, ''), //B2
assert(numbers.isNotEmpty, ''); //B3
}
class Three extends One {
Three(super.numbers) : assert(numbers.map((e) => e).isNotEmpty, ''); //B4
}
void main() {
var two = Two([1, 2]);
print(two.numbers);
var three = Three([1, 2]);
print(three.numbers);
var one = One([1, 2]);
print(one.numbers);
}
- For some reason, the
List.mapnever triggers a breakpoint. - The
numbersexpression isnull:
But when on One (B5 and B6), evaluation does work as intended, but B5 doesn't trigger. The only way I found to get there was to place a breakpoint on the constructor line and press F10 (VS Code next).
This case will trigger the breakpoint, although I'm not sure what is different here still:
class Data {
Data(this.number);
num number;
List<int> get list => switch (number) {
int v => [v],
double() => [number.toInt()],
};
}
class Foo<T> {
Foo(this.value);
T value;
}
class Bar extends Foo<Data> {
Bar(super.value, int other)
: assert(value.list.map((i) => i).contains(other)); //Break
}
void main() {
var data = Data(42);
var bar = Bar(data, 42);
print(bar.value.list);
}