private void setTypeConstraints(Iterable<TypeParameterConstraintsClauseNode> constraintClauses, TypeBuilder typeBuilder) { var packageName = typeBuilder.PackageName; foreach (var constraint in constraintClauses) { var name = context.getIdentifier(constraint.NameOffset, constraint.NameLength); TypeInfo bound = CompilerHelper.resolveTypeReference(context, packageName, constraint.Constraints[0]); if (bound.IsFinal) { context.addError(CompileErrorId.ConstraintNotInterfaceOrFinal, constraint.Constraints[0], BytecodeHelper.getDisplayName(bound)); } typeBuilder.addGenericConstraint(name, bound); for (int i = 1; i < constraint.Constraints.size(); i++) { bound = CompilerHelper.resolveTypeReference(context, packageName, constraint.Constraints[i]); if (!bound.IsInterface || bound.IsFinal) { context.addError(CompileErrorId.ConstraintNotInterfaceOrFinal, constraint.Constraints[i], BytecodeHelper.getDisplayName(bound)); } typeBuilder.addGenericConstraint(name, bound); } } }