+ if(constructors.length == 1) {
+ Constructor constructor = constructors[0];
+ if(constructor.recordFieldNames != null) {
+ fieldAccessorGenerators.add(new Runnable() {
+ @Override
+ public void run() {
+ Type in = Types.apply(dataType.name, dataType.parameters);
+ for(int i=0;i<constructor.recordFieldNames.length;++i) {
+ Type out = constructor.parameterTypes[i];
+ Constant accessor;
+ if(trivialDataType)
+ accessor = new SafeCoerce(dataType.parameters, in, out);
+ else
+ accessor = new CallJava(dataType.parameters, Types.NO_EFFECTS, out,
+ new Type[] {in}, new StackItem[] {new ParameterStackItem(0, in)},
+ new FieldRef(constructor.javaName, constructor.fieldNames != null ? constructor.fieldNames[i] : "c" + i,
+ javaTypeTranslator.toTypeDesc(out)),
+ null);
+ module.addFieldAccessor(constructor.recordFieldNames[i], accessor);
+ }
+ }
+ });
+ }
+ }