@@ -54,24 +54,29 @@ function genericPrint(path, options, print) {
5454 ] ) ;
5555 }
5656 return concat ( [ 'import ' , doc , ';' ] ) ;
57- case 'ContractDefinition' :
58- doc = concat ( [ node . kind , ' ' , node . name ] ) ;
57+ case 'ContractDefinition' : {
58+ let parts = [ node . kind , ' ' , node . name ] ;
59+
5960 if ( node . baseContracts . length > 0 ) {
60- doc = concat ( [
61- doc ,
61+ parts = parts . concat ( [
6262 ' is ' ,
6363 join ( ', ' , path . map ( print , 'baseContracts' ) )
6464 ] ) ;
6565 }
66- return concat ( [
67- doc ,
68- ' {' ,
69- indent ( line ) ,
70- indent ( printPreservingEmptyLines ( path , 'subNodes' , options , print ) ) ,
71- line ,
72- '}' ,
73- line
74- ] ) ;
66+
67+ parts . push ( ' {' ) ;
68+ if ( node . subNodes . length > 0 ) {
69+ parts = parts . concat ( [
70+ indent ( line ) ,
71+ indent ( printPreservingEmptyLines ( path , 'subNodes' , options , print ) ) ,
72+ line
73+ ] ) ;
74+ }
75+ parts . push ( '}' ) ;
76+ parts . push ( line ) ;
77+
78+ return concat ( parts ) ;
79+ }
7580 case 'InheritanceSpecifier' : {
7681 let parts = [ path . call ( print , 'baseName' ) ] ;
7782
@@ -159,6 +164,11 @@ function genericPrint(path, options, print) {
159164 }
160165 return doc ;
161166 case 'Block' : {
167+ // if block is empty, just return the pair of braces
168+ if ( node . statements . length === 0 && ! node . comments ) {
169+ return '{}' ;
170+ }
171+
162172 const parts = [
163173 '{' ,
164174 indent ( line ) ,
0 commit comments