{"record":{"id":"2cfd20c83c1908a8","repo":"JetBrains/intellij-community","slug":"type-migration-dialog-message-disjunction-type-not","errorCode":null,"errorMessage":"type.migration.dialog.message.disjunction.type.not.applicable","messagePattern":"type\\.migration\\.dialog\\.message\\.disjunction\\.type\\.not\\.applicable","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"warning","filePath":"java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java","lineNumber":215,"sourceCode":"      document.addDocumentListener(new DocumentListener() {\n        @Override\n        public void documentChanged(@NotNull DocumentEvent e) {\n          documentManager.commitDocument(document);\n          validateButtons();\n        }\n      });\n      init();\n      validateButtons();\n    }\n\n    @Override\n    protected void canRun() throws ConfigurationException {\n      super.canRun();\n      if (isIllegalVarargMigration()) {\n        throw new ConfigurationException(JavaBundle.message(\"type.migration.dialog.message.vararg.type.not.applicable\"));\n      }\n      if (isIllegalDisjunctionTypeMigration()) {\n        throw new ConfigurationException(JavaBundle.message(\"type.migration.dialog.message.disjunction.type.not.applicable\"));\n      }\n      if (isIllegalTypeMigration(getMigrationType())) {\n        throw new ConfigurationException(\n          JavaBundle.message(\"type.migration.dialog.message.invalid.type\", StringUtil.escapeXmlEntities(myTypeCodeFragment.getText())));\n      }\n      if (isIllegalVoidMigration()) {\n        throw new ConfigurationException(JavaBundle.message(\"type.migration.dialog.message.void.not.applicable\"));\n      }\n      if (getMigrationType().equals(getRootType())) {\n        throw new ConfigurationException(null);\n      }\n    }\n\n    @Override\n    public JComponent getPreferredFocusedComponent() {\n      return myToTypeEditor;\n    }\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java#L197-L233","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Enter a single concrete type (class, interface, generic type) as the migration target.","If union semantics are needed, introduce a common supertype or an interface and migrate to that.","For wildcard cases, migrate to the erasure/bound type instead of the wildcard/disjunction form."],"exampleFix":"// before\n// migrate root type String to: java.io.Serializable | Comparable -> blocked\n\n// after\n// migrate root type String to: java.io.Serializable -> proceeds","handlingStrategy":"validation","validationCode":"// Validate the migration target before running: must be one resolvable type, not a disjunction\nString targetText = myTypeCodeFragment.getText();\nif (targetText.contains(\"|\") || targetText.contains(\"&\")) {\n  // ask for a single concrete type (e.g. common supertype) instead\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never paste multi-catch 'A | B' types into the migrate-to field.","Introduce a shared supertype/interface when union semantics seem needed, then migrate to it."],"tags":["intellij","refactoring","type-migration","java","union-type"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}