-
Notifications
You must be signed in to change notification settings - Fork 852
Enhance the NameResolution System #19536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
evgTSV
wants to merge
13
commits into
dotnet:main
Choose a base branch
from
evgTSV:fix-overloads-checking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
682384b
[NameResolution] Fix accessibility and type-matching for pattern-base…
evgTSV b2e38f0
Add tests
evgTSV 170baf1
Add the entry in the changeloh
evgTSV a4d3388
Fix module name
evgTSV f37ce5b
Apply access/type-eq filter to only unindexed extension members
evgTSV de7eed2
Merge branch 'main' into fix-overloads-checking
evgTSV 137dbf5
Turn off types eq check
evgTSV bec8732
Turn on fixed types eq check
evgTSV 76e285a
Replace hard type eq check with type subsumes check
evgTSV 57a193b
Turn off the strict filter for the FSharp.Core compilation stage
evgTSV 5d0d1b1
Skip the filter for non CSharpStyle extension members
evgTSV 9c6dc65
Move the filter to CE pipeline
evgTSV 0a74bdb
Create the function to check the 'this' arg in extension methods; Add…
evgTSV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...onentTests/Conformance/BasicGrammarElements/UseBindings/UseBindingsAndExtensionMembers.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| module Conformance.BasicGrammarElements.UseBindExtensionMethodCapture | ||
|
|
||
| open Xunit | ||
| open FSharp.Test.Compiler | ||
|
|
||
| [<Fact>] | ||
| let ``Use binding doesn't capture an extension method with generic type``() = | ||
| FSharp """ | ||
| open System | ||
| open System.Runtime.CompilerServices | ||
|
|
||
| type FooClass() = class end | ||
|
|
||
| type Disposable() = | ||
| interface IDisposable with | ||
| member _.Dispose() = () | ||
|
|
||
| [<Extension>] | ||
| type PublicExtensions = | ||
| [<Extension>] | ||
| static member inline Dispose(this: #FooClass) = | ||
| this | ||
|
|
||
| let foo() = | ||
| use a = new Disposable() | ||
| () | ||
|
|
||
| foo() | ||
| """ | ||
| |> asExe | ||
| |> compile | ||
| |> shouldSucceed |
136 changes: 136 additions & 0 deletions
136
...ComponentTests/Conformance/Expressions/ComputationExpressions/CEExtensionMethodCapture.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| module Conformance.Expressions.CEExtensionMethodCapture | ||
|
|
||
| open Xunit | ||
| open FSharp.Test.Compiler | ||
|
|
||
| [<Fact>] | ||
| let ``CE doesn't capture an extension method beyond the access domain``() = | ||
| FSharp """ | ||
| open System.Runtime.CompilerServices | ||
|
|
||
| type AsyncSeq<'T>(i: 'T) = | ||
| class | ||
| let l = [i] | ||
| member this.Data = l | ||
| end | ||
|
|
||
| type AsyncSeqBuilder() = | ||
| member _.Yield(x: 'T) : AsyncSeq<'T> = | ||
| AsyncSeq(x) | ||
|
|
||
| [<Extension>] | ||
| type PrivateExtensions = | ||
| [<Extension>] | ||
| static member inline private Run(this: AsyncSeqBuilder) = | ||
| this | ||
|
|
||
| let asyncSeq = AsyncSeqBuilder() | ||
|
|
||
| let xs : AsyncSeq<int> = | ||
| asyncSeq { | ||
| yield 1 | ||
| } | ||
| """ | ||
| |> asExe | ||
| |> compile | ||
| |> shouldSucceed | ||
|
|
||
| [<Fact>] | ||
| let ``CE doesn't capture an extension method with generic type``() = | ||
| FSharp """ | ||
| open System.Runtime.CompilerServices | ||
|
|
||
| type FooClass = class end | ||
|
|
||
| type AsyncSeq<'T>(i: 'T) = | ||
| class | ||
| let l = [i] | ||
| member this.Data = l | ||
| end | ||
|
|
||
| type AsyncSeqBuilder() = | ||
| member _.Yield(x: 'T) : AsyncSeq<'T> = | ||
| AsyncSeq(x) | ||
|
|
||
| [<Extension>] | ||
| type PublicExtensions = | ||
| [<Extension>] | ||
| static member inline Run(this: #FooClass) = | ||
| this | ||
|
|
||
| let asyncSeq = AsyncSeqBuilder() | ||
|
|
||
| let xs : AsyncSeq<int> = | ||
| asyncSeq { | ||
| yield 1 | ||
| } | ||
| """ | ||
| |> asExe | ||
| |> compile | ||
| |> shouldSucceed | ||
|
|
||
| // Deliberately trigger an error to ensure that a method is captured | ||
| [<Fact>] | ||
| let ``CE captures a public extension method and procudes an error due to invalid args``() = | ||
| FSharp """ | ||
| open System.Runtime.CompilerServices | ||
|
|
||
| type AsyncSeq<'T>(i: 'T) = | ||
| class | ||
| let l = [i] | ||
| member this.Data = l | ||
| end | ||
|
|
||
| type AsyncSeqBuilder() = | ||
| member _.Yield(x: 'T) : AsyncSeq<'T> = | ||
| AsyncSeq(x) | ||
|
|
||
| [<Extension>] | ||
| type PublicExtensions = | ||
| [<Extension>] | ||
| static member inline Run(this: AsyncSeqBuilder, invalidArg: string) = | ||
| this | ||
|
|
||
| let asyncSeq = AsyncSeqBuilder() | ||
|
|
||
| let xs : AsyncSeq<int> = | ||
| asyncSeq { | ||
| yield 1 | ||
| } | ||
| """ | ||
| |> asExe | ||
| |> compile | ||
| |> shouldFail | ||
|
|
||
| // Deliberately trigger an error to ensure that a method is captured | ||
| [<Fact>] | ||
| let ``CE captures a public extension method with valid generic constrainted type and procudes an error due to invalid args``() = | ||
| FSharp """ | ||
| open System.Runtime.CompilerServices | ||
|
|
||
| type AsyncSeq<'T>(i: 'T) = | ||
| class | ||
| let l = [i] | ||
| member this.Data = l | ||
| end | ||
|
|
||
| type AsyncSeqBuilder() = | ||
| member _.Yield(x: 'T) : AsyncSeq<'T> = | ||
| AsyncSeq(x) | ||
|
|
||
| [<Extension>] | ||
| type PublicExtensions = | ||
| [<Extension>] | ||
| static member inline Run(this: #AsyncSeqBuilder, invalidArg: string) = | ||
| this | ||
|
|
||
| let asyncSeq = AsyncSeqBuilder() | ||
|
|
||
| let xs : AsyncSeq<int> = | ||
| asyncSeq { | ||
| yield 1 | ||
| } | ||
| """ | ||
| |> asExe | ||
| |> compile | ||
| |> shouldFail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering how is it already done in other cases? Is there a place that this function could be unified with?