   {ir: irMethodTranslate, type, name}
 
 irMethodTranslate = (ctx, {type, name}) ->
-  finalType = substitute ctx.substitution, type
+  finalType = type#substitute ctx.substitution, type
   # log "irmethod", name, finalType.constraints
   resolvedMethod =
     for dict in dictsForConstraint ctx, finalType.constraints

  constructor: ->

class TypeVariable
  constructor: (@name, @kind) ->
    @TypeVariable = yes
class TypeConstr
  constructor: (@name, @kind) ->

inferType = (ctx, name, type, constraints, polymorphic, scopeIndex) ->
  # For explicitly typed bindings, we need to check that the inferred type
  #   corresponds to the annotated
  currentType = type# substitute ctx.substitution, type
  if ctx.isFinallyTyped name, scopeIndex or ctx.currentScopeIndex()
    # TODO: check class constraints
    if not includesJsType currentType.type
      # Check the declared type
      declaredType = ctx.type name
      explicitType = freshInstance ctx, declaredType
      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
        console.log currentType, (printType currentType)
        ctx.extendSubstitution substitutionFail "#{name}'s declared type is too general, inferred #{plainPrettyPrint inferredType}"
      # Context reduction
      isDeclaredConstraint = (c) ->
        entailed = entail ctx, unifiedType.constraints, c
      notDeclared = filter (__ _not, isDeclaredConstraint), checked = constraints #(substituteList ctx.substitution, constraints)
      {success, error} = deferConstraints ctx, notDeclared, currentType
      if error
        ctx.extendSubstitution error
