[Microsoft.Build.Tasks] Fix a net 2.0 failure.
[mono.git] / mcs / mcs / anonymous.cs
index 847cbcfd5d83deba03c210446fe28a868b50e4c0..b20608ea52def25fa65d522c58746fbab1a0e59e 100644 (file)
@@ -352,7 +352,7 @@ namespace Mono.CSharp {
                                hoisted_locals.Add (hoisted);
                        }
 
-                       if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine))
+                       if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine) && hoisted.Storey != null)
                                hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
                }