package com.netflix.governator.visitors;

import com.google.inject.Binding;
import com.google.inject.spi.DefaultBindingTargetVisitor;
import com.google.inject.spi.DefaultElementVisitor;
import com.google.inject.spi.InstanceBinding;

public class WarnOfToInstanceInjectionVisitor extends DefaultElementVisitor<String> { 
    public <T> String visit(Binding<T> binding) {
        return binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, String>() {
            public String visit(InstanceBinding<? extends T> instanceBinding) {
                return String.format("toInstance() at %s can force undesireable static initialization.  " +
                        "Consider replacing with an @Provides method instead.",
                        instanceBinding.getSource());
            }
        });
    }
}

package com.netflix.governator.visitors;

import com.google.inject.Binding;
import com.google.inject.spi.DefaultBindingTargetVisitor;
import com.google.inject.spi.DefaultElementVisitor;
import com.google.inject.spi.InstanceBinding;
import com.google.inject.spi.ProviderInstanceBinding;

public class WarnOfToInstanceInjectionVisitor extends DefaultElementVisitor<String> { 
    public <T> String visit(Binding<T> binding) {
        return binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, String>() {
            public String visit(InstanceBinding<? extends T> instanceBinding) {
                return String.format("toInstance() at %s can force undesireable static initialization.  " +
                        "Consider replacing with an @Provides method instead.",
                        instanceBinding.getSource());
            }

            public String visit(ProviderInstanceBinding<? extends T> providerInstanceBinding) {
                return String.format("toInstance() at %s can force undesireable static initialization.  " +
                        "Consider replacing with an @Provides method instead.",
                        providerInstanceBinding.getSource());
            }            
        });
    }
}

--- 
+++ 
@@ -4,7 +4,6 @@
 import com.google.inject.spi.DefaultBindingTargetVisitor;
 import com.google.inject.spi.DefaultElementVisitor;
 import com.google.inject.spi.InstanceBinding;
-import com.google.inject.spi.ProviderInstanceBinding;
 
 public class WarnOfToInstanceInjectionVisitor extends DefaultElementVisitor<String> { 
     public <T> String visit(Binding<T> binding) {
@@ -14,12 +13,6 @@
                         "Consider replacing with an @Provides method instead.",
                         instanceBinding.getSource());
             }
-
-            public String visit(ProviderInstanceBinding<? extends T> providerInstanceBinding) {
-                return String.format("toInstance() at %s can force undesireable static initialization.  " +
-                        "Consider replacing with an @Provides method instead.",
-                        providerInstanceBinding.getSource());
-            }            
         });
     }
 }
Remove ProviderInstanceBinding as it also captures @Provides methods
