Skip to content

Conversation

@TIHan
Copy link
Contributor

@TIHan TIHan commented Aug 15, 2019

This places the open static classes in preview to allow some bake time for the feature and make sure we cover all design scenarios.

This also fixes the ability for multiple open static classes that have the same method name to be overloads of each other. Resolving this issue: #7400

@cartermp has a design in his head and so he will update the open static classes RFC. So, we will continue to update the design there.

@cartermp
Copy link
Contributor

@cartermp

This comment has been minimized.

(minfosNew, minfosCurrent)
||> List.fold (fun minfos minfo1 ->
// Shadow methods with the same signature.
if minfos |> List.exists (fun minfo2 -> MethInfosEquivByNameAndSig Erasure.EraseAll true g amap m minfo1 minfo2) then
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks quadratic in the number of method overloads? I suspect it's hard to escape that without massively over-complicating the code though. Other things in the compiler are also quadratic (though I think it's less common to be quadratic when consuming a construct.)

Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider whether we should be using EraseAll here - e.g. should units of measure be significant when determining whether one overload shadows another? EraseAll means they are not. I think they should be significant - because the only reason we erase UoM when forbidding identical method signatures is that .NET IL doesn't permit two identical method signatures within the same class. But it does allow them across different classes.

Either way we will definitely need test cases for this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I can make a slight tweak to the overloads complexity; I notice I keep searching on the list that keeps getting additions which isn't necessary.

In regards to EraseAll. Because you cannot do overloading with UoM normally in classes, should we now allow it in this case? I was worried about consistency. But, it would be extremely powerful to allow it. I'll set it back to EraseNone; it should be pretty interesting to see overloading with UoM. I can imagine reasonable use cases where it would be helpful. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a tricky choice - each way sort of seems wrong. Could you try the switch and explore some test cases?

Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

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

Good work - I left some comments

(minfosNew, minfosCurrent)
||> List.fold (fun minfos minfo1 ->
// Shadow methods with the same signature.
if minfos |> List.exists (fun minfo2 -> MethInfosEquivByNameAndSig Erasure.EraseAll true g amap m minfo1 minfo2) then
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider whether we should be using EraseAll here - e.g. should units of measure be significant when determining whether one overload shadows another? EraseAll means they are not. I think they should be significant - because the only reason we erase UoM when forbidding identical method signatures is that .NET IL doesn't permit two identical method signatures within the same class. But it does allow them across different classes.

Either way we will definitely need test cases for this case

x.Add(k, Item.MethodGroup (k, minfos, None))

// Methods will hide properties, events, and fields with the same name.
| Item.MethodGroup _, Item.Property _
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine, will need test cases and RFC update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, for sure. This is to mimic opening multiple static classes in C# and what their behavior is.

@TIHan TIHan changed the title Open static classes is now preview. Added fix for overloads Open static classes changes Aug 16, 2019
@TIHan TIHan changed the title Open static classes changes Open Static Classes - Updates Aug 16, 2019

let getMethItems () =
[ let methGroups =
AllMethInfosOfTypeInScope ResultCollectionSettings.AllResults infoReader nenv None AccessorDomain.AccessibleFromSomeFSharpCode PreferOverrides m ty
Copy link
Contributor

Choose a reason for hiding this comment

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

need to pass ad here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops

@cartermp cartermp changed the base branch from release/dev16.3 to master May 5, 2020 21:02
@dsyme
Copy link
Contributor

dsyme commented Jun 18, 2020

@TIHan I've forgotten exactly what's in this branch but we recorded these items today

  1. open C --> open type C
  2. allow open on non-static
  3. reveal nested type when opening a static type

@dsyme
Copy link
Contributor

dsyme commented Jun 18, 2020

This also fixes the ability for multiple open static classes that have the same method name to be overloads of each other. Resolving this issue: #7400

OK this part would have to be undone per our design discussion today

@TIHan
Copy link
Contributor Author

TIHan commented Jun 20, 2020

Closing in favor of this: #9513

@TIHan TIHan closed this Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants