public static Surrogate coerceToBoundOrLocalSurrogate(GeneralizedSymbol self) {
    { Surrogate surrogate = null;

      if (Logic.explicitlyQualifiedLogicObjectNameP(self, ((Module)(Stella.$MODULE$.get())))) {
        { Object old$Module$000 = Stella.$MODULE$.get();
          Object old$Context$000 = Stella.$CONTEXT$.get();

          try {
            Native.setSpecial(Stella.$MODULE$, ((Module)(self.homeContext)));
            Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
            return (Logic.coerceToBoundOrLocalSurrogate(self));

          } finally {
            Stella.$CONTEXT$.set(old$Context$000);
            Stella.$MODULE$.set(old$Module$000);
          }
        }
      }
      { Surrogate testValue000 = Stella_Object.safePrimaryType(self);

        if (Surrogate.subtypeOfSurrogateP(testValue000)) {
          { Surrogate self000 = ((Surrogate)(self));

            surrogate = self000;
          }
        }
        else if (Surrogate.subtypeOfSymbolP(testValue000)) {
          { Symbol self000 = ((Symbol)(self));

            surrogate = Surrogate.lookupSurrogateInModule(self000.symbolName, ((Module)(self000.homeContext)), false);
            if ((surrogate == null) &&
                (!(((Module)(self000.homeContext)) == ((Module)(Stella.$MODULE$.get()))))) {
              surrogate = Surrogate.lookupSurrogateInModule(self000.symbolName, ((Module)(Stella.$MODULE$.get())), false);
            }
          }
        }
        else {
          { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

            stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
            throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
          }
        }
      }
      if ((surrogate != null) &&
          (surrogate.surrogateValue != null)) {
        return (surrogate);
      }
      return (Stella.shadowSurrogate(self.symbolName));
    }
  }