@@ -115,6 +115,22 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
115115 await NameUtils . RenameAllAsync ( ctx , logger , handleTypes . Select ( t => ( ( ISymbol ) t , $ "{ t . Name } Handle") ) , ct ) ;
116116 project = ctx . SourceProject ;
117117
118+ // Get the compilation again
119+ compilation = await project . GetCompilationAsync ( ct ) ;
120+ if ( compilation == null )
121+ {
122+ throw new InvalidOperationException ( "Failed to get compilation" ) ;
123+ }
124+
125+ // Restore symbols invalidated by previous modification
126+ handleTypes = handleTypeMetadataNames . SelectMany ( name => compilation . GetTypesByMetadataName ( name ) ) . ToList ( ) ;
127+
128+ // Reduce pointer dimensions
129+ ctx . SourceProject = project ;
130+ await LocationTransformationUtils . ModifyAllReferencesAsync ( ctx , logger , handleTypes ,
131+ [ new PointerDimensionReductionTransformer ( ) ] , ct ) ;
132+ project = ctx . SourceProject ;
133+
118134 // Use document IDs from earlier
119135 var handleTypeRewriter = new HandleTypeRewriter ( cfg . UseDSL ) ;
120136 foreach ( var ( originalName , documentId ) in handleTypeDocumentIds )
@@ -141,23 +157,6 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
141157 project = document . Project ;
142158 }
143159
144- // Phase 3. Reduce pointer dimensions
145- // Get the compilation again
146- compilation = await project . GetCompilationAsync ( ct ) ;
147- if ( compilation == null )
148- {
149- throw new InvalidOperationException ( "Failed to get compilation" ) ;
150- }
151-
152- // Restore symbols
153- handleTypes = handleTypeMetadataNames . SelectMany ( name => compilation . GetTypesByMetadataName ( name ) ) . ToList ( ) ;
154-
155- // Reduce pointer dimensions
156- ctx . SourceProject = project ;
157- await LocationTransformationUtils . ModifyAllReferencesAsync ( ctx , logger , handleTypes ,
158- [ new PointerDimensionReductionTransformer ( ) ] , ct ) ;
159- project = ctx . SourceProject ;
160-
161160 // At the time of writing this comment, this line effectively does nothing
162161 // However, if the code above is removed, then this line ensures that the context's project is updated properly
163162 ctx . SourceProject = project ;
0 commit comments