diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java index b1f85817e46b..ebe56e91f786 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java @@ -362,15 +362,7 @@ public class TypeMigrationLabeler { type = userDefinedType ? type : TypeEvaluator.substituteType(type, originalType, isContraVariantPosition); if (!userDefinedType) { - if (originalType instanceof PsiClassType) { - final PsiClassType psiClassType = (PsiClassType)originalType; - if (psiClassType.resolve() instanceof PsiTypeParameter) { - return false; - } - for (PsiType paramType : psiClassType.getParameters()) { - if (paramType instanceof PsiClassType && ((PsiClassType)paramType).resolve() instanceof PsiTypeParameter) return false; - } - } + if (typeContainsTypeParameters(originalType)) return false; } if (type instanceof PsiCapturedWildcardType) { @@ -433,6 +425,18 @@ public class TypeMigrationLabeler { } } + static boolean typeContainsTypeParameters(PsiType originalType) { + if (originalType instanceof PsiClassType) { + final PsiClassType psiClassType = (PsiClassType)originalType; + if (psiClassType.resolve() instanceof PsiTypeParameter) { + return true; + } + for (PsiType paramType : psiClassType.getParameters()) { + if (paramType instanceof PsiClassType && ((PsiClassType)paramType).resolve() instanceof PsiTypeParameter) return true; + } + } + return false; + } @Nullable diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java index dc7a470a4363..84c7fe5be7d3 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationStatementProcessor.java @@ -168,7 +168,10 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor { final PsiType valueType = myTypeEvaluator.evaluateType(value); if (returnType != null && valueType != null) { - myLabeler.addMigrationRoot(method, valueType, myStatement, TypeConversionUtil.isAssignable(returnType, valueType), true); + if (!myLabeler.addMigrationRoot(method, valueType, myStatement, TypeConversionUtil.isAssignable(returnType, valueType), true) + && TypeMigrationLabeler.typeContainsTypeParameters(returnType)) { + myLabeler.markFailedConversion(new Pair(returnType, valueType), value); + } } } }