yet another import fix
This commit is contained in:
parent
3b6bdda0a4
commit
e925195495
1
.gitignore
vendored
1
.gitignore
vendored
@ -28,3 +28,4 @@ debug.log
|
||||
/compile_metadata_output.txt
|
||||
test_output*.txt
|
||||
/site/src/version-template/lyng-version.js
|
||||
/bugs/
|
||||
|
||||
@ -146,18 +146,27 @@ class CliLocalModuleImportRegressionJvmTest {
|
||||
val headers = Map<String, String>()
|
||||
|
||||
fn startListen(port, host) {
|
||||
var eager = Bravo()
|
||||
eager.doSomething()
|
||||
tcpServer = Net.tcpListen(port, host)
|
||||
// println("tcpServer.isOpen: " + tcpServer.isOpen()) // historical workaround; should not be needed
|
||||
println("tcpServer.isOpen: " + tcpServer.isOpen())
|
||||
launch {
|
||||
try {
|
||||
while (true) {
|
||||
println("wait for accept...")
|
||||
val tcpSocket = tcpServer.accept()
|
||||
println("var bravo = Bravo()")
|
||||
var bravo = Bravo()
|
||||
println("bravo.doSomething()...")
|
||||
bravo.doSomething()
|
||||
println("bravo.doSomething()... OK")
|
||||
tcpSocket.close()
|
||||
break
|
||||
}
|
||||
} catch (e) {
|
||||
println("ERR [Alpha.startListen]: '", e, "'")
|
||||
} finally {
|
||||
println("FIN [Alpha.startListen]")
|
||||
tcpServer.close()
|
||||
}
|
||||
}
|
||||
@ -259,6 +268,7 @@ class CliLocalModuleImportRegressionJvmTest {
|
||||
delay(50)
|
||||
|
||||
val socket = Net.tcpConnect("127.0.0.1", $port)
|
||||
println("send ping...")
|
||||
socket.writeUtf8("ping")
|
||||
socket.flush()
|
||||
socket.close()
|
||||
@ -269,8 +279,10 @@ class CliLocalModuleImportRegressionJvmTest {
|
||||
|
||||
val result = runCli(mainFile.toString())
|
||||
assertTrue(result.err.isBlank(), result.err)
|
||||
assertFalse(result.out.contains("ERR [Alpha.startListen]"), result.out)
|
||||
assertFalse(result.out.contains("module capture 'Bravo'"), result.out)
|
||||
assertTrue(result.out.contains("Bravo.doSomething"), result.out)
|
||||
assertTrue(result.out.contains("bravo.doSomething()... OK"), result.out)
|
||||
assertEquals(2, Regex("Bravo\\.doSomething").findAll(result.out).count(), result.out)
|
||||
} finally {
|
||||
root.toFile().deleteRecursively()
|
||||
}
|
||||
|
||||
@ -2086,7 +2086,7 @@ class Compiler(
|
||||
return null
|
||||
}
|
||||
if (scopeSeedNames.contains(name)) {
|
||||
val isModuleSlot = modulePlan != null && slotLoc.scopeId == modulePlan.id
|
||||
val isModuleSlot = resolvesToModuleSeedSlot(name, slotLoc)
|
||||
if (!isModuleSlot || useScopeSlots) return null
|
||||
}
|
||||
recordCaptureSlot(name, slotLoc)
|
||||
@ -2105,6 +2105,24 @@ class Compiler(
|
||||
)
|
||||
}
|
||||
|
||||
private fun resolvesToModuleSeedSlot(name: String, slotLoc: SlotLocation): Boolean {
|
||||
val modulePlan = moduleSlotPlan() ?: return false
|
||||
var current: SlotLocation? = slotLoc
|
||||
val visitedScopeIds = HashSet<Int>()
|
||||
while (current != null && visitedScopeIds.add(current.scopeId)) {
|
||||
if (current.scopeId == modulePlan.id) {
|
||||
return true
|
||||
}
|
||||
val owner = capturePlanStack
|
||||
.firstOrNull { it.slotPlan.id == current.scopeId }
|
||||
?.captureOwners
|
||||
?.get(name)
|
||||
?: return false
|
||||
current = owner
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun captureSlotRef(name: String, pos: Pos): ObjRef? {
|
||||
if (capturePlanStack.isEmpty()) return null
|
||||
if (name == "this") return null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user