package com.example;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;

public class Main {

    private static Injector injector;

    public static void main(String... args) {
        injector = Guice.createInjector(new SampleModule());
        new Main().getInstance();
    }

    public void getInstance() {
        SampleInterface instance = injector.getInstance(Key.get(SampleInterface.class, Names.named("sample1")));
        System.out.println("get? " + instance);
        System.out.println("type " + instance.getClass());
        System.out.println("cast " + instance.getClass().cast(instance);
        //System.out.println("foo? " + instance.getClass().cast(instance).foo());
    }

}

@@ -540,24 +540,25 @@
 et? %22 + 
+(
 instance
 );%0A     
@@ -541,32 +541,41 @@
 t? %22 + (instance
+ != null)
 );%0A        Syste
@@ -691,16 +691,17 @@
 nstance)
+)
 ;%0A      
@@ -772,21 +772,388 @@
 ce).foo());%0A
+        invoke(instance.getClass().cast(instance));%0A    %7D%0A%0A    public void invoke(Sample1Class instance) %7B%0A        System.out.println(%22foo? %22 + instance.foo());%0A    %7D%0A%0A    public void invoke(Sample2Class instance) %7B%0A        System.out.println(%22bar? %22 + instance.bar());%0A    %7D%0A%0A    public void invoke(Object instance) %7B%0A        System.out.println(%22%3CNG%3E %22 + instance);%0A
     %7D%0A%0A%7D%0A

add test case