Revision: 6003
Author: [email protected]
Date: Mon Aug 24 08:25:24 2009
Log: Add test for failing case in IHM:
  - non-static generic class (or interface) inside a generic class/interface
  - subtype of the inner class is outside a subtype of the outer  
class/interface

http://code.google.com/p/google-web-toolkit/source/detail?r=6003

Modified:
   
/changes/jat/ihm/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java

=======================================
---  
/changes/jat/ihm/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java
      
Mon Aug 10 08:49:04 2009
+++  
/changes/jat/ihm/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java
      
Mon Aug 24 08:25:24 2009
@@ -558,6 +558,46 @@
      }
    };

+  protected CheckedMockCompilationUnit CU_NestedGenericInterfaces = new  
CheckedMockCompilationUnit(
+      "test", "OuterInt", "OuterInt.InnerInt") {
+
+    @Override
+    public void check(JClassType type) {
+      final String name = type.getSimpleSourceName();
+      if ("OuterInt".equals(name)) {
+        checkOuter(type);
+      } else {
+        checkInner(type);
+      }
+    }
+
+    public void checkInner(JClassType type) {
+      assertEquals("InnerInt", type.getSimpleSourceName());
+      assertEquals("test.OuterInt.InnerInt",  
type.getQualifiedSourceName());
+      assertEquals("test.OuterInt",
+          type.getEnclosingType().getQualifiedSourceName());
+    }
+
+    public void checkOuter(JClassType type) {
+      assertEquals("OuterInt", type.getSimpleSourceName());
+      assertEquals("test.OuterInt", type.getQualifiedSourceName());
+      JClassType[] nested = type.getNestedTypes();
+      assertEquals(1, nested.length);
+      JClassType inner = nested[0];
+      assertEquals("test.OuterInt.InnerInt",  
inner.getQualifiedSourceName());
+    }
+
+    @Override
+    public String getSource() {
+      StringBuffer sb = new StringBuffer();
+      sb.append("package test;\n");
+      sb.append("public interface OuterInt<K,V> {\n");
+      sb.append("   public interface InnerInt<V> { }\n");
+      sb.append("}\n");
+      return sb.toString();
+    }
+  };
+
    protected CheckedMockCompilationUnit CU_Object = new  
CheckedMockCompilationUnit(
        "java.lang", "Object") {
      @Override
@@ -686,6 +726,26 @@
      }
    };

+  protected CheckedMockCompilationUnit CU_UnnestedImplementations = new  
CheckedMockCompilationUnit(
+      "test", "Implementations") {
+    @Override
+    public void check(JClassType type) {
+      assertEquals("Implementations", type.getSimpleSourceName());
+      assertEquals("test.Implementations", type.getQualifiedSourceName());
+    }
+
+    @Override
+    public String getSource() {
+      StringBuffer sb = new StringBuffer();
+      sb.append("package test;");
+      sb.append("public class Implementations {");
+      sb.append("  public static class OuterImpl<K,V> implements  
OuterInt<K,V> {}");
+      sb.append("  public static class InnerImpl<V> implements  
OuterInt.InnerInt<V> {}");
+      sb.append("}");
+      return sb.toString();
+    }
+  };
+
    private final TypeOracleMediator mediator = new TypeOracleMediator();

    private final TypeOracle typeOracle = mediator.getTypeOracle();
@@ -1011,6 +1071,24 @@
      assertEquals(1, types.length);
      assertEquals("java.lang.Object", types[0].getQualifiedSourceName());
    }
+
+  public void testTypeParams() throws TypeOracleException {
+    units.add(CU_Object);
+    units.add(CU_NestedGenericInterfaces);
+    units.add(CU_UnnestedImplementations);
+    compileAndRefresh();
+    JClassType[] types = typeOracle.getTypes();
+    assertEquals(6, types.length);
+    JClassType type =  
typeOracle.findType("test.Implementations.InnerImpl");
+    assertNotNull(type);
+    JClassType[] interfaces = type.getImplementedInterfaces();
+    assertEquals(1, interfaces.length);
+    JClassType intf = interfaces[0];
+    JParameterizedType intfParam = intf.isParameterized();
+    assertNotNull(intfParam);
+    JClassType intfEnclosing = intf.getEnclosingType();
+    assertNotNull(intfEnclosing.isRawType());
+  }

    public void testUnresolvedSymbls() throws TypeOracleException {
      units.add(CU_Object);

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to