From 72479198755fc1349b8171b776cb3e97a75ac1da Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Tue, 24 Apr 2018 08:22:03 -0700 Subject: [PATCH] Repeatedly infer maps until nothing changes When an inferred map is nested in another inferred map, the inner one will usually not actually be made into a map because its original class will be unified with another class in the process of making the outer map. On the other hand, this unification can lead to more inner classes becoming viable as maps. --- src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 7c1d7349..f84b1ed0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -243,7 +243,13 @@ export class Run { } graph = flattenStrings(graph, stringTypeMapping, debugPrintReconstitution); if (this._options.inferMaps) { - graph = inferMaps(graph, stringTypeMapping, true, debugPrintReconstitution); + for (;;) { + const newGraph = inferMaps(graph, stringTypeMapping, true, debugPrintReconstitution); + if (newGraph === graph) { + break; + } + graph = newGraph; + } } graph = noneToAny(graph, stringTypeMapping, debugPrintReconstitution); if (!targetLanguage.supportsOptionalClassProperties) {