From 6ba128f7bacc0240d66523e62ffacfdf3b00ed86 Mon Sep 17 00:00:00 2001 From: sergeych Date: Mon, 20 Apr 2026 12:23:17 +0300 Subject: [PATCH] fixed some more inference bugs --- .../commonMain/kotlin/net/sergeych/lyng/Compiler.kt | 12 +++++++++++- lynglib/stdlib/lyng/root.lyng | 9 ++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt index 9965c2b..3b9d7c0 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt @@ -2096,12 +2096,19 @@ class Compiler( plan.captureOwners[name] = slotLoc plan.captures += capture if (!plan.slotPlan.slots.containsKey(name)) { + val newSlot = plan.slotPlan.nextIndex plan.slotPlan.slots[name] = SlotEntry( - plan.slotPlan.nextIndex, + newSlot, isMutable = slotLoc.isMutable, isDelegated = slotLoc.isDelegated ) plan.slotPlan.nextIndex += 1 + slotTypeByScopeId[slotLoc.scopeId]?.get(slotLoc.slot)?.let { cls -> + slotTypeByScopeId.getOrPut(plan.slotPlan.id) { mutableMapOf() }[newSlot] = cls + } + slotTypeDeclByScopeId[slotLoc.scopeId]?.get(slotLoc.slot)?.let { decl -> + slotTypeDeclByScopeId.getOrPut(plan.slotPlan.id) { mutableMapOf() }[newSlot] = decl + } } } @@ -10346,6 +10353,9 @@ class Compiler( if (initClass != null) { classFieldTypesByName.getOrPut(declaringClassNameCaptured) { mutableMapOf() }[name] = initClass } + if (!isDelegate && varTypeDecl is TypeDecl.Generic) { + classMemberTypeDeclByName.getOrPut(declaringClassNameCaptured) { mutableMapOf() }[name] = varTypeDecl + } } // Emit MiniValDecl for this declaration (before execution wiring), attach doc if any diff --git a/lynglib/stdlib/lyng/root.lyng b/lynglib/stdlib/lyng/root.lyng index 11eb0e1..744b9af 100644 --- a/lynglib/stdlib/lyng/root.lyng +++ b/lynglib/stdlib/lyng/root.lyng @@ -545,8 +545,7 @@ class StackTraceEntry( } // Private helper: starts one LaunchPool worker coroutine for the given queue. // Defined outside LaunchPool so the global `launch` is not shadowed by the method. -private fun _launchPoolWorker(q) { - val ch = q as Channel +private fun _launchPoolWorker(ch: Channel): Deferred { launch { var task = ch.receive() while (task != null) { @@ -618,7 +617,7 @@ class LaunchPool(maxWorkers, maxQueueSize = Channel.UNLIMITED) { */ fun cancel() { closeQueue() - workers.forEach { (it as Deferred).cancel() } + workers.forEach { it.cancel() } } /* @@ -628,7 +627,7 @@ class LaunchPool(maxWorkers, maxQueueSize = Channel.UNLIMITED) { */ fun cancelAndJoin() { closeQueue() - workers.forEach { (it as Deferred).cancel() } + workers.forEach { it.cancel() } } /* @@ -639,7 +638,7 @@ class LaunchPool(maxWorkers, maxQueueSize = Channel.UNLIMITED) { fun closeAndJoin() { closeQueue() for (w in workers) { - (w as Deferred).await() + w.await() } } } \ No newline at end of file