Narrow covariant type parameter

@param optional Optional with covariant type parameter
@return Narrowed Optional
323350
public static <T> Optional<T> narrow(final Optional<? extends T> optional) {
        return (Optional<T>) optional;
    }
221165
private Map<String, TypeVariableDefinition> getEnclosingTypeVars()
  {
    ICompilableType gsClass = getGosuClass();
    if( gsClass == null )
    {
      return Collections.emptyMap();
    }
    Map<String, TypeVariableDefinition> mapTypeVarDefByName = new HashMap<>( 2 );
    while( !gsClass.isStatic() && gsClass.getEnclosingType() != null )
    {
      // Note we don't resolve type vars defined in outer for static inner classes.
      // This is because we do not maintain separate inner classes for each
      // parameterization of a generic outer class

      ICompilableType enclosingType = gsClass.getEnclosingType();
      for( IGenericTypeVariable gtv : enclosingType.getGenericTypeVariables() )
      {
        Map<String, ITypeVariableDefinition> typeVarMap = getTypeVariables();
        if( !typeVarMap.containsKey( gtv.getTypeVariableDefinition().getName() ) )
        {
          getTypeVariables().put( gtv.getName(), gtv.getTypeVariableDefinition() );
        }
      }
      gsClass = enclosingType;
    }
    return mapTypeVarDefByName;
  }
534687
static <T> Optional<Equivalence.Wrapper<T>> wrapOptionalInEquivalence(
      Equivalence<T> equivalence, Optional<T> optional) {
    return optional.isPresent()
        ? Optional.of(equivalence.wrap(optional.get()))
        : Optional.<Equivalence.Wrapper<T>>absent();
  }
6179
@javax.annotation.Nonnull
    public java.util.Optional<java.util.Map<String,net.morimekta.providence.model.ProgramMeta>> optionalIncludes() {
        return java.util.Optional.ofNullable(mIncludes);
    }
535385
function getApparentTypeOfTypeParameter(type) {
            if (!type.resolvedApparentType) {
                var constraintType = getConstraintOfTypeParameter(type);
                while (constraintType && constraintType.flags & 16384 /* TypeParameter */) {
                    constraintType = getConstraintOfTypeParameter(constraintType);
                }
                type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type);
            }
            return type.resolvedApparentType;
        }
718651
@NotNull
    public static OptionalLong ofNullable(@Nullable Long value) {
        return value == null ? EMPTY : new OptionalLong(value);
    }
634576
public final Parser<T> optional(T defaultValue) {
    return Parsers.or(this, Parsers.constant(defaultValue));
  }
1356346
public Optional<MapperInstance> getDeserializer( JType type ) {
        return Optional.fromNullable( deserializers.get( type.getQualifiedSourceName() ) );
    }
523748
@javax.annotation.Nonnull
    public java.util.Optional<net.morimekta.providence.PApplicationExceptionType> optionalId() {
        return java.util.Optional.ofNullable(mId);
    }
654386
public static <T> OptionalValue<T> ofNullable(T value) {
        return new GenericOptionalValue<T>(RUNTIME_SOURCE, DEFAULT_KEY, value);
    }
1036876
public static final <T extends Comparable<? super T>> Optional<Tuple2<T, T>> intersect(Tuple2<T, T> left, Tuple2<T, T> right) {
        if (overlaps(left, right))
            return Optional.of(new Tuple2<>(
                left.v1.compareTo(right.v1) >= 0 ? left.v1 : right.v1,
                left.v2.compareTo(right.v2) <= 0 ? left.v2 : right.v2
            ));
        else
            return Optional.empty();
    }
955025
public static <T, R> Optional<R> getOptionalIfExist(Optional<T> optional,
            Function<T, R> returnBuilderFunction) {
        return optional.map(returnBuilderFunction);
    }
475393
public static <W extends WitnessType<W>,A> OptionalT<W,A> of(final AnyM<W,Optional<A>> monads) {
        return new OptionalT<>(
                                 monads);
    }
328118
public static Optional<TypeElement> maybeAsTypeElement(TypeMirror type) {
    Optional<DeclaredType> declaredType = maybeDeclared(type);
    if (declaredType.isPresent()) {
      return maybeType(declaredType.get().asElement());
    } else {
      return Optional.empty();
    }
  }
1165942
public Optional<MapperInstance> getSerializer( JType type ) {
        return Optional.fromNullable( serializers.get( type.getQualifiedSourceName() ) );
    }
191436
public static @NonNull OptionalDouble map(final @NonNull OptionalDouble optional, final @NonNull DoubleUnaryOperator operator) {
    requireNonNull(operator, "operator");
    return optional.isPresent() ? OptionalDouble.of(operator.applyAsDouble(optional.getAsDouble())) : OptionalDouble.empty();
  }
1354575
public static <T, C extends Collection<T>> Optional<C>
    getOptional(C collection) {
        return Optional.ofNullable(collection).filter(c -> c.size() > 0);
    }