Closed kevmoo closed 4 months ago
Here's the fun bit. With this diff, no compiler crash:
diff --git a/lib/src/sokoban_view/components/grided.dart b/lib/src/sokoban_view/components/grided.dart
index 198775a..e28a176 100644
--- a/lib/src/sokoban_view/components/grided.dart
+++ b/lib/src/sokoban_view/components/grided.dart
@@ -25,6 +25,6 @@ mixin GridElement {
Vector2 getPosition() => Vector2(
(gridPosition.x * gridPixelDimensions.x) + gridPixelOffset.x,
(gridPosition.y * gridPixelDimensions.y) + gridPixelOffset.y);
- double getGridValue() => (gridPosition.y * 13.0) + gridPosition.x;
- int getLayeredGridValue() => getGridValue().toInt() + (layer * 200);
+ int getGridValue() => ((gridPosition.y * 13.0) + gridPosition.x).toInt();
+ int getLayeredGridValue() => getGridValue() + (layer * 200);
}
diff --git a/lib/src/sokoban_view/components/world.dart b/lib/src/sokoban_view/components/world.dart
index c68e5a8..c2460f3 100644
--- a/lib/src/sokoban_view/components/world.dart
+++ b/lib/src/sokoban_view/components/world.dart
@@ -158,7 +158,7 @@ class SokobanWorld extends World with HasGameRef {
var initialIdx = int.parse(split[1]);
var nextIdx = int.parse(split[2]);
var goalHit = bool.parse(split[3]);
- var gridValue = box.getGridValue() as int;
+ var gridValue = box.getGridValue();
logger.i('box $idx $gridValue');
if (gridValue == initialIdx) {
@@ -183,7 +183,7 @@ class SokobanWorld extends World with HasGameRef {
for (var idx = 0; idx < batteries.length; idx++) {
var battery = batteries[idx];
- var gridValue = battery.getGridValue() as int;
+ var gridValue = battery.getGridValue();
if (gridValue == initialIdx) {
battery.hide();
Smaller repro:
class Num {
final double x;
Num(this.x);
double getX() => x;
}
void main() {
final num = Num(0.0);
var value = num.getX() as int;
print(value);
}
Compile with --omit-implicit-checks --omit-explicit-checks
.
Source: https://github.com/flutter/engine/compare/6b36113c4ab7...63dd50788d4a Dart SDK version: 3.6.0-36.0.dev (dev) (Fri Jul 12 09:05:30 2024 -0700) on "macos_arm64"