Scripting: fix script type extraction on psi2ir
#KT-48812 fixed
This commit is contained in:
@@ -1181,6 +1181,13 @@ private fun makeKotlinType(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is IrScriptSymbol -> {
|
||||||
|
TypeUtils.makeUnsubstitutedType(
|
||||||
|
classifier.toIrBasedDescriptorIfPossible(),
|
||||||
|
MemberScope.Empty,
|
||||||
|
KotlinTypeFactory.EMPTY_REFINED_TYPE_FACTORY
|
||||||
|
).makeNullableAsSpecified(hasQuestionMark)
|
||||||
|
}
|
||||||
else -> error("unknown classifier kind $classifier")
|
else -> error("unknown classifier kind $classifier")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1200,3 +1207,8 @@ private fun IrSimpleFunctionSymbol.toIrBasedDescriptorIfPossible(): FunctionDesc
|
|||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
private fun IrPropertySymbol.toIrBasedDescriptorIfPossible(): PropertyDescriptor =
|
private fun IrPropertySymbol.toIrBasedDescriptorIfPossible(): PropertyDescriptor =
|
||||||
if (isBound) owner.toIrBasedDescriptor() else descriptor
|
if (isBound) owner.toIrBasedDescriptor() else descriptor
|
||||||
|
|
||||||
|
// this is a temporary solution for scripts - seems that introducing full-blown emulation of descriptors for the single degenerate case
|
||||||
|
// doesn't make any sense.
|
||||||
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
|
private fun IrScriptSymbol.toIrBasedDescriptorIfPossible(): ScriptDescriptor = descriptor
|
||||||
|
|||||||
+6
@@ -223,6 +223,12 @@ class MainKtsTest {
|
|||||||
assertEquals("success", value)
|
assertEquals("success", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testKt48812() {
|
||||||
|
val res = evalFile(File("$TEST_DATA_ROOT/kt48812.main.kts"))
|
||||||
|
assertSucceeded(res)
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertSucceeded(res: ResultWithDiagnostics<EvaluationResult>) {
|
private fun assertSucceeded(res: ResultWithDiagnostics<EvaluationResult>) {
|
||||||
Assert.assertTrue(
|
Assert.assertTrue(
|
||||||
"test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}",
|
"test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}",
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
|
||||||
|
import kotlinx.coroutines.flow.*
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
|
||||||
|
fun printInt(n : Int) = println(n)
|
||||||
|
|
||||||
|
runBlocking {
|
||||||
|
flowOf(1, 2, 3)
|
||||||
|
.onEach(::printInt)
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user