private List<SemanticError> check(DataType dataType) {
    	logger.finer("Checking semantic constraints on datatype " + dataType.name);
        final List<SemanticError> errors = new ArrayList<SemanticError>();
        
        final Set<String> constructorNames = new HashSet<String>();
        for(Constructor constructor : dataType.constructors) {
        	logger.finest("Checking semantic constraints on constructor " + constructor.name + " in datatype " + dataType.name);
            if (dataType.constructors.size() > 1 && dataType.name.equals(constructor.name)) {
            	logger.info("Constructor with same name as its data type " + dataType.name + ".");
                errors.add(_ConstructorDataTypeConflict(dataType.name));
            }
            if (constructorNames.contains(constructor.name)) {
            	logger.info("Two constructors with same name " + constructor.name + " in data type " + dataType.name + ".");
                errors.add(_DuplicateConstructor(dataType.name, constructor.name));
            } else {
                constructorNames.add(constructor.name);
            }
            errors.addAll(check(dataType, constructor));
        }
        return errors;
    }
private List < SemanticError > check ( DataType dataType ) { logger . finer ( "Checking semantic constraints on datatype " + dataType . name ) ; final List < SemanticError > errors = new ArrayList < SemanticError > ( ) ; final Set < String > constructorNames = new HashSet < String > ( ) ; for ( Constructor constructor : dataType . constructors ) { logger . finest ( "Checking semantic constraints on constructor " + constructor . name + " in datatype " + dataType . name ) ; if ( dataType . constructors . size ( ) > 1 && dataType . name . equals ( constructor . name ) ) { logger . info ( "Constructor with same name as its data type " + dataType . name + "." ) ; errors . add ( _ConstructorDataTypeConflict ( dataType . name ) ) ; } if ( constructorNames . contains ( constructor . name ) ) { logger . info ( "Two constructors with same name " + constructor . name + " in data type " + dataType . name + "." ) ; errors . add ( _DuplicateConstructor ( dataType . name , constructor . name ) ) ; } else { constructorNames . add ( constructor . name ) ; } errors . addAll ( check ( dataType , constructor ) ) ; } return errors ; }
Checks a data type for duplicate constructor names or constructors having the same name
as the data type

@param dataType DataType to check
@return Set<SemanticError> with the problems or empty set if there are none