Files
openide/java/java-impl/resources/inspectionDescriptions/SuspiciousTernaryOperatorInVarargsCall.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

36 lines
915 B
HTML

<html>
<body>
Reports vararg method calls that use a ternary operator with mixed array and non-array branches.
<p>
When compiled, both branches are wrapped in arrays. As a result, the array branch is turned into
a two-dimensional array, which may indicate a problem.
</p>
<p>
The quick-fix wraps the non-array branch in an array to prevent the compiler from doing the conversion.
</p>
<!-- tooltip end -->
<p><b>Example:</b></p>
<pre><code>
static void bar(boolean flag) {
Object[] a = {1, 2};
Object b = "hello";
foo(flag ? a : b);
}
static void foo(Object... obj) {
}
</code></pre>
<p>After the quick-fix: </p>
<pre><code>
static void bar(boolean flag) {
Object[] a = {1, 2};
Object b = "hello";
foo(flag ? a : new Object[]{b});
}
static void foo(Object... obj) {
}
</code></pre>
<p><small>New in 2020.3</small></p>
</body>
</html>