JetBrains/intellij-community · warning · ConfigurationException

type.migration.dialog.message.vararg.type.not.applicable

Error message

type.migration.dialog.message.vararg.type.not.applicable

What it means

Thrown by TypeMigrationDialog.canRun() (TypeMigrationDialog.java:212) when isIllegalVarargMigration() is true — the user attempts to migrate the type of an element whose usage flows into varargs, where the target type is not applicable to a vararg position. Type Migration rewrites usages along the type-flow graph, and vararg call sites cannot be soundly migrated to an unrelated type, so the dialog blocks the run.

Source

Thrown at java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java:212

      myToTypeEditor = new EditorComboBox(document, project, JavaFileType.INSTANCE);
      final String[] types = getValidTypes(project, root);
      myToTypeEditor.setHistory(types != null ? types : new String[]{document.getText()});
      document.addDocumentListener(new DocumentListener() {
        @Override
        public void documentChanged(@NotNull DocumentEvent e) {
          documentManager.commitDocument(document);
          validateButtons();
        }
      });
      init();
      validateButtons();
    }

    @Override
    protected void canRun() throws ConfigurationException {
      super.canRun();
      if (isIllegalVarargMigration()) {
        throw new ConfigurationException(JavaBundle.message("type.migration.dialog.message.vararg.type.not.applicable"));
      }
      if (isIllegalDisjunctionTypeMigration()) {
        throw new ConfigurationException(JavaBundle.message("type.migration.dialog.message.disjunction.type.not.applicable"));
      }
      if (isIllegalTypeMigration(getMigrationType())) {
        throw new ConfigurationException(
          JavaBundle.message("type.migration.dialog.message.invalid.type", StringUtil.escapeXmlEntities(myTypeCodeFragment.getText())));
      }
      if (isIllegalVoidMigration()) {
        throw new ConfigurationException(JavaBundle.message("type.migration.dialog.message.void.not.applicable"));
      }
      if (getMigrationType().equals(getRootType())) {
        throw new ConfigurationException(null);
      }
    }

    @Override
    public JComponent getPreferredFocusedComponent() {

View on GitHub (pinned to be881553f2)

Solutions

  1. Change the migration root: migrate the array-typed element as a whole rather than a vararg component (or vice versa) so no usage sits in a vararg position.
  2. Refactor the vararg method to an explicit array/collection parameter first, then re-run Type Migration.
  3. Pick a migration type that is assignable in the vararg position (e.g. java.lang.Object or a supertype of the component type).

Example fix

// before
void log(Object... args) {}
void m(String s) { log(s); }
// Type Migration root 's' from String to Integer -> vararg position -> blocked

// after
void log(Object[] args) {}
// (drop varargs) then migrate 's' String -> Integer proceeds
Defensive patterns

Strategy: validation

Validate before calling

// Before running Type Migration, check whether the root flows into varargs
PsiElement root = /* chosen root */;
boolean varargUsage = !ReferencesSearch.search(root).findAll().stream()
    .filter(ref -> ref.getElement().getParent() instanceof PsiExpressionList list
                   && PsiUtil.isVarArgPosition(list))
    .toList().isEmpty();
if (varargUsage) { /* choose another root or refactor varargs away first */ }

Prevention

When it happens

Trigger: Refactoring | Type Migration (Ctrl+Shift+F6) on a field/parameter/variable that is passed as varargs (or is itself a T... element) and choosing a migration type incompatible with the vararg usage — e.g. migrating int[] used in a String... position, or migrating the component type where call sites use the array spread.

Common situations: Migrating legacy APIs that used Object... catch-alls to typed collections; attempting to migrate the type of a parameter referenced by method(...) spread call sites; test fixtures calling helper(varargs) where the helper's parameter type is the migration root.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/4ba9f1a0858881dc. Report an issue: GitHub.