@Override public LightweightTypeReference getWrapperTypeIfPrimitive() { if (internalIsResolved()) return resolvedTo.getWrapperTypeIfPrimitive(); return super.getWrapperTypeIfPrimitive(); }
protected List<LightweightTypeReference> replacePrimitivesAndRemoveAnyReferences(List<LightweightTypeReference> types) { List<LightweightTypeReference> result = Lists.newArrayList(); for(LightweightTypeReference type: types) { if (!(type.isAny())) result.add(type.getWrapperTypeIfPrimitive()); } return result; }
protected LightweightBoundTypeArgument boundByConstraint(LightweightTypeReference reference, Object origin) { return new LightweightBoundTypeArgument(reference.getWrapperTypeIfPrimitive(), BoundTypeArgumentSource.CONSTRAINT, origin, VarianceInfo.OUT, VarianceInfo.OUT); }
@Override public LightweightTypeReference enhance(ParameterizedTypeReference reference) { LightweightTypeReference componentType = type.getComponentType(); LightweightTypeReference wrapper = componentType.getWrapperTypeIfPrimitive(); reference.addTypeArgument(wrapper); return reference; } });
protected List<JvmType> getParamTypes(JvmOperation jvmOperation, boolean wrapPrimitives) { List<JvmType> types = newArrayList(); for (JvmFormalParameter p : jvmOperation.getParameters()) { LightweightTypeReference typeReference = toLightweightTypeReference(p.getParameterType()); if (wrapPrimitives) { typeReference = typeReference.getWrapperTypeIfPrimitive(); } types.add(typeReference.getType()); } return types; }
@Override public TypeReference getWrapperIfPrimitive() { return this.getCompilationUnit().toTypeReference(this.getDelegate().getWrapperTypeIfPrimitive()); }
protected void deferredBindTypeArgument(/* @Nullable */ LightweightTypeReference declared, LightweightTypeReference actual, ITypeComputationState state) { if (declared != null && actual != null) { // TODO double check other clients of the ExpectationTypeParameterHintCollector // It may be possible / necessary to use the very same implementation instead of anonymous // specializations or it may be possible that this specialization is no longer necessary. ExpectationTypeParameterHintCollector collector = new ResolvingTypeParameterHintCollector(state.getReferenceOwner(), BoundTypeArgumentSource.INFERRED); collector.processPairedReferences(declared, actual.getWrapperTypeIfPrimitive()); } }
@Override protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { LightweightTypeReference wrapped = reference.getWrapperTypeIfPrimitive(); typeParameter.acceptHint(wrapped, BoundTypeArgumentSource.RESOLVED, getOrigin(), getExpectedVariance(), getActualVariance()); } }.processPairedReferences(operationParameterType, closureParameterType);
@Override public JvmTypeReference toTypeReference() { TypesFactory typesFactory = getTypesFactory(); JvmWildcardTypeReference result = typesFactory.createJvmWildcardTypeReference(); if (upperBounds != null && !upperBounds.isEmpty()) { for(LightweightTypeReference typeArgument: upperBounds) { JvmUpperBound constraint = typesFactory.createJvmUpperBound(); constraint.setTypeReference(typeArgument.getWrapperTypeIfPrimitive().toTypeReference()); result.getConstraints().add(constraint); } } if (lowerBound != null) { JvmLowerBound constraint = typesFactory.createJvmLowerBound(); constraint.setTypeReference(lowerBound.getWrapperTypeIfPrimitive().toTypeReference()); result.getConstraints().add(constraint); } return result; }
protected void doAddHint(UnboundTypeReference typeParameter, LightweightTypeReference reference, BoundTypeArgumentSource source) { typeParameter.acceptHint( reference.getWrapperTypeIfPrimitive(), source, getOrigin(), getExpectedVariance(), getActualVariance()); } };
@Override public LightweightTypeReference enhance(ParameterizedTypeReference reference) { LightweightTypeReference argumentType = owner.newParameterizedTypeReference((JvmType) feature); if (argumentType.isPrimitiveVoid()) { argumentType = owner.newReferenceTo(Void.class); } else { argumentType = argumentType.getWrapperTypeIfPrimitive(); } reference.addTypeArgument(argumentType); return reference; } });
private LightweightBoundTypeArgument boundByInference(LightweightTypeReference reference) { return new LightweightBoundTypeArgument(reference.getWrapperTypeIfPrimitive(), BoundTypeArgumentSource.INFERRED, getOrigin(), getExpectedVariance(), getActualVariance()); } }
protected LightweightBoundTypeArgument boundByDefaultSource(LightweightTypeReference reference) { return new LightweightBoundTypeArgument(reference.getWrapperTypeIfPrimitive(), defaultSource, getOrigin(), getExpectedVariance(), getActualVariance()); }
protected int doIsConformant(ArrayTypeReference left, ParameterizedTypeReference right, int flags) { if ((flags & AS_TYPE_ARGUMENT) == 0 && (flags & ALLOW_SYNONYMS) != 0) { ArrayTypeReference rightAsArray = right.tryConvertToArray(); if (rightAsArray != null) { LightweightTypeReference leftComponent = left.getComponentType().getWrapperTypeIfPrimitive(); LightweightTypeReference rightComponent = rightAsArray.getComponentType(); int result = doIsConformant(leftComponent, rightComponent, flags & ~(ALLOW_BOXING_UNBOXING | ALLOW_PRIMITIVE_WIDENING | ALLOW_SYNONYMS | ALLOW_FUNCTION_CONVERSION)); if ((result & SUCCESS) != 0) { return result | DEMAND_CONVERSION | SYNONYM; } } } return flags; }
@Override protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { LightweightTypeReference wrapped = reference.getWrapperTypeIfPrimitive(); if (source == BoundTypeArgumentSource.INFERRED_CONSTRAINT) { wrapped = getStricterConstraint(typeParameter, wrapped); } if (wrapped != null) { typeParameter.acceptHint(wrapped, source, getOrigin(), getExpectedVariance(), getActualVariance()); } } };
public IInputKey getExpressionType() { LightweightTypeReference expressionType = xbaseResolver.resolveTypes(xExpression).getReturnType(xExpression); if (expressionType == null) { return new JavaTransitiveInstancesKey(Object.class); } else if (expressionType instanceof UnknownTypeReference) { return new JavaTransitiveInstancesKey(Object.class); } else { return new JavaTransitiveInstancesKey(expressionType.getWrapperTypeIfPrimitive().getJavaIdentifier()); } }
@Override public void exec(ITreeAppendable appendable) { TypeConformanceComputationArgument rawNoSynonyms = new TypeConformanceComputationArgument(true, false, true, true, false, false); if (caseParamType.isAssignableFrom(dispatchParamType, rawNoSynonyms) && !dispatchParamType.isPrimitive()) { appendable.append(name).append(" != null"); } else { appendable.append(name).append(" instanceof "); JvmType type = caseParamType.getWrapperTypeIfPrimitive().getType(); if (type == null) { throw new IllegalStateException(String.valueOf(caseParamType)); } appendable.append(type); } } });
protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { LightweightTypeReference wrapped = getStricterConstraint(typeParameter, reference.getWrapperTypeIfPrimitive()); if (wrapped != null) { typeParameter.acceptHint(wrapped, getTypeArgumentSource(), getOrigin(), getExpectedVariance(), getActualVariance()); } }
@Override public LightweightTypeReference doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference) { JvmType type = getType(reference); if (type == null || type.eIsProxy()) { return createUnknownTypeReference(reference); } ParameterizedTypeReference result = owner.newParameterizedTypeReference(type); for(JvmTypeReference argument: reference.getArguments()) { result.addTypeArgument(visit(argument).getWrapperTypeIfPrimitive()); } return result; }
@Override protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { LightweightTypeReference wrapped = reference.getWrapperTypeIfPrimitive(); typeParameter.acceptHint(wrapped, BoundTypeArgumentSource.RESOLVED, getOrigin(), getExpectedVariance(), getActualVariance()); LightweightTypeReference typeParameterReference = reference.getOwner().newParameterizedTypeReference(typeParameter.getTypeParameter()); if (validParameterTypes && !typeParameterReference.getRawTypeReference().isAssignableFrom(reference)) { validParameterTypes = false; } } }.processPairedReferences(operationParameterType, closureParameterType);