     if not includesJsType currentType.type
       # Check the declared type
       declaredType = ctx.type name
-      explicitType = freshInstance ctx, declaredType
+      explicitType = copyOrigin (freshInstance ctx, declaredType), declaredType.type
       updatedDeclaredType = quantifyUnbound ctx, explicitType#(substitute ctx.substitution, explicitType)
       unify ctx, currentType.type, explicitType.type
       unifiedType = explicitType# substitute ctx.substitution, explicitType
       inferredType = quantifyUnbound ctx, unifiedType
       if not typeEq inferredType, updatedDeclaredType
-        declaredTypeTooGeneral ctx, inferredType, updatedDeclaredType, declaredType
+        declaredTypeTooGeneral ctx, inferredType, updatedDeclaredType, unifiedType, declaredType
       # Context reduction
       isDeclaredConstraint = (c) ->
         entailed = entail ctx, unifiedType.constraints, c

    copyOrigin to.type, from.type
    for c, i in to.constraints
      copyOrigin c, from.constraints[i]
  else
    if to.TypeApp
      copyOrigin to.op, from.op

      message: "declared type is too general, " +
        if t1 is fromInferred then "#{inferred}, #{got}" else "#{got}, #{inferred}"
      conflicts: conflicts

replaceQuantifiedByOrigin = (type) ->
  if type.TypeApp
    new TypeApp (replaceQuantifiedByOrigin type.op),
      (replaceQuantifiedByOrigin type.arg)
  else if type.QuantifiedVar and type.origin
    new TypeVariable (print type.origin), star
  else
    type

topLevelExpression = (ctx, expression) ->
  ctx.bareDefine()
