2828import com .google .turbine .binder .bound .TypeBoundClass .FieldInfo ;
2929import com .google .turbine .binder .bound .TypeBoundClass .MethodInfo ;
3030import com .google .turbine .binder .bound .TypeBoundClass .ParamInfo ;
31+ import com .google .turbine .binder .bound .TypeBoundClass .RecordComponentInfo ;
3132import com .google .turbine .binder .bound .TypeBoundClass .TyVarInfo ;
3233import com .google .turbine .binder .env .Env ;
3334import com .google .turbine .binder .lookup .CompoundScope ;
3839import com .google .turbine .binder .sym .FieldSymbol ;
3940import com .google .turbine .binder .sym .MethodSymbol ;
4041import com .google .turbine .binder .sym .ParamSymbol ;
42+ import com .google .turbine .binder .sym .RecordComponentSymbol ;
4143import com .google .turbine .binder .sym .Symbol ;
4244import com .google .turbine .binder .sym .TyVarSymbol ;
4345import com .google .turbine .diag .TurbineError .ErrorKind ;
@@ -235,8 +237,7 @@ private SourceTypeBoundClass bind() {
235237
236238 SyntheticMethods syntheticMethods = new SyntheticMethods ();
237239
238- ImmutableList <ParamInfo > components =
239- bindComponents (scope , syntheticMethods , base .decl ().components ());
240+ ImmutableList <RecordComponentInfo > components = bindComponents (scope , base .decl ().components ());
240241
241242 ImmutableList .Builder <MethodInfo > methods =
242243 ImmutableList .<MethodInfo >builder ()
@@ -284,20 +285,17 @@ MethodSymbol create(ClassSymbol owner, String name) {
284285 }
285286 }
286287
287- private ImmutableList <ParamInfo > bindComponents (
288- CompoundScope scope ,
289- SyntheticMethods syntheticMethods ,
290- ImmutableList <Tree .VarDecl > components ) {
291- ImmutableList .Builder <ParamInfo > result = ImmutableList .builder ();
288+ private ImmutableList <RecordComponentInfo > bindComponents (
289+ CompoundScope scope , ImmutableList <Tree .VarDecl > components ) {
290+ ImmutableList .Builder <RecordComponentInfo > result = ImmutableList .builder ();
292291 for (Tree .VarDecl p : components ) {
293292 int access = 0 ;
294293 for (TurbineModifier m : p .mods ()) {
295294 access |= m .flag ();
296295 }
297- MethodSymbol msym = syntheticMethods .create (owner , "" );
298- ParamInfo param =
299- new ParamInfo (
300- new ParamSymbol (msym , p .name ().value ()),
296+ RecordComponentInfo param =
297+ new RecordComponentInfo (
298+ new RecordComponentSymbol (owner , p .name ().value ()),
301299 bindTy (scope , p .ty ()),
302300 bindAnnotations (scope , p .annos ()),
303301 access );
@@ -308,7 +306,7 @@ private ImmutableList<ParamInfo> bindComponents(
308306
309307 /** Collect synthetic and implicit methods, including default constructors and enum methods. */
310308 ImmutableList <MethodInfo > syntheticMethods (
311- SyntheticMethods syntheticMethods , ImmutableList <ParamInfo > components ) {
309+ SyntheticMethods syntheticMethods , ImmutableList <RecordComponentInfo > components ) {
312310 switch (base .kind ()) {
313311 case CLASS :
314312 return maybeDefaultConstructor (syntheticMethods );
@@ -322,13 +320,22 @@ ImmutableList<MethodInfo> syntheticMethods(
322320 }
323321
324322 private ImmutableList <MethodInfo > maybeDefaultRecordConstructor (
325- SyntheticMethods syntheticMethods , ImmutableList <ParamInfo > components ) {
323+ SyntheticMethods syntheticMethods , ImmutableList <RecordComponentInfo > components ) {
326324 if (hasConstructor ()) {
327325 return ImmutableList .of ();
328326 }
329327 MethodSymbol symbol = syntheticMethods .create (owner , "<init>" );
328+ ImmutableList .Builder <ParamInfo > params = ImmutableList .builder ();
329+ for (RecordComponentInfo component : components ) {
330+ params .add (
331+ new ParamInfo (
332+ new ParamSymbol (symbol , component .name ()),
333+ component .type (),
334+ component .annotations (),
335+ component .access ()));
336+ }
330337 return ImmutableList .of (
331- syntheticConstructor (symbol , components , TurbineVisibility .fromAccess (base .access ())));
338+ syntheticConstructor (symbol , params . build () , TurbineVisibility .fromAccess (base .access ())));
332339 }
333340
334341 private ImmutableList <MethodInfo > maybeDefaultConstructor (SyntheticMethods syntheticMethods ) {
@@ -450,7 +457,7 @@ private ImmutableList<MethodInfo> syntheticEnumMethods(SyntheticMethods syntheti
450457 }
451458
452459 private ImmutableList <MethodInfo > syntheticRecordMethods (
453- SyntheticMethods syntheticMethods , ImmutableList <ParamInfo > components ) {
460+ SyntheticMethods syntheticMethods , ImmutableList <RecordComponentInfo > components ) {
454461 ImmutableList .Builder <MethodInfo > methods = ImmutableList .builder ();
455462 MethodSymbol toStringMethod = syntheticMethods .create (owner , "toString" );
456463 methods .add (
@@ -496,7 +503,7 @@ private ImmutableList<MethodInfo> syntheticRecordMethods(
496503 null ,
497504 ImmutableList .of (),
498505 null ));
499- for (ParamInfo c : components ) {
506+ for (RecordComponentInfo c : components ) {
500507 MethodSymbol componentMethod = syntheticMethods .create (owner , c .name ());
501508 methods .add (
502509 new MethodInfo (
0 commit comments