public boolean isConformant(JvmTypeReference left, JvmTypeReference right, boolean ignoreGenerics) { if (left == right && left != null) return true; TypeConformanceResult result = isConformant(left, right, new TypeConformanceComputationArgument(ignoreGenerics, false, true)); return result.isConformant(); }
@Override public TypeConformanceResult doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference left, JvmGenericArrayTypeReference right, TypeConformanceComputationArgument.Internal<JvmGenericArrayTypeReference> param) { JvmTypeReference leftComponent = left.getComponentType(); JvmTypeReference rightComponent = right.getComponentType(); return conformanceComputer.isConformant(leftComponent, rightComponent, new TypeConformanceComputationArgument(param.rawType, param.asTypeArgument, false)); }
@Override public TypeConformanceResult doVisitTypeReference(JvmWildcardTypeReference leftWildcard, JvmTypeReference right, TypeConformanceComputationArgument.Internal<JvmWildcardTypeReference> param) { if (param.asTypeArgument) { List<JvmTypeConstraint> constraints = leftWildcard.getConstraints(); if (!constraints.isEmpty()) { for(JvmTypeConstraint constraint: constraints) { if (constraint instanceof JvmUpperBound) { TypeConformanceResult result = conformanceComputer.isConformant(constraint.getTypeReference(), right, new TypeConformanceComputationArgument(false, false, false)); if (!result.isConformant()) { return result; } } else if (constraint instanceof JvmLowerBound) { TypeConformanceResult result = conformanceComputer.isConformant(right, constraint.getTypeReference(), new TypeConformanceComputationArgument(false, false, false)); if (!result.isConformant()) { return result; } } } return TypeConformanceResult.SUCCESS; } else { // no constraints found return TypeConformanceResult.SUCCESS; } } return TypeConformanceResult.FAILED; }
bestResolvedLower = resolvedLower; } else { TypeConformanceResult conformanceResult = conformanceComputer.isConformant(bestResolvedLower.reference, resolvedLower.reference, new TypeConformanceComputationArgument(false, false, true)); if (conformanceResult.isConformant() && conformanceResult.getKinds().contains(TypeConformanceResult.Kind.SUBTYPE)) bestResolvedLower = resolvedLower;
protected TypeConformanceResult areArgumentsConformant(JvmParameterizedTypeReference leftReference, JvmParameterizedTypeReference rightReference) { TypeArgumentContext leftArgumentContext = getBoundTypeParameters(leftReference); if (leftArgumentContext != null && !leftArgumentContext.isRawTypeContext()) { Collection<JvmTypeParameter> boundParameters = leftArgumentContext.getBoundParameters(); Set<Pair<JvmTypeReference, JvmTypeReference>> tested = Sets.newHashSet(); if (!boundParameters.isEmpty()) { TypeArgumentContext rightArgumentContext = getBoundTypeParameters(rightReference); if (rightArgumentContext == null) { return TypeConformanceResult.FAILED; } if (!rightArgumentContext.isRawTypeContext()) { for(JvmTypeParameter leftTypeParameter: boundParameters) { JvmTypeReference leftBound = leftArgumentContext.getBoundArgument(leftTypeParameter); JvmTypeReference rightBound = rightArgumentContext.getBoundArgument(leftTypeParameter); if (leftBound != rightBound && rightBound != null) { if (tested.add(Tuples.create(leftBound, rightBound))) { TypeConformanceResult result = conformanceComputer.isConformant(leftBound, rightBound, new TypeConformanceComputationArgument(false, true, false)); if (!result.isConformant()) { return result; } } } } } } } return TypeConformanceResult.SUCCESS; }
for(JvmTypeConstraint rightConstraint: rightConstraints) { if (rightConstraint instanceof JvmUpperBound) { TypeConformanceResult result = conformanceComputer.isConformant(leftUpperBound, rightConstraint.getTypeReference(), new TypeConformanceComputationArgument(false, false, false)); if (!result.isConformant()) { return result; } else if (rightConstraint instanceof JvmLowerBound) { lowerBoundSeen = true; TypeConformanceResult result = conformanceComputer.isConformant(rightConstraint.getTypeReference(), leftLowerBound, new TypeConformanceComputationArgument(false, false, false)); if (!result.isConformant()) { return TypeConformanceResult.FAILED;