@@ -1073,11 +1073,9 @@ and genExpr astContext synExpr ctx =
1073
1073
let smallRecordExpr =
1074
1074
genTriviaFor SynExpr_ Record_ OpeningBrace openingBrace sepOpenS
1075
1075
+> optSingle
1076
- ( fun ( inheritType , inheritExpr ) ->
1076
+ ( fun inheritCtor ->
1077
1077
!- " inherit "
1078
- +> genType astContext inheritType
1079
- +> addSpaceBeforeClassConstructor inheritExpr
1080
- +> genExpr astContext inheritExpr
1078
+ +> genInheritConstructor astContext inheritCtor
1081
1079
+> onlyIf ( List.isNotEmpty xs) sepSemi)
1082
1080
inheritOpt
1083
1081
+> optSingle ( fun e -> genExpr astContext e +> !- " with " ) eo
@@ -2486,13 +2484,11 @@ and genMultilineRecordInstance
2486
2484
2487
2485
let expr =
2488
2486
match inheritOpt with
2489
- | Some ( t , e ) ->
2487
+ | Some inheritCtor ->
2490
2488
genTriviaFor SynExpr_ Record_ OpeningBrace openingBrace sepOpenS
2491
2489
+> atCurrentColumn (
2492
2490
!- " inherit "
2493
- +> genType astContext t
2494
- +> addSpaceBeforeClassConstructor e
2495
- +> genExpr astContext e
2491
+ +> autoIndentAndNlnIfExpressionExceedsPageWidth ( genInheritConstructor astContext inheritCtor)
2496
2492
+> onlyIf ( List.isNotEmpty xs) sepNln
2497
2493
+> fieldsExpr
2498
2494
+> genTriviaFor SynExpr_ Record_ ClosingBrace closingBrace sepCloseS
@@ -2551,22 +2547,16 @@ and genMultilineRecordInstanceAlignBrackets
2551
2547
let hasFields = List.isNotEmpty xs
2552
2548
2553
2549
match inheritOpt, eo with
2554
- | Some ( inheritType, inheritExpr), None ->
2555
- genTriviaFor SynExpr_ Record_ OpeningBrace openingBrace sepOpenS
2556
- +> ifElse hasFields ( indent +> sepNln) sepNone
2557
- +> !- " inherit "
2558
- +> genType astContext inheritType
2559
- +> addSpaceBeforeClassConstructor inheritExpr
2560
- +> genExpr astContext inheritExpr
2561
- +> ifElse
2562
- hasFields
2563
- ( sepNln
2564
- +> fieldsExpr
2565
- +> unindent
2566
- +> sepNln
2567
- +> genTriviaFor SynExpr_ Record_ ClosingBrace closingBrace sepCloseSFixed)
2568
- ( sepSpace +> genTriviaFor SynExpr_ Record_ ClosingBrace closingBrace sepCloseSFixed)
2569
-
2550
+ | Some inheritCtor, None ->
2551
+ genTriviaFor SynExpr_ Record_ OpeningBrace openingBrace sepOpenSFixed
2552
+ +> indentSepNlnUnindent (
2553
+ !- " inherit "
2554
+ +> autoIndentAndNlnIfExpressionExceedsPageWidth ( genInheritConstructor astContext inheritCtor)
2555
+ +> onlyIf hasFields sepNln
2556
+ +> fieldsExpr
2557
+ )
2558
+ +> sepNln
2559
+ +> genTriviaFor SynExpr_ Record_ ClosingBrace closingBrace sepCloseSFixed
2570
2560
| None, Some e ->
2571
2561
genTriviaFor SynExpr_ Record_ OpeningBrace openingBrace sepOpenS
2572
2562
+> atCurrentColumnIndent ( genExpr astContext e)
@@ -2586,6 +2576,18 @@ and genMultilineRecordInstanceAlignBrackets
2586
2576
+> ifElseCtx lastWriteEventIsNewline sepNone sepNln
2587
2577
+> genTriviaFor SynExpr_ Record_ ClosingBrace closingBrace sepCloseSFixed)
2588
2578
2579
+ and genInheritConstructor ( astContext : ASTContext ) ( inheritCtor : SynType * SynExpr ) =
2580
+ match inheritCtor with
2581
+ | TypeOnlyInheritConstructor t -> genType astContext t
2582
+ | UnitInheritConstructor t -> genType astContext t +> sepSpaceBeforeClassConstructor +> sepOpenT +> sepCloseT
2583
+ | ParenInheritConstructor ( t, px) ->
2584
+ genType astContext t
2585
+ +> sepSpaceBeforeClassConstructor
2586
+ +> expressionFitsOnRestOfLine ( genExpr astContext px) ( genMultilineFunctionApplicationArguments astContext px)
2587
+ | OtherInheritConstructor ( t, e) ->
2588
+ genType astContext t
2589
+ +> sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidth ( genExpr astContext e)
2590
+
2589
2591
and genMultilineAnonRecord ( isStruct : bool ) fields copyInfo ( astContext : ASTContext ) =
2590
2592
let recordExpr =
2591
2593
match copyInfo with
@@ -4194,32 +4196,8 @@ and genMemberDefn astContext node =
4194
4196
| MDOpen lid -> !- " open " +> genSynLongIdent false lid
4195
4197
// What is the role of so
4196
4198
| MDImplicitInherit ( t, e, _) ->
4197
- let genBasecall =
4198
- let shortExpr = genExpr astContext e
4199
-
4200
- let longExpr =
4201
- match e with
4202
- | Paren ( lpr, Tuple ( es, tr), rpr, pr) ->
4203
- indent
4204
- +> sepNln
4205
- +> indent
4206
- +> sepOpenTFor lpr
4207
- +> sepNln
4208
- +> ( col ( sepComma +> sepNln) es ( genExpr astContext)
4209
- |> genTriviaFor SynExpr_ Tuple tr)
4210
- +> unindent
4211
- +> sepNln
4212
- +> unindent
4213
- +> sepCloseTFor rpr
4214
- |> genTriviaFor SynExpr_ Paren pr
4215
- | _ -> genExpr astContext e
4216
-
4217
- expressionFitsOnRestOfLine shortExpr longExpr
4218
-
4219
4199
!- " inherit "
4220
- +> genType astContext t
4221
- +> addSpaceBeforeClassConstructor e
4222
- +> genBasecall
4200
+ +> autoIndentAndNlnIfExpressionExceedsPageWidth ( genInheritConstructor astContext ( t, e))
4223
4201
4224
4202
| MDInherit ( t, _) -> !- " inherit " +> genType astContext t
4225
4203
| MDValField f -> genField astContext " val " f
0 commit comments