Fix parameters nullability for generated overloads in light classes

When making KtLightNullabilityAnnotation after test org.jetbrains.kotlin.idea.caches.resolve.IdeLightClassTestGenerated.NullabilityAnnotations#testJvmOverloads
started failing the wrong assumption was made that for
@JvmOverloads-generated overloads their last parameter is always nullable
(see removed isNullableInJvmOverloads function) and that lead to a bug,
namely KT-28556.

The actual problem of this test started failing was incorrect definition
of kotlinOrigin in KtLightParameter for case of JvmOverloads:
wrong KtParameter was being chosen before

This commit fixes the issue by propagating how actually generated
parameters in codegen relate to source KtParameters'

^KT-28556 Fixed
This commit is contained in:
Denis Zharkov
2018-11-30 15:17:35 +03:00
parent ac19cc9376
commit d7d0407afb
9 changed files with 40 additions and 31 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.resolve.jvm.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.KtPureElement
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.*
@@ -31,13 +32,15 @@ enum class JvmDeclarationOriginKind {
COLLECTION_STUB,
AUGMENTED_BUILTIN_API,
ERASED_INLINE_CLASS,
UNBOX_METHOD_OF_INLINE_CLASS
UNBOX_METHOD_OF_INLINE_CLASS,
JVM_OVERLOADS
}
class JvmDeclarationOrigin(
val originKind: JvmDeclarationOriginKind,
val element: PsiElement?,
val descriptor: DeclarationDescriptor?
val descriptor: DeclarationDescriptor?,
val parametersForJvmOverload: List<KtParameter?>? = null
) {
companion object {
@JvmField