mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
36 lines
915 B
HTML
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> |