{"record":{"id":"4ba9f1a0858881dc","repo":"JetBrains/intellij-community","slug":"type-migration-dialog-message-vararg-type-not-appl","errorCode":null,"errorMessage":"type.migration.dialog.message.vararg.type.not.applicable","messagePattern":"type\\.migration\\.dialog\\.message\\.vararg\\.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":212,"sourceCode":"      myToTypeEditor = new EditorComboBox(document, project, JavaFileType.INSTANCE);\n      final String[] types = getValidTypes(project, root);\n      myToTypeEditor.setHistory(types != null ? types : new String[]{document.getText()});\n      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() {","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java#L194-L230","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Refactor the vararg method to an explicit array/collection parameter first, then re-run Type Migration.","Pick a migration type that is assignable in the vararg position (e.g. java.lang.Object or a supertype of the component type)."],"exampleFix":"// before\nvoid log(Object... args) {}\nvoid m(String s) { log(s); }\n// Type Migration root 's' from String to Integer -> vararg position -> blocked\n\n// after\nvoid log(Object[] args) {}\n// (drop varargs) then migrate 's' String -> Integer proceeds","handlingStrategy":"validation","validationCode":"// Before running Type Migration, check whether the root flows into varargs\nPsiElement root = /* chosen root */;\nboolean varargUsage = !ReferencesSearch.search(root).findAll().stream()\n    .filter(ref -> ref.getElement().getParent() instanceof PsiExpressionList list\n                   && PsiUtil.isVarArgPosition(list))\n    .toList().isEmpty();\nif (varargUsage) { /* choose another root or refactor varargs away first */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Convert Object.../T... catch-all APIs to explicit collection parameters before large type migrations.","Migrate the array-typed root as a whole rather than component positions."],"tags":["intellij","refactoring","type-migration","java","varargs"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}