Infer map literal types

This commit is contained in:
sergeych committed 2026-02-05 20:31:20 +03:00
1 parent de9ac14e33
commit 7a286f2e06
4 files changed
+152 -1

No files matched your search

@@ -201,6 +201,22 @@ class TypesTest {
}
}
@Test
fun testMapLiteralInferenceForBounds() = runTest {
eval("""
fun acceptMap<T: Int>(m: Map<String, T>) { }
acceptMap({ "a": 1, "b": 2 })
val base = { "a": 1 }
acceptMap({ ...base, "b": 3 })
""".trimIndent())
assertFailsWith<net.sergeych.lyng.ScriptError> {
eval("""
fun acceptMap<T: Int>(m: Map<String, T>) { }
acceptMap({ "a": 1, "b": "x" })
""".trimIndent())
}
}
@Test
fun testUnionTypeLists() = runTest {
eval("""