コード例 #1
0
 private void setMethodConstraints(Iterable<TypeParameterConstraintsClauseNode> constraintClauses, MethodBuilder methodBuilder) {
     var packageName = methodBuilder.DeclaringType.PackageName;
     foreach (var constraint in constraintClauses) {
         var name = context.getIdentifier(constraint.NameOffset, constraint.NameLength);
         var bound = CompilerHelper.resolveTypeReference(context, packageName, constraint.Constraints[0]);
         if (bound.IsFinal) {
             context.addError(CompileErrorId.ConstraintNotInterfaceOrFinal, constraint.Constraints[0],
                 BytecodeHelper.getDisplayName(bound));
         }
         methodBuilder.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));
             }
             methodBuilder.addGenericConstraint(name, bound);
         }
     }
 }