Skip to content

Commit

Permalink
Fix dotnet#123 - Union types without sub-classes should be sealed
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Jan 27, 2015
1 parent 742c133 commit 8dc04ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/ilx/cu_erase.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,6 @@ let rec convClassUnionDef cenv enc td cud =
|> List.filter (fun pd -> not (cud.cudHasHelpers = SpecialFSharpListHelpers && (pd.Name = "Empty" || pd.Name = "IsEmpty" )) &&
not (cud.cudHasHelpers = SpecialFSharpOptionHelpers && (pd.Name = "Value" || pd.Name = "None")))

let casesTypeDef =
None

let enumTypeDef =
// The nested Tags type is elided if there is only one tag
// The Tag property is NOT elided if there is only one tag
Expand Down Expand Up @@ -1095,15 +1092,14 @@ let rec convClassUnionDef cenv enc td cud =

let baseTypeDef =
{ Name = td.Name;
NestedTypes = mkILTypeDefs (Option.toList casesTypeDef @

This comment has been minimized.

Copy link
@brodyberg

brodyberg Jan 28, 2015

I need to play around with the code, but while reading I was curious: could this change be achieved without removing casesTypeDef here? In other words could the fix just be the IsSealed = altTypeDefs.IsEmpty line?

This comment has been minimized.

Copy link
@dsyme

dsyme Jan 28, 2015

Author Owner

Yes, it could just be that line.

Option.toList enumTypeDef @
NestedTypes = mkILTypeDefs (Option.toList enumTypeDef @
altTypeDefs @
altDebugTypeDefs @
(convTypeDefs cenv (enc@[td]) td.NestedTypes).AsList);
GenericParams= td.GenericParams;
Access = td.Access;
IsAbstract = isAbstract;
IsSealed = false;
IsSealed = altTypeDefs.IsEmpty;
IsSerializable=td.IsSerializable;
IsComInterop=false;
Layout=td.Layout;
Expand Down
2 changes: 2 additions & 0 deletions tests/fsharp/core/array/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,8 @@ module bug872632 =

do check "bug872632" Foo.x.Length 8

do check "vwllfewlkefwl" (typedefof<list<int>>.IsSealed) true

module manyIndexes =
open System

Expand Down

1 comment on commit 8dc04ab

@brodyberg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the test to verify the type mentioned in the issue is correctly sealed, is there any chance we need to verify the other types are changed or not changed?

Please sign in to comment.