Browse Source

Fixed crash in PatternStatementTransform (foreach loop with captured variables).

pull/105/head
Daniel Grunwald 14 years ago
parent
commit
03183ab7bf
  1. 3
      ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs

3
ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs

@ -176,7 +176,6 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -176,7 +176,6 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
if (varDecl != null && varDecl.Parent is BlockStatement) {
Statement declarationPoint;
if (CanMoveVariableDeclarationIntoStatement(varDecl, usingStatement, out declarationPoint)) {
Debug.Assert(declarationPoint == usingStatement);
// Moving the variable into the UsingStatement is allowed:
usingStatement.ResourceAcquisition = new VariableDeclarationStatement {
Type = (AstType)varDecl.Type.Clone(),
@ -302,7 +301,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -302,7 +301,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
};
node.ReplaceWith(foreachStatement);
foreach (Statement stmt in m.Get<Statement>("variablesOutsideLoop")) {
((BlockStatement)foreachStatement.Parent).Statements.InsertAfter(null, stmt);
((BlockStatement)foreachStatement.Parent).Statements.InsertAfter(null, stmt.Detach());
}
return foreachStatement;
}

Loading…
Cancel
Save