+ 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);
+
+ ComponentAccess[] componentAccesses = constructor.componentAccesses != null
+ ? constructor.componentAccesses
+ : SCLConstructor.DEFAULT_FIELD_NAMES[constructor.recordFieldNames.length];
+ 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)},
+ componentAccesses[i].toMethodRef(constructor.javaName, javaTypeTranslator.toTypeDesc(out)),
+ null);
+ module.addFieldAccessor(constructor.recordFieldNames[i], accessor);
+ }
+ }
+ });
+ }
+ }