Remove assertion about dispatch receiver in scripts
#KT-42530 fixed
This commit is contained in:
@@ -328,7 +328,8 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
destructuringVariables = () -> {
|
||||
assert owner.getDispatchReceiverParameter() == null
|
||||
ReceiverParameterDescriptor dispatchReceiver = owner.getDispatchReceiverParameter();
|
||||
assert dispatchReceiver == null || dispatchReceiver.getContainingDeclaration() instanceof ScriptDescriptor
|
||||
: "Destructuring declarations are only be parsed for lambdas, and they must not have a dispatch receiver";
|
||||
LexicalScope scopeForDestructuring =
|
||||
ScopeUtilsKt.createScopeForDestructuring(scope, owner.getExtensionReceiverParameter());
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
fun Int.isOdd() = (this % 2) == 1
|
||||
val list: List<Pair<Int, String>> = listOf(1 to "a", 2 to "b")
|
||||
val (odds, evens) = list.partition { (i, _) -> i.isOdd() }
|
||||
odds
|
||||
+10
@@ -76,6 +76,16 @@ class ScriptTest : TestCase() {
|
||||
})
|
||||
}
|
||||
|
||||
fun testKt42530() {
|
||||
val aClass = compileScript("kt42530.kts", StandardScriptDefinition)
|
||||
Assert.assertNotNull(aClass)
|
||||
val out = captureOut {
|
||||
val anObj = tryConstructClassFromStringArgs(aClass!!, emptyList())
|
||||
Assert.assertNotNull(anObj)
|
||||
}
|
||||
assertEqualsTrimmed("[(1, a)]", out)
|
||||
}
|
||||
|
||||
private fun compileScript(
|
||||
scriptPath: String,
|
||||
scriptDefinition: KotlinScriptDefinition,
|
||||
|
||||
Reference in New Issue
Block a user