private void resolveUpperBoundsFromWhereClause(Set<JetType> upperBounds) { JetClassOrObject classOrObject = JetStubbedPsiUtil.getPsiOrStubParent(jetTypeParameter, JetClassOrObject.class, true); if (classOrObject instanceof JetClass) { JetClass jetClass = (JetClass) classOrObject; for (JetTypeConstraint jetTypeConstraint : jetClass.getTypeConstraints()) { DescriptorResolver.reportUnsupportedClassObjectConstraint( resolveSession.getTrace(), jetTypeConstraint); JetSimpleNameExpression constrainedParameterName = jetTypeConstraint.getSubjectTypeParameterName(); if (constrainedParameterName != null) { if (getName().equals(constrainedParameterName.getReferencedNameAsName())) { resolveSession .getTrace() .record(BindingContext.REFERENCE_TARGET, constrainedParameterName, this); JetTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference(); if (boundTypeReference != null) { JetType boundType = resolveBoundType(boundTypeReference); if (!jetTypeConstraint.isClassObjectConstraint()) { upperBounds.add(boundType); } } } } } } }
@Nullable private static JetTypeConstraint findTypeParameterConstraint( @NotNull JetFunction function, @NotNull Name typeParameterName, int index) { if (index != 0) { int currentIndex = 0; for (JetTypeConstraint constraint : function.getTypeConstraints()) { JetSimpleNameExpression parameterName = constraint.getSubjectTypeParameterName(); assert parameterName != null; if (typeParameterName.equals(parameterName.getReferencedNameAsName())) { currentIndex++; } if (currentIndex == index) { return constraint; } } } return null; }