Index: /trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/ApiLinker.scala
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/ApiLinker.scala (revision 3876)
+++ /trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/ApiLinker.scala (revision 3876)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+ ******************************************************************************/
+
+package com.sun.fortress.scala_src.linker
+
+import com.sun.fortress.compiler.index.ApiIndex
+import com.sun.fortress.compiler.GlobalEnvironment
+import com.sun.fortress.compiler.index.ApiIndex
+import com.sun.fortress.compiler.IndexBuilder
+import com.sun.fortress.nodes._
+import com.sun.fortress.repository.FortressRepository
+import com.sun.fortress.scala_src.nodes._
+import com.sun.fortress.scala_src.useful.Lists._
+import _root_.java.util.{List => JList}
+import _root_.java.util.Map
+import _root_.java.util.ArrayList
+
+class ApiLinker(env: GlobalEnvironment, repository: FortressRepository) {
+  def link(api: ApiIndex): ApiIndex = {
+    api.ast match {
+      case SApi(info, name, imports, decls, comprises) => {
+        if (comprises.isEmpty) { 
+          api 
+        } 
+        else {
+          val allDecls = new ArrayList[Decl]()
+          for (constituent <- comprises) {
+            constituent match {
+              case SApi(cinfo, cname, cimports, cdecls, _) => {
+                // The comprises clause should be empty because repositories
+                // only store simple APIs
+                  allDecls.addAll(toJavaList(cdecls))
+                }
+              }
+            }
+            IndexBuilder.builder.buildApiIndex(new Api(info, name, toJavaList(imports), 
+                                                       allDecls, new ArrayList[APIName]()), 
+                                               api.modifiedDate)
+        }
+      }
+    }
+  }
+}
+
Index: /trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/CompoundApiChecker.scala
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/CompoundApiChecker.scala (revision 3876)
+++ /trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/CompoundApiChecker.scala (revision 3876)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+    Copyright 2009 Sun Microsystems, Inc.,
+    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+    All rights reserved.
+
+    U.S. Government Rights - Commercial software.
+    Government users are subject to the Sun Microsystems, Inc. standard
+    license agreement and applicable provisions of the FAR and its supplements.
+
+    Use is subject to license terms.
+
+    This distribution may include materials developed by third parties.
+
+    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+ ******************************************************************************/
+
+package com.sun.fortress.scala_src.linker
+
+import com.sun.fortress.compiler.index.ApiIndex
+import com.sun.fortress.compiler.GlobalEnvironment
+import com.sun.fortress.compiler.index.ApiIndex
+import com.sun.fortress.exceptions.StaticError
+import com.sun.fortress.nodes._
+import com.sun.fortress.repository.FortressRepository
+import com.sun.fortress.scala_src.nodes._
+import com.sun.fortress.scala_src.useful.Lists._
+import _root_.java.util.{List => JList}
+import _root_.java.util.Map
+import _root_.java.util.ArrayList
+
+class CompoundApiChecker(env: GlobalEnvironment, repository: FortressRepository) {
+  def check(api: ApiIndex) = {
+    new ArrayList[StaticError]()
+  }
+}
+
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java (revision 3865)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java (revision 3876)
@@ -45,4 +45,6 @@
 import com.sun.fortress.nodes.Type;
 import com.sun.fortress.repository.FortressRepository;
+import com.sun.fortress.scala_src.linker.ApiLinker;
+import com.sun.fortress.scala_src.linker.CompoundApiChecker;
 import com.sun.fortress.scala_src.typechecker.CoercionTest;
 import com.sun.fortress.scala_src.typechecker.ExportChecker;
@@ -290,6 +292,14 @@
                                              GlobalEnvironment env,
                                              FortressRepository repository) {
+
+        // Check if this is a compound API, and, if so, link it into a single API.
+        List<StaticError> errors = new CompoundApiChecker(env, repository).check(api);
+        if (! errors.isEmpty()) { 
+            return new TypeCheckerResult(api.ast(), errors);
+        }
+        api = new ApiLinker(env, repository).link(api);
+
         // Check type hierarchy to ensure acyclicity.
-        List<StaticError> errors = new TypeHierarchyChecker(api, env, repository).checkHierarchy();
+        errors = new TypeHierarchyChecker(api, env, repository).checkHierarchy();
         if (! errors.isEmpty()) {
             return new TypeCheckerResult(api.ast(), errors);
Index: /trunk/ProjectFortress/src/com/sun/fortress/compiler/index/CompilationUnitIndex.java
===================================================================
--- /trunk/ProjectFortress/src/com/sun/fortress/compiler/index/CompilationUnitIndex.java (revision 3760)
+++ /trunk/ProjectFortress/src/com/sun/fortress/compiler/index/CompilationUnitIndex.java (revision 3876)
@@ -82,4 +82,12 @@
     }
 
+    public Set<APIName> comprises() { 
+        final Set<APIName> result = new HashSet<APIName>();
+        for (APIName _apiName : ast().getComprises()) { 
+            result.add(_apiName);
+        }
+        return result;
+    }
+
     public Map<Id, Variable> variables() { return _variables; }
 
Index: /trunk/ProjectFortress/compiler_tests/XXX5a.twice.test
===================================================================
--- /trunk/ProjectFortress/compiler_tests/XXX5a.twice.test (revision 3876)
+++ /trunk/ProjectFortress/compiler_tests/XXX5a.twice.test (revision 3876)
@@ -0,0 +1,29 @@
+#    Copyright 2009 Sun Microsystems, Inc.,
+#    4150 Network Circle, Santa Clara, California 95054, U.S.A.
+#    All rights reserved.
+#
+#    U.S. Government Rights - Commercial software.
+#    Government users are subject to the Sun Microsystems, Inc. standard
+#    license agreement and applicable provisions of the FAR and its supplements.
+#
+#    Use is subject to license terms.
+#
+#    This distribution may include materials developed by third parties.
+#
+#    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+#    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
+
+tests=Compiled5.a
+STATIC_TESTS_DIR=${FORTRESS_AUTOHOME}/ProjectFortress/compiler_tests
+compile
+compile
+compile_err_equals=\
+${STATIC_TESTS_DIR}/Compiled5.a.fss:18:11-21:\n\
+\ The following declarations in API Compiled5.a are not matched\n\
+\ by the declarations in component Compiled5.a.\n\
+\ Unmatched declarations: {\n\
+\ (TraitDecl T at ${FORTRESS_AUTOHOME}/ProjectFortress/test_library/Compiled5.a.fsi:20.1,\n\
+\ due to different method n @ ${FORTRESS_AUTOHOME}/ProjectFortress/test_library/Compiled5.a.fsi:22:3-23:1)\n\
+\ }\n\
+File Compiled5.a.fss has 1 error.\n
+compile_out_equals=
