Browse Source

Fix local functions inside lambdas.

pull/1586/head
Siegfried Pammer 6 years ago
parent
commit
01e42b772c
  1. 12
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/LocalFunctions.cs
  2. 5
      ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs

12
ICSharpCode.Decompiler.Tests/TestCases/Pretty/LocalFunctions.cs

@ -222,5 +222,17 @@ namespace LocalFunctions @@ -222,5 +222,17 @@ namespace LocalFunctions
}
}
}
public static int LocalFunctionInLambda(IEnumerable<int> xs)
{
return xs.First(delegate(int x) {
return Do();
bool Do()
{
return x == 3;
}
});
}
}
}

5
ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs

@ -169,6 +169,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -169,6 +169,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
if (function.DeclarationScope != null && function.DeclarationScope.Parent is ILFunction betterParentFunction) {
parentFunction.LocalFunctions.Remove(function);
betterParentFunction.LocalFunctions.Add(function);
}
return function;
}

Loading…
Cancel
Save