private void checkReturnType(Type encountered) {
      Type returnType = machine.getPrototype().getReturnType();

      /*
       * Check to see if the prototype's return type is
       * possibly assignable from the type we encountered. This
       * takes care of all the salient cases (types are the same,
       * they're compatible primitive types, etc.).
       */
      if (!Merger.isPossiblyAssignableFrom(returnType, encountered)) {
        fail(
            "return type mismatch: prototype "
                + "indicates "
                + returnType.toHuman()
                + ", but encountered type "
                + encountered.toHuman());
      }
    }
Checks whether the prototype is compatible with returning the given type, and throws if not.

@param encountered {@code non-null;} the encountered return type
android/android_framework/dex-maker/src/main/java/com/android/dx/cf/code/Simulator.java