Skip to content

Removal of a unnecessary cast causes 'unintended reference comparison' warning. #57065

@CyrusNajmabadi

Description

@CyrusNajmabadi

Similar to the widened-sign-extension warning, the compiler gives a warning in this location and allows a cast to suppress it. we need to not remove the cast here:

         private static Cci.IAssemblyReference TryGetAssemblyScope(NamespaceSymbol @namespace, Emit.PEModuleBuilder moduleBuilder, DiagnosticBag diagnostics)
         {
             AssemblySymbol containingAssembly = @namespace.ContainingAssembly;
-            if ((object)containingAssembly != null && (object)containingAssembly != moduleBuilder.CommonCompilation.Assembly)
+            if ((object)containingAssembly != null && containingAssembly != moduleBuilder.CommonCompilation.Assembly)
             {
                 var referenceManager = ((CSharpCompilation)moduleBuilder.CommonCompilation).GetBoundReferenceManager();
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions