diff --git a/gosu-core/src/main/java/gw/internal/gosu/ir/transform/AbstractElementTransformer.java b/gosu-core/src/main/java/gw/internal/gosu/ir/transform/AbstractElementTransformer.java
index <HASH>..<HASH> 100644
--- a/gosu-core/src/main/java/gw/internal/gosu/ir/transform/AbstractElementTransformer.java
+++ b/gosu-core/src/main/java/gw/internal/gosu/ir/transform/AbstractElementTransformer.java
@@ -1014,7 +1014,8 @@ public abstract class AbstractElementTransformer<T extends IParsedElement>
     }
     else
     {
-      return nullLiteral();
+      // Note we cast the Null value to make ASM's stack map frame calculations work, otherwise ASM has a bug where it calculates the wrong type
+      return checkCast( type, nullLiteral() );
     }
   }
cast null value for implicit local var initialization, this is purely for ASM's stack map frame calculations, otherwise ASM has a bug where it determines the wrong type which may cause a bytecode verify error