JetBrains/intellij-community · warning · ConfigurationException

type.migration.dialog.message.disjunction.type.not.applicabl

Error message

type.migration.dialog.message.disjunction.type.not.applicable

What it means

Thrown by TypeMigrationDialog.canRun() (TypeMigrationDialog.java:215) when isIllegalDisjunctionTypeMigration() is true — the chosen migration target is a disjunction (union) type such as a multi-catch 'A | B' or intersection type that cannot serve as a migration destination. Type Migration needs a single classifiable type to rewrite declarations and expressions; disjunctions only exist in limited contexts and cannot be materialized as field/local types.

Source

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

      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() {
      return myToTypeEditor;
    }

View on GitHub (pinned to be881553f2)

Solutions

  1. Enter a single concrete type (class, interface, generic type) as the migration target.
  2. If union semantics are needed, introduce a common supertype or an interface and migrate to that.
  3. For wildcard cases, migrate to the erasure/bound type instead of the wildcard/disjunction form.

Example fix

// before
// migrate root type String to: java.io.Serializable | Comparable -> blocked

// after
// migrate root type String to: java.io.Serializable -> proceeds
Defensive patterns

Strategy: validation

Validate before calling

// Validate the migration target before running: must be one resolvable type, not a disjunction
String targetText = myTypeCodeFragment.getText();
if (targetText.contains("|") || targetText.contains("&")) {
  // ask for a single concrete type (e.g. common supertype) instead
}

Prevention

When it happens

Trigger: Refactoring | Type Migration and typing 'A | B', '? extends X', or an intersection ('Serializable & Comparable') into the 'Migrate to' type field, when the root usage requires a concrete single type.

Common situations: Copying a catch-clause union type from code into the migration-type field; attempting to generalize a type to 'A | B' hoping for ADT-like behavior in Java; pasting wildcard generics that resolve to disjunctions internally.

Related errors


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