 +        // Handle parent class and interfaces
 +        if ($self->isInterface()) {
 +          $decl= 'interface '.$name;
++          $extends= array();
++          foreach ($self->getDeclaredInterfaces() as $iface) {
++            $declared= xp::reflect($iface->getName());
++            if ($self->hasAnnotation('generic', $declared)) {
++              $extends[]= xp::reflect(self::createGenericType($iface, $arguments)->getName());
++            } else {
++              $extends[]= $declared;
++            }
++          }
++          $extends && $decl.= ' extends '.implode(', ', $extends);
 +        } else {
 +          $parent= $self->getParentClass();
 +          $impl= array();
-+          foreach ($self->getInterfaces() as $iface) {
-+            if ($parent->isSubclassOf($iface)) continue;
-+            
-+            $declared= $iface->getSimpleName();
++          foreach ($self->getDeclaredInterfaces() as $iface) {
++            $declared= xp::reflect($iface->getName());
 +            if ($self->hasAnnotation('generic', $declared)) {
 +              $impl[]= xp::reflect(self::createGenericType($iface, $arguments)->getName());
 +            } else {
 +              $impl[]= $declared;
 +            }
 +          }
-+
 +          $decl= '';
 +          Modifiers::isAbstract($self->getModifiers()) && $decl.= 'abstract ';
 +          $decl.= 'class '.$name.' extends ';
 +          if ($self->hasAnnotation('generic', 'parent')) {
 +            $decl.= xp::reflect(self::createGenericType($parent, $arguments)->getName());
 +          } else {
-+            $decl.= $parent->getSimpleName();
++            $decl.= xp::reflect($parent->getName());
 +          }
 +          $impl && $decl.= ' implements '.implode(', ', $impl);
 +        }
 +      
 +        // Create class
-+        // DEBUG echo '> ', $decl, "\n  ", $src, "\n";
++        //  DEBUG echo '> ', $decl, "\n  ", $src, "\n";
 +        eval($decl.' {'.$src.'}');
 +        xp::$registry['details.'.$qname]= $meta;
 +        xp::$registry['class.'.$name]= $qname;

+          $sig[$i]= xp::reflect($t->getName()).' $'.$i;
+        } else if (isset($generic[$i])) {
+          if ($generic[$i] instanceof XPClass) {
+            $sig[$i]= $generic[$i]->getSimpleName().' ';
+          } else if ($generic[$i] instanceof Primitive) {
+            $sig[$i]= '';
+            $p= $generic[$i]->getName();
+            $verify.= (
+              ' if (!is_'.$p.'($'.$i.')) throw new IllegalArgumentException('.

  
   /**
    * Represents classes. Every instance of an XP class has an method
@@ -650,8 +651,330 @@
       $details= self::detailsForClass(xp::nameOf($class));
       return $details ? (isset($details[0][$field]) ? $details[0][$field] : NULL) : NULL;
     }
