diff --git a/Directory.Build.props b/Directory.Build.props index d00d268a9ea..424258eef47 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,7 +38,7 @@ --> $(OtherFlags) --realsig- - $(OtherFlags) --realsig- + $(OtherFlags) --realsig+ diff --git a/src/Compiler/Checking/AugmentWithHashCompare.fs b/src/Compiler/Checking/AugmentWithHashCompare.fs index f34c447f257..4326ac6ccfc 100644 --- a/src/Compiler/Checking/AugmentWithHashCompare.fs +++ b/src/Compiler/Checking/AugmentWithHashCompare.fs @@ -1347,7 +1347,10 @@ let MakeValsForEqualsAugmentation g (tcref: TyconRef) = let MakeValsForEqualityWithComparerAugmentation g (tcref: TyconRef) = let _, ty = mkMinimalTy g tcref - let vis = tcref.TypeReprAccessibility + let vis = + // Equality method for union types match the union type visibility rather than the TypeReprAccessibility + if tcref.IsUnionTycon then tcref.Accessibility + else tcref.TypeReprAccessibility let tps = tcref.Typars tcref.Range let objGetHashCodeVal = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/CCtorDUWithMember/CCtorDUWithMember.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/CCtorDUWithMember/CCtorDUWithMember.fs index 99c31471aba..248532a1638 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/CCtorDUWithMember/CCtorDUWithMember.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/CCtorDUWithMember/CCtorDUWithMember.fs @@ -80,3 +80,69 @@ module CCtorDUWithMember = |> asFs |> withAdditionalSourceFile (SourceFromPath (__SOURCE_DIRECTORY__ ++ "CCtorDUWithMember04.fs")) |> verifyCompilation + + let withRealInternalSignature realSig compilation = + compilation + |> withOptions [if realSig then "--realsig+" else "--realsig-" ] + + [] // RealSig + [] // Regular + [] + let ``public - DU internal case specified in fsi file`` (realSig) = + Fsi """ +namespace RealInternalSignature + +[] +type ILArrayShape = + internal + | One +""" + |> withAdditionalSourceFile (FsSource (""" +namespace RealInternalSignature + +[] +type ILArrayShape = + | One + """)) + |> asLibrary + |> withLangVersionPreview + |> withRealInternalSignature realSig + |> compile + |> withILContains [ + """ + .method public hidebysig instance bool + Equals(class RealInternalSignature.ILArrayShape obj, + class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) +""" + ] + |> shouldSucceed + + [] // RealSig + [] // Regular + [] + let ``public - DU internal case specified in fs file`` (realSig) = + FSharp """ +namespace RealInternalSignature + +[] +type ILArrayShape = + internal + | One +""" + |> asLibrary + |> withLangVersionPreview + |> withRealInternalSignature realSig + |> compile + |> withILContains [ + """ + .method public hidebysig instance bool + Equals(class RealInternalSignature.ILArrayShape obj, + class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) +""" + ] + |> shouldSucceed + diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index b37d8e1b528..909e42e2cdc 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -51,6 +51,7 @@ FSharp.Compiler.AbstractIL.IL+ILArgConvention: Int32 Tag FSharp.Compiler.AbstractIL.IL+ILArgConvention: Int32 get_Tag() FSharp.Compiler.AbstractIL.IL+ILArgConvention: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(ILArrayShape) +FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(ILArrayShape, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILArrayShape: ILArrayShape FromRank(Int32) @@ -65,6 +66,7 @@ FSharp.Compiler.AbstractIL.IL+ILArrayShape: Int32 Rank FSharp.Compiler.AbstractIL.IL+ILArrayShape: Int32 get_Rank() FSharp.Compiler.AbstractIL.IL+ILArrayShape: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(ILAssemblyLongevity) +FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(ILAssemblyLongevity, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: ILAssemblyLongevity Default @@ -950,6 +952,7 @@ FSharp.Compiler.AbstractIL.IL+ILModuleRef: System.String Name FSharp.Compiler.AbstractIL.IL+ILModuleRef: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILModuleRef: System.String get_Name() FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(ILNativeResource) +FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(ILNativeResource, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILNativeResource: Int32 CompareTo(ILNativeResource) @@ -1224,6 +1227,7 @@ FSharp.Compiler.AbstractIL.IL+ILParameter: Microsoft.FSharp.Core.FSharpOption`1[ FSharp.Compiler.AbstractIL.IL+ILParameter: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILParameter: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[System.String], ILType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldInit], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILNativeType], Boolean, Boolean, Boolean, ILAttributesStored, Int32) FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(ILPlatform) +FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(ILPlatform, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILPlatform: Int32 CompareTo(ILPlatform) @@ -2286,6 +2290,7 @@ FSharp.Compiler.CodeAnalysis.FSharpSymbolUse: System.String FileName FSharp.Compiler.CodeAnalysis.FSharpSymbolUse: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpSymbolUse: System.String get_FileName() FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet) +FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet, System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(System.Object) FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Int32 GetHashCode() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index b37d8e1b528..909e42e2cdc 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -51,6 +51,7 @@ FSharp.Compiler.AbstractIL.IL+ILArgConvention: Int32 Tag FSharp.Compiler.AbstractIL.IL+ILArgConvention: Int32 get_Tag() FSharp.Compiler.AbstractIL.IL+ILArgConvention: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(ILArrayShape) +FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(ILArrayShape, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILArrayShape: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILArrayShape: ILArrayShape FromRank(Int32) @@ -65,6 +66,7 @@ FSharp.Compiler.AbstractIL.IL+ILArrayShape: Int32 Rank FSharp.Compiler.AbstractIL.IL+ILArrayShape: Int32 get_Rank() FSharp.Compiler.AbstractIL.IL+ILArrayShape: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(ILAssemblyLongevity) +FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(ILAssemblyLongevity, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILAssemblyLongevity: ILAssemblyLongevity Default @@ -950,6 +952,7 @@ FSharp.Compiler.AbstractIL.IL+ILModuleRef: System.String Name FSharp.Compiler.AbstractIL.IL+ILModuleRef: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILModuleRef: System.String get_Name() FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(ILNativeResource) +FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(ILNativeResource, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILNativeResource: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILNativeResource: Int32 CompareTo(ILNativeResource) @@ -1224,6 +1227,7 @@ FSharp.Compiler.AbstractIL.IL+ILParameter: Microsoft.FSharp.Core.FSharpOption`1[ FSharp.Compiler.AbstractIL.IL+ILParameter: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILParameter: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[System.String], ILType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldInit], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILNativeType], Boolean, Boolean, Boolean, ILAttributesStored, Int32) FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(ILPlatform) +FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(ILPlatform, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(System.Object) FSharp.Compiler.AbstractIL.IL+ILPlatform: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILPlatform: Int32 CompareTo(ILPlatform) @@ -2286,6 +2290,7 @@ FSharp.Compiler.CodeAnalysis.FSharpSymbolUse: System.String FileName FSharp.Compiler.CodeAnalysis.FSharpSymbolUse: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpSymbolUse: System.String get_FileName() FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet) +FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet, System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(System.Object) FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet: Int32 GetHashCode() diff --git a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.fs b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.fs index 2e09e6cc65d..85ac86b3f33 100644 --- a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.fs +++ b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.fs @@ -35,9 +35,4 @@ type SurfaceAreaTest() = let baseline = Path.Combine(__SOURCE_DIRECTORY__, $"FSharp.Compiler.Service.SurfaceArea.{platform}.{flavor}.bsl") let outFileName = $"FSharp.Compiler.Service.SurfaceArea.{platform}.{flavor}.out" - - let realSig = Environment.GetEnvironmentVariable("FSHARP_REALSIG") - match realSig with - | "false" -> Assert.True(true, "Skipping the test, the surface area without real sig differs and doesn't matter.") - | _ -> FSharp.Test.SurfaceArea.verify assembly baseline outFileName - + FSharp.Test.SurfaceArea.verify assembly baseline outFileName