protected LightweightBoundTypeArgument boundByDefaultSource(LightweightTypeReference reference) { return new LightweightBoundTypeArgument(reference.getWrapperTypeIfPrimitive(), defaultSource, getOrigin(), getExpectedVariance(), getActualVariance()); }
public void populateTypeParameterMapping(LightweightTypeReference declaredType, LightweightTypeReference actualType) { processPairedReferences(declaredType, actualType); }
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> getTypeParameterMapping() { if (typeParameterMapping.keySet().containsAll(getParametersToProcess())) { return typeParameterMapping; for(JvmTypeParameter pendingParameter: getParametersToProcess()) { if (!result.containsKey(pendingParameter)) { for(JvmTypeConstraint constraint: pendingParameter.getConstraints()) { JvmType constraintType = constraintReference.getType(); if (!result.containsKey(constraintType)) { if (!getParametersToProcess().contains(constraintType)) { LightweightTypeReference lightweightReference = getOwner().toLightweightTypeReference(constraintReference); Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> constraintParameterMapping = new DeclaratorTypeArgumentCollector().getTypeParameterMapping(lightweightReference); TypeParameterByConstraintSubstitutor substitutor = new TypeParameterByConstraintSubstitutor(constraintParameterMapping, getOwner()); LightweightTypeReference resolvedConstraint = lightweightReference.accept( substitutor, substitutor.createVisiting(pendingParameter)); Maps2.putIntoListMap(pendingParameter, boundByConstraint(resolvedConstraint, pendingParameter), result); } else { LightweightTypeReference lightweightReference = getOwner().newReferenceToObject(); Maps2.putIntoListMap(pendingParameter, boundByConstraint(lightweightReference, pendingParameter), result);
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> getFunctionTypeParameterMapping( LightweightTypeReference functionType, JvmOperation operation, ActualTypeArgumentCollector typeArgumentCollector, ITypeReferenceOwner owner) { /* * The mapping is populated by means of the function type to declarator mapping, though a method * * m(Zonk zonk) { .. } * * with * * interface Foo<X> { * void bar(X x); * } * interface Zonk extends Foo<CharSequence> {} * * infers the parameter type CharSequence for the lamba param */ LightweightTypeReference lightweightTypeReference = owner.toLightweightTypeReference(operation.getDeclaringType()); typeArgumentCollector.populateTypeParameterMapping(lightweightTypeReference, functionType); Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> typeParameterMapping = typeArgumentCollector.rawGetTypeParameterMapping(); return typeParameterMapping; }
@Override protected void processTypeParameter(JvmTypeParameter typeParameter, LightweightTypeReference reference) { Maps2.putIntoListMap(typeParameter, boundByDefaultSource(reference), typeParameterMapping); }