protected ITypeArgumentContext getExpectedTypeContext(JvmTypeReference declaredType, JvmTypeReference expectedType) { final Multimap<JvmTypeParameter, ResolveInfo> result = createTemporaryMultimap(); resolveAgainstActualType(declaredType, expectedType, result, false, -1); Map<JvmTypeParameter, JvmTypeReference> normalized = normalizedCopy(result); if (normalized.isEmpty()) return null; return new TypeArgumentContext(normalized, typeReferences, typesFactory, rawTypeHelper, primitives); }
@Override protected ITypeArgumentContext getDeclaredBoundsContext(JvmExecutable feature) { if (primaryLog.isDebugEnabled()) { primaryLog.debug(indentation + "compute declared bounds context for " + getIdentifier(feature)); } return contextProviderDelegate.getDeclaredBoundsContext(feature); }
@Override protected ITypeArgumentContext getExpectedTypeContext(JvmTypeReference declaredType, JvmTypeReference expectedType) { if (primaryLog.isDebugEnabled()) { primaryLog.debug(indentation + "compute expected type context for " + expectedType + " <= " + declaredType); } return contextProviderDelegate.getExpectedTypeContext(declaredType, expectedType); }
if (receiverType != null) { nextLevel = 1; return contextProvider.getReceiverContext(receiverType); if (explicitTypeArguments != null && !explicitTypeArguments.isEmpty()) { nextLevel = 2; return contextProvider.getExplicitArgumentContext((JvmExecutable) feature, explicitTypeArguments); if (argumentTypes != null && !argumentTypes.isEmpty()) { nextLevel = 3; return contextProvider.getParameterContext((JvmExecutable) feature, argumentTypes); if (expectedType != null) { nextLevel = 4; return contextProvider.getExpectedTypeContext(declaredType, expectedType); if (feature instanceof JvmExecutable && ((JvmExecutable) feature).isVarArgs()) { nextLevel = -1; return contextProvider.getDeclaredBoundsContext((JvmExecutable) feature);
protected ITypeArgumentContext getParameterContext( JvmExecutable executable, List<JvmTypeReference> argumentTypes) { final Multimap<JvmTypeParameter, ResolveInfo> result = createTemporaryMultimap(); List<JvmFormalParameter> parameters = executable.getParameters(); int paramCount = parameters.size(); JvmTypeReference argumentType = argumentTypes.get(i); if (argumentType != null && parameterType != null && !typeReferences.is(argumentType, Void.TYPE)) { resolveAgainstActualType(parameterType, argumentType, result, true, i); JvmTypeReference parameterType = parameters.get(i).getParameterType(); if (parameterType != null) { resolveAgainstActualType(parameterType, null, result, true, i); if (lastArgumentType instanceof JvmGenericArrayTypeReference) { if (((JvmGenericArrayTypeReference) lastArgumentType).getDimensions() == ((JvmGenericArrayTypeReference) varArgParameterType).getDimensions()) { resolveAgainstActualType(varArgParameterType, lastArgumentType, result, true, paramCount); Map<JvmTypeParameter, JvmTypeReference> normalized = normalizedCopy(result); return new TypeArgumentContext(normalized, typeReferences, typesFactory, rawTypeHelper, primitives); resolveAgainstActualType(varArgComponentType, lastArgumentType, result, true, paramCount); JvmTypeReference commonVarArgType = getConformanceComputer().getCommonSuperType(actualVarArgTypes); resolveAgainstActualType(varArgComponentType, commonVarArgType, result, true, paramCount); Map<JvmTypeParameter, JvmTypeReference> normalized = normalizedCopy(result); if (normalized.isEmpty()) return null;
Map.Entry<JvmTypeParameter, ResolveInfo> singleElement = Iterables.getOnlyElement(map.entries()); ResolveInfo singleResolveInfo = singleElement.getValue(); JvmTypeReference reference = wildcardAwareGetReference(singleResolveInfo); return Collections.singletonMap(singleElement.getKey(), reference); Map<JvmTypeParameter, JvmTypeReference> result = createMapWithTweakedToString(); for(JvmTypeParameter boundParameter: map.keySet()) { Collection<ResolveInfo> boundTo = map.get(boundParameter); if (boundTo.size() == 1) { ResolveInfo singleResolveInfo = Iterables.getOnlyElement(boundTo); JvmTypeReference reference = wildcardAwareGetReference(singleResolveInfo); result.put(boundParameter, reference); } else { boolean conformant = true; for(ResolveInfo lower: lowers) { if (!getConformanceComputer().isConformant(info.reference, lower.reference)) { conformant = false; break; reference = upper; else reference = wildcardAwareGetReference(bestResolvedLower); } else { reference = wildcardAwareGetReference(bestResolvedLower); reference = wildcardAwareGetReference(bestResolvedLower); Map<JvmTypeParameter, JvmTypeReference> normalizedCopy = normalizedCopy(result);
protected TypeArgumentContext getReceiverContext(JvmTypeReference receiverType) { final Map<JvmTypeParameter, JvmTypeReference> result = createTemporaryMap(); final Set<JvmType> visited = Sets.newHashSet(); boolean rawType = new AbstractTypeReferenceVisitor.InheritanceAware<Boolean>() { if (rawType) return new TypeArgumentContext(null, typeReferences, typesFactory, rawTypeHelper, primitives); Map<JvmTypeParameter, JvmTypeReference> normalized = normalizedCopy(result); if (normalized.isEmpty()) return null;
public Iterable<JvmFeature> getAllJvmFeatures(JvmTypeReference type) { if (type == null) return Collections.emptyList(); ITypeArgumentContext context = contextProvider.getTypeArgumentContext( new TypeArgumentContextProvider.ReceiverRequest(type)); JvmType rawType = type.getType(); if (rawType == null || rawType.eIsProxy() || !(rawType instanceof JvmDeclaredType)) return Collections.emptyList(); return getAllJvmFeatures((JvmDeclaredType) rawType, context); }
@Override protected TypeArgumentContext getReceiverContext(JvmTypeReference receiverType) { if (primaryLog.isDebugEnabled()) { primaryLog.debug(indentation + "compute receiver context for " + receiverType); } return contextProviderDelegate.getReceiverContext(receiverType); }
protected ITypeArgumentContext getExplicitArgumentContext( JvmExecutable executable, List<JvmTypeReference> explicitTypeArguments) { Map<JvmTypeParameter, JvmTypeReference> result = createTemporaryMap(); List<JvmTypeParameter> typeParameters = executable.getTypeParameters(); if (typeParameters.isEmpty() && executable instanceof JvmConstructor) { JvmDeclaredType declaringType = executable.getDeclaringType(); if (declaringType instanceof JvmTypeParameterDeclarator) { typeParameters = ((JvmTypeParameterDeclarator) declaringType).getTypeParameters(); } } for(int i = 0; i < typeParameters.size() && i < explicitTypeArguments.size(); i++) { JvmTypeParameter typeParameter = typeParameters.get(i); JvmTypeReference typeArgument = explicitTypeArguments.get(i); if (typeParameter != null && typeArgument != null) result.put(typeParameters.get(i), explicitTypeArguments.get(i)); } if (result.isEmpty()) return null; return new TypeArgumentContext(result, typeReferences, typesFactory, rawTypeHelper, primitives); }
@Override protected ITypeArgumentContext getParameterContext(JvmExecutable executable, List<JvmTypeReference> argumentTypes) { if (primaryLog.isDebugEnabled()) { primaryLog.debug(indentation + "compute parameter context for " + getIdentifier(executable) + " with " + argumentTypes); } return contextProviderDelegate.getParameterContext(executable, argumentTypes); }
@Override protected ITypeArgumentContext getExplicitArgumentContext(JvmExecutable executable, List<JvmTypeReference> explicitTypeArguments) { if (primaryLog.isDebugEnabled()) { primaryLog.debug(indentation + "compute explicit argument context for " + explicitTypeArguments + " " + getIdentifier(executable)); } return contextProviderDelegate.getExplicitArgumentContext(executable, explicitTypeArguments); }
return Collections.singletonMap(singleElement.getKey(), singleElement.getValue()); Map<JvmTypeParameter, JvmTypeReference> result = createMapWithTweakedToString(); for(Map.Entry<JvmTypeParameter, JvmTypeReference> entry: map.entrySet()) { final JvmTypeParameter parameter = entry.getKey();
protected void initializeDistance(final JvmTypeReference firstType, Multimap<JvmType, JvmTypeReference> all, Multiset<JvmType> cumulatedDistance) { ITypeArgumentContext firstContext = getTypeArgumentContextProvider().getTypeArgumentContext( new TypeArgumentContextProvider.ReceiverRequest(firstType)); MaxDistanceRawTypeAcceptor acceptor = new MaxDistanceRawTypeAcceptor( cumulatedDistance, all, new ArgumentResolver(firstContext)); acceptor.accept(firstType, 0); superTypeCollector.collectSuperTypes(firstType, acceptor); }
protected TypeArgumentContext getBoundTypeParameters(JvmParameterizedTypeReference reference) { return conformanceComputer.getTypeArgumentContextProvider().getReceiverContext(reference); }
protected ITypeArgumentContext getDeclaredBoundsContext(JvmExecutable executable) { JvmTypeParameterDeclarator declarator = executable; Map<JvmTypeParameter, JvmTypeReference> result = createTemporaryMap(); while(declarator != null) { List<JvmTypeParameter> typeParameters = declarator.getTypeParameters();