Files
kotlin-fork/idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/JvmOverloadsFunctions.java
T
Denis Zharkov d7d0407afb 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
2018-12-05 16:34:44 +03:00

19 lines
1.1 KiB
Java
Vendored

import test.kotlin.A;
import static test.kotlin.JvmOverloadsFunctionsKt.foo;
class JvmOverloadsFunctions {
public static void main(String[] args) {
A a = new A() { };
foo(a.getClass(), a, true, "Some");
foo(a.getClass(), a, true);
foo(a.getClass(), a);
// Before KT-28556 is fixed the second not-nullable parameter wasn't marked as it shoud, so there were no warnings on it
foo(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>, <warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>, true, <warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
foo(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>, <warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>, true);
foo(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>, <warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
}
}