Code review comment: I think there was a typo here maybe this should have been: ``` if (instance.name().equals(MOCKITO_CONFIG) && instance.target().asField().hasAnnotation(DEPRECATED_INJECT_MOCK)) {    continue; } ``` As I think that we shouldn't process `@MockConfig` and the deprecated  `@InjectMock` twice as it sets the same configs, but we should process the `@MockConfig` if being used in conjunction with the new `@InjectMock` to tweak the mock configuration. Since now using `@MockitoConfig` to convert scopes doesn't work =/ Also saw that there is no test for converting scopes, so this it wasn't caught before. Good thing is that there is still the deprecated `@InjectMock` as we can use it do to scope conversion.

Code under review:
public Consumer<BuildChainBuilder> produce(Index testClassesIndex) {
        return new Consumer<>() {

            @Override
            public void accept(BuildChainBuilder buildChainBuilder) {
                buildChainBuilder.addBuildStep(new BuildStep() {
                    @Override
                    public void execute(BuildContext context) {
                        Set<DotName> mockTypes = new HashSet<>();
                        List<AnnotationInstance> instances = new ArrayList<>();
                        instances.addAll(testClassesIndex.getAnnotations(DEPRECATED_INJECT_MOCK));
                        instances.addAll(testClassesIndex.getAnnotations(INJECT_SPY));
                        instances.addAll(testClassesIndex.getAnnotations(MOCKITO_CONFIG));
                        for (AnnotationInstance instance : instances) {
                            if (instance.target().kind() != AnnotationTarget.Kind.FIELD) {
                                continue;
                            }
                            if (instance.name().equals(MOCKITO_CONFIG)
                                    && instance.target().asField().hasAnnotation(INJECT_MOCK)) {
                                continue;
                            }
                            AnnotationValue allowScopeConversionValue = instance.value("convertScopes");
                            if ((allowScopeConversionValue != null) && allowScopeConversionValue.asBoolean()) {
                                
                                mockTypes.add(instance.target().asField().type().name());
                            }
                        }
                        if (mockTypes.isEmpty()) {
                            return;
                        }

                        CustomScopeAnnotationsBuildItem scopes = context.consume(CustomScopeAnnotationsBuildItem.class);
                        
                        Set<DotName> singletonBeanDefiningAnnotations = new HashSet<>();
                        for (BeanDefiningAnnotationBuildItem annotation : context
                                .consumeMulti(BeanDefiningAnnotationBuildItem.class)) {
                            if (DotNames.SINGLETON.equals(annotation.getDefaultScope())) {
                                singletonBeanDefiningAnnotations.add(annotation.getName());
                            }
                        }

                        
                        
                        
                        context.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
                            @Override
                            public boolean appliesTo(AnnotationTarget.Kind kind) {
                                return (kind == AnnotationTarget.Kind.CLASS) || (kind == AnnotationTarget.Kind.METHOD);
                            }

                            @Override
                            public void transform(TransformationContext transformationContext) {
                                AnnotationTarget target = transformationContext.getTarget();
                                if (target.kind() == AnnotationTarget.Kind.CLASS) { 
                                    ClassInfo classInfo = target.asClass();
                                    if (isMatchingBean(classInfo)) {
                                        if (Annotations.contains(transformationContext.getAnnotations(), DotNames.SINGLETON)
                                                || hasSingletonBeanDefiningAnnotation(transformationContext)) {
                                            replaceSingletonWithApplicationScoped(transformationContext);
                                        }
                                    }
                                } else if (target.kind() == AnnotationTarget.Kind.METHOD) { 
                                    MethodInfo methodInfo = target.asMethod();
                                    if ((methodInfo.annotation(DotNames.PRODUCES) != null)
                                            && (Annotations.contains(transformationContext.getAnnotations(),
                                                    DotNames.SINGLETON)
                                                    || hasSingletonBeanDefiningAnnotation(transformationContext))) {
                                        DotName returnType = methodInfo.returnType().name();
                                        if (mockTypes.contains(returnType)) {
                                            replaceSingletonWithApplicationScoped(transformationContext);
                                        }
                                    }
                                }
                            }

                            private void replaceSingletonWithApplicationScoped(TransformationContext transformationContext) {
                                transformationContext.transform().remove(new IsSingletonPredicate())
                                        .add(DotNames.APPLICATION_SCOPED).done();
                            }

                            
                            
                            private boolean isMatchingBean(ClassInfo classInfo) {
                                
                                if (mockTypes.contains(classInfo.name())) {
                                    return true;
                                }
                                if (mockTypes.contains(classInfo.superName())) {
                                    return true;
                                }
                                for (DotName iface : classInfo.interfaceNames()) {
                                    if (mockTypes.contains(iface)) {
                                        return true;
                                    }
                                }
                                return false;
                            }

                            private boolean hasSingletonBeanDefiningAnnotation(TransformationContext transformationContext) {
                                if (singletonBeanDefiningAnnotations.isEmpty()
                                        || scopes.isScopeIn(transformationContext.getAnnotations())) {
                                    return false;
                                }
                                return Annotations.containsAny(transformationContext.getAnnotations(),
                                        singletonBeanDefiningAnnotations);
                            }

                        }));
                    }
                }).produces(AnnotationsTransformerBuildItem.class).consumes(CustomScopeAnnotationsBuildItem.class)
                        .consumes(BeanDefiningAnnotationBuildItem.class).build();
            }
        };
    }

Line commented on: if (instance.name().equals(MOCKITO_CONFIG)

Revised code:
public Consumer<BuildChainBuilder> produce(Index testClassesIndex) {
        return new Consumer<>() {

            @Override
            public void accept(BuildChainBuilder buildChainBuilder) {
                buildChainBuilder.addBuildStep(new BuildStep() {
                    @Override
                    public void execute(BuildContext context) {
                        Set<DotName> mockTypes = new HashSet<>();
                        List<AnnotationInstance> instances = new ArrayList<>();
                        instances.addAll(testClassesIndex.getAnnotations(DEPRECATED_INJECT_MOCK));
                        instances.addAll(testClassesIndex.getAnnotations(INJECT_SPY));
                        instances.addAll(testClassesIndex.getAnnotations(MOCKITO_CONFIG));
                        for (AnnotationInstance instance : instances) {
                            if (instance.target().kind() != AnnotationTarget.Kind.FIELD) {
                                continue;
                            }
                            if (instance.name().equals(MOCKITO_CONFIG)
                                    && instance.target().asField().hasAnnotation(INJECT_MOCK)) {
                                continue;
                            }
                            AnnotationValue allowScopeConversionValue = instance.value("convertScopes");
                            if ((allowScopeConversionValue != null) && allowScopeConversionValue.asBoolean()) {
                                
                                mockTypes.add(instance.target().asField().type().name());
                            }
                        }
                        if (mockTypes.isEmpty()) {
                            return;
                        }

                        CustomScopeAnnotationsBuildItem scopes = context.consume(CustomScopeAnnotationsBuildItem.class);
                        
                        Set<DotName> singletonBeanDefiningAnnotations = new HashSet<>();
                        for (BeanDefiningAnnotationBuildItem annotation : context
                                .consumeMulti(BeanDefiningAnnotationBuildItem.class)) {
                            if (DotNames.SINGLETON.equals(annotation.getDefaultScope())) {
                                singletonBeanDefiningAnnotations.add(annotation.getName());
                            }
                        }

                        
                        
                        
                        context.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
                            @Override
                            public boolean appliesTo(AnnotationTarget.Kind kind) {
                                return (kind == AnnotationTarget.Kind.CLASS) || (kind == AnnotationTarget.Kind.METHOD);
                            }

                            @Override
                            public void transform(TransformationContext transformationContext) {
                                AnnotationTarget target = transformationContext.getTarget();
                                if (target.kind() == AnnotationTarget.Kind.CLASS) { 
                                    ClassInfo classInfo = target.asClass();
                                    if (isMatchingBean(classInfo)) {
                                        if (Annotations.contains(transformationContext.getAnnotations(), DotNames.SINGLETON)
                                                || hasSingletonBeanDefiningAnnotation(transformationContext)) {
                                            replaceSingletonWithApplicationScoped(transformationContext);
                                        }
                                    }
                                } else if (target.kind() == AnnotationTarget.Kind.METHOD) { 
                                    MethodInfo methodInfo = target.asMethod();
                                    if ((methodInfo.annotation(DotNames.PRODUCES) != null)
                                            && (Annotations.contains(transformationContext.getAnnotations(),
                                                    DotNames.SINGLETON)
                                                    || hasSingletonBeanDefiningAnnotation(transformationContext))) {
                                        DotName returnType = methodInfo.returnType().name();
                                        if (mockTypes.contains(returnType)) {
                                            replaceSingletonWithApplicationScoped(transformationContext);
                                        }
                                    }
                                }
                            }

                            private void replaceSingletonWithApplicationScoped(TransformationContext transformationContext) {
                                transformationContext.transform().remove(new IsSingletonPredicate())
                                        .add(DotNames.APPLICATION_SCOPED).done();
                            }

                            
                            
                            private boolean isMatchingBean(ClassInfo classInfo) {
                                
                                if (mockTypes.contains(classInfo.name())) {
                                    return true;
                                }
                                if (mockTypes.contains(classInfo.superName())) {
                                    return true;
                                }
                                for (DotName iface : classInfo.interfaceNames()) {
                                    if (mockTypes.contains(iface)) {
                                        return true;
                                    }
                                }
                                return false;
                            }

                            private boolean hasSingletonBeanDefiningAnnotation(TransformationContext transformationContext) {
                                if (singletonBeanDefiningAnnotations.isEmpty()
                                        || scopes.isScopeIn(transformationContext.getAnnotations())) {
                                    return false;
                                }
                                return Annotations.containsAny(transformationContext.getAnnotations(),
                                        singletonBeanDefiningAnnotations);
                            }

                        }));
                    }
                }).produces(AnnotationsTransformerBuildItem.class).consumes(CustomScopeAnnotationsBuildItem.class)
                        .consumes(BeanDefiningAnnotationBuildItem.class).build();
            }
        };
    }