Skip to content

Commit 74eab9f

Browse files
committed
Fix the moving of free functions to classes to match by module too
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 05c70ea commit 74eab9f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Generator/Passes/MoveFunctionToClassPass.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ private Class FindClassToMoveFunctionTo(Function function)
6565
}
6666
else
6767
{
68-
var unit = function.Namespace as TranslationUnit;
69-
@class = unit == null
70-
? ASTContext.FindClass(
71-
function.Namespace.Name, ignoreCase: true).FirstOrDefault()
72-
: ASTContext.FindCompleteClass(
73-
unit.FileNameWithoutExtension.ToLowerInvariant(), true);
68+
string name = (function.Namespace as TranslationUnit)?.FileNameWithoutExtension ??
69+
function.Namespace.Name;
70+
@class = ASTContext.FindClass(
71+
name, ignoreCase: true).FirstOrDefault(
72+
c => c.TranslationUnit.Module == function.TranslationUnit.Module &&
73+
!c.IsIncomplete);
7474
}
7575

7676
return @class;

0 commit comments

Comments
 (0)