This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
forked from nosami/visualfsharp
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix generic overloads with nullable (dotnet#10582)
- Loading branch information
Showing
4 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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
35 changes: 35 additions & 0 deletions
35
tests/fsharp/Compiler/Regressions/NullableOptionalRegressionTests.fs
This file contains 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,35 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
||
namespace FSharp.Compiler.UnitTests | ||
|
||
open NUnit.Framework | ||
open FSharp.Test.Utilities.Compiler | ||
|
||
[<TestFixture()>] | ||
module NullableOptionalRegressionTests = | ||
|
||
[<Test>] | ||
let ``Should compile with generic overloaded nullable methods``() = | ||
Fsx """ | ||
open System | ||
type OverloadMeths = | ||
static member Map(m: 'T option, f) = Option.map f m | ||
static member Map(m: 'T when 'T:null, f) = m |> Option.ofObj |> Option.map f | ||
static member Map(m: 'T Nullable, f) = m |> Option.ofNullable |> Option.map f | ||
[<AllowNullLiteral>] | ||
type Node (child:Node)= | ||
new() = new Node(null) | ||
member val child:Node = child with get,set | ||
let test () = | ||
let parent = Node() | ||
let b1 = OverloadMeths.Map(parent.child, fun x -> x.child) | ||
let c1 = OverloadMeths.Map(b1, fun x -> x.child) | ||
() | ||
""" | ||
|> withLangVersion50 | ||
|> typecheck | ||
|> shouldSucceed | ||
|> ignore |
This file contains 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