@Override protected void doVisitTypeReference(LightweightTypeReference reference, UnboundTypeReference declaration) { if (declaration.internalIsResolved() || getOwner().isResolved(declaration.getHandle())) { declaration.tryResolve(); outerVisit(declaration, reference, declaration, getExpectedVariance(), getActualVariance()); } else if (reference.isValidHint()) { addHint(declaration, reference); } }
protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { LightweightTypeReference wrapped = getStricterConstraint(typeParameter, reference.getWrapperTypeIfPrimitive()); if (wrapped != null) { typeParameter.acceptHint(wrapped, getTypeArgumentSource(), getOrigin(), getExpectedVariance(), getActualVariance()); } }
@Override protected void doVisitArrayTypeReference(ArrayTypeReference reference, ParameterizedTypeReference declaration) { JvmType type = declaration.getType(); if (type instanceof JvmTypeParameter) { if (shouldProcess((JvmTypeParameter) type)) { JvmTypeParameter typeParameter = (JvmTypeParameter) type; processTypeParameter(typeParameter, reference); } } else { if (!declaration.isRawType() && (declaration.isType(List.class) || declaration.isType(Collection.class) || declaration.isType(Iterable.class))) { LightweightTypeReference elementType = declaration.getTypeArguments().get(0); LightweightTypeReference componentType = reference.getComponentType(); outerVisit(componentType.getInvariantBoundSubstitute(), elementType); } } } }
@Override protected void resolveAgainstActualType(LightweightTypeReference declaredType, LightweightTypeReference actualType, final AbstractTypeComputationState state) { super.resolveAgainstActualType(declaredType, actualType, state); if (!isStatic() && !isExtension()) { DeferredTypeParameterHintCollector collector = new DeferredTypeParameterHintCollector(state.getReferenceOwner()); collector.processPairedReferences(declaredType, actualType); } }
@Override public void doVisitUnboundTypeReference(UnboundTypeReference reference, ParameterizedTypeReference declaration) { addHint(reference, declaration); }
@Override protected TypeParameterSubstitutor<?> createTypeParameterSubstitutor(Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping) { return new UnboundTypeParameterPreservingSubstitutor(mapping, getOwner()); }
protected void propageResolvedTypeToConstraints(List<LightweightBoundTypeArgument> hints) { if (!resolvedTo.isRawType()) { for(LightweightBoundTypeArgument hint: hints) { LightweightTypeReference hintReference = hint.getTypeReference(); if (hintReference != null && !hintReference.isRawType() && hint.getSource() == BoundTypeArgumentSource.CONSTRAINT) { DeferredTypeParameterHintCollector collector = new DeferredTypeParameterHintCollector(getOwner()) { @Override protected BoundTypeArgumentSource getTypeArgumentSource() { return BoundTypeArgumentSource.INFERRED_CONSTRAINT; } @Override protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { if (typeParameter.getHandle() != getHandle()) super.addHint(typeParameter, reference); } }; collector.processPairedReferences(hintReference, resolvedTo); } } } }
@Override protected void resolveAgainstActualType(LightweightTypeReference declaredType, LightweightTypeReference actualType, final AbstractTypeComputationState state) { super.resolveAgainstActualType(declaredType, actualType, state); if (!isStatic() || ((actualType.hasTypeArguments() || actualType.isArray()) && getDeclaredTypeParameters().isEmpty())) { DeferredTypeParameterHintCollector collector = new DeferredTypeParameterHintCollector(state.getReferenceOwner()); collector.processPairedReferences(declaredType, actualType); } }
@Override protected void doVisitUnboundTypeReference(UnboundTypeReference reference, CompoundTypeReference declaration) { if (declaration.isSynonym()) { super.doVisitUnboundTypeReference(reference, declaration); } else { addHint(reference, declaration); } } };
protected LightweightTypeReference copy(UnboundTypeReference reference) { return reference.copyInto(getOwner()); }
collector.processPairedReferences(substitutedFeatureType, expectedType);
@Override protected void addHint(UnboundTypeReference typeParameter, LightweightTypeReference reference) { if (typeParameter.getHandle() != getHandle()) super.addHint(typeParameter, reference); } };