TypeConversionDescriptor (PsiType to, PsiType from, @Nullable PsiExpression expression, PsiElement context, @NotNull AtomicConversionType type) { final String typeText = PsiDiamondTypeUtil.getCollapsedType(to, context); final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to); final PsiClass atomicClass = resolveResult.getElement(); LOG.assertTrue(atomicClass != null); final PsiTypeParameter[] typeParameters = atomicClass.getTypeParameters(); if (typeParameters.length == 1) { final PsiType initial = resolveResult.getSubstitutor().substitute(typeParameters[0]); final PsiPrimitiveType unboxedInitialType = PsiPrimitiveType.getUnboxedType(initial); if (unboxedInitialType != null) { if (from instanceof PsiPrimitiveType) { final PsiClassType boxedFromType = ((PsiPrimitiveType)from).getBoxedType(atomicClass); LOG.assertTrue(boxedFromType != null); if (!TypeConversionUtil.isAssignable(initial, boxedFromType)) { return new AtomicConstructorConversionDescriptor("$val$", "new " + typeText + "((" + unboxedInitialType.getCanonicalText() + ")$val$)", expression, type); } } } } return new AtomicConstructorConversionDescriptor("$val$", "new " + typeText + "($val$)", expression, type); }