-
Notifications
You must be signed in to change notification settings - Fork 858
Expand file tree
/
Copy pathOverloadResolutionErrorRangeTests.fs
More file actions
99 lines (79 loc) · 2.73 KB
/
OverloadResolutionErrorRangeTests.fs
File metadata and controls
99 lines (79 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
module ErrorMessages.OverloadResolutionErrorRangeTests
open Xunit
open FSharp.Test.Compiler
// https://github.com/dotnet/fsharp/issues/14284
[<Fact>]
let ``Issue 14284 - overload error should cover only method name, not full expression`` () =
FSharp
"""
type T() =
static member Instance = T()
member _.Method(_: double) = ()
member _.Method(_: int) = ()
T.Instance.Method("")
"""
|> typecheck
|> shouldFail
|> withDiagnostics
[ (Error 41, Line 8, Col 12, Line 8, Col 18, "No overloads match for method 'Method'.
Known type of argument: string
Available overloads:
- member T.Method: double -> unit // Argument at index 1 doesn't match
- member T.Method: int -> unit // Argument at index 1 doesn't match") ]
// Verify that the error range is narrow also for simple direct method calls
[<Fact>]
let ``Issue 14284 - overload error for simple static method`` () =
FSharp
"""
type T() =
static member Method(_: double) = ()
static member Method(_: int) = ()
T.Method("")
"""
|> typecheck
|> shouldFail
|> withDiagnostics
[ (Error 41, Line 6, Col 3, Line 6, Col 9, "No overloads match for method 'Method'.
Known type of argument: string
Available overloads:
- static member T.Method: double -> unit // Argument at index 1 doesn't match
- static member T.Method: int -> unit // Argument at index 1 doesn't match") ]
// Verify that a long expression before the method doesn't widen the error range
[<Fact>]
let ``Issue 14284 - overload error on chained expression`` () =
FSharp
"""
type T() =
static member Instance = T()
member _.Next = T()
member _.Method(_: double) = ()
member _.Method(_: int) = ()
T.Instance.Next.Next.Method("")
"""
|> typecheck
|> shouldFail
|> withDiagnostics
[ (Error 41, Line 9, Col 22, Line 9, Col 28, "No overloads match for method 'Method'.
Known type of argument: string
Available overloads:
- member T.Method: double -> unit // Argument at index 1 doesn't match
- member T.Method: int -> unit // Argument at index 1 doesn't match") ]
// Verify error range with lambda argument
[<Fact>]
let ``Issue 14284 - overload error with lambda argument`` () =
FSharp
"""
type T() =
static member Instance = T()
member _.Method(_: double) = ()
member _.Method(_: int) = ()
T.Instance.Method(fun () -> "")
"""
|> typecheck
|> shouldFail
|> withDiagnostics
[ (Error 41, Line 8, Col 12, Line 8, Col 18, "No overloads match for method 'Method'.
Known type of argument: (unit -> string)
Available overloads:
- member T.Method: double -> unit // Argument at index 1 doesn't match
- member T.Method: int -> unit // Argument at index 1 doesn't match") ]