The meaning of `setDropOriginalInContainingParts()` call is that
it makes copyBuilder forget the original parts, in particular
the valueParameter.original.containingDeclaration does not reference
original descriptor no more
Otherwise the following exception is happening:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl.getOverriddenDescriptors(ValueParameterDescriptorImpl.kt:119)
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl.getOverriddenDescriptors(ValueParameterDescriptorImpl.kt:119)
at org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt$hasDefaultValue$1.getNeighbors(DescriptorUtils.kt:192)
at org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt$hasDefaultValue$1.getNeighbors(DescriptorUtils.kt)
at org.jetbrains.kotlin.utils.DFS.doDfs(DFS.java:98)
at org.jetbrains.kotlin.utils.DFS.doDfs(DFS.java:99)
at org.jetbrains.kotlin.utils.DFS.dfs(DFS.java:27)
at org.jetbrains.kotlin.utils.DFS.dfs(DFS.java:37)
at org.jetbrains.kotlin.utils.DFS.ifAny(DFS.java:47)
at org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.hasDefaultValue(DescriptorUtils.kt:189)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.renderValueParameter(DescriptorRendererImpl.kt:803)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.renderValueParameters(DescriptorRendererImpl.kt:767)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.renderFunction(DescriptorRendererImpl.kt:683)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.access$renderFunction(DescriptorRendererImpl.kt:42)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl$RenderDeclarationDescriptorVisitor.visitFunctionDescriptor(DescriptorRendererImpl.kt:1039)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl$RenderDeclarationDescriptorVisitor.visitFunctionDescriptor(DescriptorRendererImpl.kt:1002)
at org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl.accept(FunctionDescriptorImpl.java:760)
- move getDelegates from CodegenUtil to DelegationResolver, reuse it in
DelegationChecker
- use getAllOverriddenDescriptors + filterOutOverridden instead of a manual DFS
Not all the `hasNext` operators return types is exactly Z,
suspend operators return boxed versions.
So the fix is just coercing result value after invoked function to Z
This change should make the logic a bit more simple.
For all suspend functions/coroutines treat them in expression codegen
like they return boxed version of the original type.
Everything works fine then, except Unit type functions:
their bodies must be generated just like they're VOID and then load
Unit on stack manually.
Inline functions with reified type parameters are generated as private (see
AsmUtil.specialCaseVisibility), so we should treat them as "declared" in
reflection to look them up via getDeclaredMethod, not getMethod
#KT-14721 Fixed
'SuspendFunction$n' class descriptors are created on demand by KotlinBuiltIns (and cached).
On serialization, types constructed with 'SuspendFunction$n' are written as 'Function$n' with extra flag (SUSPEND_TYPE).
On deserialization, corresponding 'SuspendFunction$n' classes are used.
(required for 'suspend' on functional types).
TYPE_REFERENCE element now has MODIFIER_LIST child, which hosts annotations and modifiers for the corresponding type reference.
Annotations and modifiers written before an extension function type are now parsed as annotations and modifiers for the functional type, not the receiver type.
So, '@Ann A.(B) -> C' was '(@Ann A).(B) -> C', and became '@Ann (A.(B) -> C)'.
NB: DSL_SCOPE_VIOLATION testData updated accordingly.
Type projection variance modifiers ('in', 'out') belong to a separate modifier list under corresponding type projection (not under a type reference).
'A<in suspend T>' is 'A<(in (suspend T))>', 'A<suspend in T>' is an error.
In stub builder, create a modifier list node to host annotations and modifiers (none so far; TODO properly serialize/deserialize types with modifiers).
- There will be no `coroutine` keyword for builders
- They accept a special suspend function type instead
(it's return type is straightforward, not Continuation<Unit>)
- Instances of these types may be run with special built-in functions
- These built-ins functions are parametrized
with handleResult/handleException/interceptResume, so these operators
become unnecessary (and controllers too)
NB: `@Suspend` annotation is subject to replace with the `suspend` modifier
on types