@@ -849,10 +849,18 @@ private void checkForClassFilesChangesInModule(DevModeContext.ModuleInfo module,
849
849
.collect (Collectors .toSet ());
850
850
851
851
for (Path classFilePath : classFilePaths ) {
852
- final Path sourceFilePath = retrieveSourceFilePathForClassFile (classFilePath , moduleChangedSourceFiles ,
853
- module , cuf , timestampSet );
854
-
852
+ Path sourceFilePath = retrieveSourceFilePathForClassFile (classFilePath , moduleChangedSourceFiles ,
853
+ module , cuf , timestampSet , false );
855
854
if (sourceFilePath != null ) {
855
+ if (!sourceFilePath .toFile ().exists ()) {
856
+ // We need to refresh this in case the source file has changed
857
+ // This can happen if you rename a kotlin file, the same class will now be provided by a new file
858
+ var updated = retrieveSourceFilePathForClassFile (classFilePath , moduleChangedSourceFiles ,
859
+ module , cuf , timestampSet , true );
860
+ if (updated != null ) {
861
+ sourceFilePath = updated ;
862
+ }
863
+ }
856
864
if (!sourceFilePath .toFile ().exists ()) {
857
865
// Source file has been deleted. Delete class and restart
858
866
cleanUpClassFile (classFilePath , timestampSet );
@@ -888,9 +896,9 @@ private void checkForClassFilesChangesInModule(DevModeContext.ModuleInfo module,
888
896
889
897
private Path retrieveSourceFilePathForClassFile (Path classFilePath , List <Path > moduleChangedSourceFiles ,
890
898
DevModeContext .ModuleInfo module , Function <DevModeContext .ModuleInfo , DevModeContext .CompilationUnit > cuf ,
891
- TimestampSet timestampSet ) {
899
+ TimestampSet timestampSet , boolean forceRefresh ) {
892
900
Path sourceFilePath = timestampSet .classFilePathToSourceFilePath .get (classFilePath );
893
- if (sourceFilePath == null || moduleChangedSourceFiles .contains (sourceFilePath )) {
901
+ if (sourceFilePath == null || moduleChangedSourceFiles .contains (sourceFilePath ) || forceRefresh ) {
894
902
sourceFilePath = compiler .findSourcePath (classFilePath , cuf .apply (module ).getSourcePaths (),
895
903
cuf .apply (module ).getClassesPath ());
896
904
}
0 commit comments