-
Notifications
You must be signed in to change notification settings - Fork 853
Expand file tree
/
Copy pathAttributeResolutionInRecursiveScopes.fs
More file actions
142 lines (115 loc) · 3.17 KB
/
AttributeResolutionInRecursiveScopes.fs
File metadata and controls
142 lines (115 loc) · 3.17 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace Conformance.BasicGrammarElements
open Xunit
open FSharp.Test.Compiler
module AttributeResolutionInRecursiveScopes =
// https://github.com/dotnet/fsharp/issues/7931
[<Fact>]
let ``Extension attribute on module in namespace rec`` () =
FSharp """
namespace rec Ns
open System.Runtime.CompilerServices
[<Extension>]
module Module =
[<Extension>]
let ext1 (x: int) = x.ToString()
"""
|> asLibrary
|> typecheck
|> shouldSucceed
// https://github.com/dotnet/fsharp/issues/7931
[<Fact>]
let ``Extension attribute on type in namespace rec`` () =
FSharp """
namespace rec Ns
open System.Runtime.CompilerServices
[<Extension>]
type T() =
class end
"""
|> asLibrary
|> typecheck
|> shouldSucceed
// https://github.com/dotnet/fsharp/issues/5795 - Custom attribute used on type and let in rec module
[<Fact>]
let ``Custom attribute used on type and let in rec module`` () =
FSharp """
module rec M
type CustomAttribute() =
inherit System.Attribute()
[<Custom>] type A = | A
[<Custom>] let a = ()
"""
|> typecheck
|> shouldSucceed
// Nested module case: open inside outer module, attribute on inner module
[<Fact>]
let ``Open inside nested module resolves for attribute on inner module in namespace rec`` () =
FSharp """
namespace rec Ns
module Outer =
open System.Runtime.CompilerServices
[<Extension>]
module Inner =
[<Extension>]
let ext1 (x: int) = x.ToString()
"""
|> asLibrary
|> typecheck
|> shouldSucceed
// Non-recursive baseline: should always work
[<Fact>]
let ``Extension attribute works without rec - baseline`` () =
FSharp """
namespace Ns
open System.Runtime.CompilerServices
[<Extension>]
module Module =
[<Extension>]
let ext1 (x: int) = x.ToString()
"""
|> asLibrary
|> typecheck
|> shouldSucceed
// Multiple opens in namespace rec
[<Fact>]
let ``Multiple opens resolve for attributes in namespace rec`` () =
FSharp """
namespace rec Ns
open System
open System.Runtime.CompilerServices
[<Extension>]
module Module =
[<Extension>]
[<Obsolete("test")>]
let ext1 (x: int) = x.ToString()
"""
|> asLibrary
|> typecheck
|> shouldSucceed
// Open in module rec resolves for module attributes
[<Fact>]
let ``Open in module rec resolves for nested module attribute`` () =
FSharp """
module rec M
open System.Runtime.CompilerServices
[<Extension>]
module Inner =
[<Extension>]
let ext1 (x: int) = x.ToString()
"""
|> typecheck
|> shouldSucceed
// Open with Obsolete attribute in namespace rec
[<Fact>]
let ``Obsolete attribute resolves via open in namespace rec`` () =
FSharp """
namespace rec Ns
open System
[<Obsolete("deprecated")>]
module DeprecatedModule =
let x = 42
"""
|> asLibrary
|> typecheck
|> shouldSucceed