From 9327d7d085e1e493f489c028263dc3f9a335828b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Fri, 23 Aug 2013 22:06:29 +0200 Subject: [PATCH] generator: fix possible unhandled KeyNotFoundException (regression) This regression surfaced after 82a957bc9d3d1fcc44c715a1020fe2afd16c7f4a [1], when many collections were migrated to generic collections. HashTables simply return null when queried for certain key, while Dictionary objects throw KeyNotFoundException. The regression could be noticed, more particularly, when trying to compile the gtk3 branch of the gudevsharp project [2]. [1] https://github.com/mono/gtk-sharp/commit/82a957bc9d3d1fcc44c715a1020fe2afd16c7f4a [2] https://github.com/mono/gudev-sharp/commits/gtk3 --- generator/SymbolTable.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 7981a7744..4ace94446 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -214,7 +214,12 @@ namespace GtkSharp.Generation { IGeneratable cur_type = null; while (types.TryGetValue (type, out cur_type) && cur_type is AliasGen) { IGeneratable igen = cur_type as AliasGen; - types [type] = types [igen.Name]; + + IGeneratable new_type; + if (!types.TryGetValue (igen.Name, out new_type)) + new_type = null; + + types [type] = new_type; type = igen.Name; }