 
 findSubClassParam = (ctx, constraint) ->
   toClassName = (c) -> c.className
-  for className, dict of values ctx.classParamsForType constraint
+  classParams = ctx.classParamsForType constraint
+  throw new Error "No params for #{safePrintType constraint}" unless classParams
+  for className, dict of values classParams
     if chain = findSuperClassChain ctx, className, constraint.className
       return accessList dict, chain
   throw new Error "Couldn't find dict for #{safePrintType constraint}"

  [typed, notTyped] = partitionMap typesUnify, validDefinitions
  # allDefs = join (setToArray typed), (setToArray notTyped)
  allDefs = concatMaps typed, notTyped # TODO: don't use object key ordering for ordering
  values mapMap (__ prettyPrint, _type), allDefs

# API


addConstraints = ({constraints, type}, addedConstraints) ->
  new Constrained (join constraints, addedConstraints), type

replaceConstraints = ({type}, constraints) ->
  new Constrained constraints, type

toConstrained = (type) ->
  new Constrained [], type

