Skip to content

Commit 371b7e9

Browse files
Add attribute shadowing test
1 parent 9fcae18 commit 371b7e9

File tree

3 files changed

+268
-0
lines changed

3 files changed

+268
-0
lines changed

tests/FSharp.Compiler.ComponentTests/EmittedIL/Spreads/RecordTypeSpreads.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ let Type_SpreadShadowsExplicit_fs compilation =
6363
compilation
6464
|> getCompilation
6565
|> verifyCompilation
66+
67+
[<Theory; FileInlineData("Type_AttributesAreShadowed.fs", Realsig = BooleanOptions.True, Optimize = BooleanOptions.True)>]
68+
let Type_Type_AttributesAreShadowed_fs compilation =
69+
compilation
70+
|> getCompilation
71+
|> verifyCompilation
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Attr1Attribute () = inherit System.Attribute ()
2+
type Attr2Attribute () = inherit System.Attribute ()
3+
4+
[<NoEquality; NoComparison; DefaultAugmentation(false)>]
5+
type R1 = { [<Attr1>] A : int; [<Attr1>] B : int }
6+
[<NoEquality; NoComparison; DefaultAugmentation(false)>]
7+
type R2 = { ...R1; [<Attr2>] A : string }
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
2+
3+
4+
5+
6+
.assembly extern runtime { }
7+
.assembly extern FSharp.Core { }
8+
.assembly assembly
9+
{
10+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32,
11+
int32,
12+
int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )
13+
14+
15+
16+
17+
.hash algorithm 0x00008004
18+
.ver 0:0:0:0
19+
}
20+
.module assembly.exe
21+
22+
.imagebase {value}
23+
.file alignment 0x00000200
24+
.stackreserve 0x00100000
25+
.subsystem 0x0003
26+
.corflags 0x00000001
27+
28+
29+
30+
31+
32+
.class public abstract auto ansi sealed assembly
33+
extends [runtime]System.Object
34+
{
35+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 )
36+
.class auto ansi serializable nested public Attr1Attribute
37+
extends [runtime]System.Attribute
38+
{
39+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 )
40+
.method public specialname rtspecialname instance void .ctor() cil managed
41+
{
42+
43+
.maxstack 8
44+
IL_0000: ldarg.0
45+
IL_0001: callvirt instance void [runtime]System.Attribute::.ctor()
46+
IL_0006: ldarg.0
47+
IL_0007: pop
48+
IL_0008: ret
49+
}
50+
51+
}
52+
53+
.class auto ansi serializable nested public Attr2Attribute
54+
extends [runtime]System.Attribute
55+
{
56+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 )
57+
.method public specialname rtspecialname instance void .ctor() cil managed
58+
{
59+
60+
.maxstack 8
61+
IL_0000: ldarg.0
62+
IL_0001: callvirt instance void [runtime]System.Attribute::.ctor()
63+
IL_0006: ldarg.0
64+
IL_0007: pop
65+
IL_0008: ret
66+
}
67+
68+
}
69+
70+
.class auto ansi serializable sealed nested public R1
71+
extends [runtime]System.Object
72+
{
73+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 )
74+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 )
75+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.DefaultAugmentationAttribute::.ctor(bool) = ( 01 00 00 00 00 )
76+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 )
77+
.field assembly int32 A@
78+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
79+
.custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
80+
.field assembly int32 B@
81+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
82+
.custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
83+
.method public hidebysig specialname instance int32 get_A() cil managed
84+
{
85+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
86+
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
87+
88+
.maxstack 8
89+
IL_0000: ldarg.0
90+
IL_0001: ldfld int32 assembly/R1::A@
91+
IL_0006: ret
92+
}
93+
94+
.method public hidebysig specialname instance int32 get_B() cil managed
95+
{
96+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
97+
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
98+
99+
.maxstack 8
100+
IL_0000: ldarg.0
101+
IL_0001: ldfld int32 assembly/R1::B@
102+
IL_0006: ret
103+
}
104+
105+
.method public specialname rtspecialname instance void .ctor(int32 a, int32 b) cil managed
106+
{
107+
.custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
108+
class [runtime]System.Type) = ( 01 00 60 06 00 00 1D 54 79 70 65 5F 41 74 74 72
109+
69 62 75 74 65 73 41 72 65 53 68 61 64 6F 77 65
110+
64 2B 52 31 00 00 )
111+
112+
.maxstack 8
113+
IL_0000: ldarg.0
114+
IL_0001: call instance void [runtime]System.Object::.ctor()
115+
IL_0006: ldarg.0
116+
IL_0007: ldarg.1
117+
IL_0008: stfld int32 assembly/R1::A@
118+
IL_000d: ldarg.0
119+
IL_000e: ldarg.2
120+
IL_000f: stfld int32 assembly/R1::B@
121+
IL_0014: ret
122+
}
123+
124+
.method public strict virtual instance string ToString() cil managed
125+
{
126+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
127+
128+
.maxstack 8
129+
IL_0000: ldstr "%+A"
130+
IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class assembly/R1,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class assembly/R1>::.ctor(string)
131+
IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class assembly/R1,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string>)
132+
IL_000f: ldarg.0
133+
IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class assembly/R1,string>::Invoke(!0)
134+
IL_0015: ret
135+
}
136+
137+
.property instance int32 A()
138+
{
139+
.custom instance void assembly/Attr1Attribute::.ctor() = ( 01 00 00 00 )
140+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags,
141+
int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 )
142+
.get instance int32 assembly/R1::get_A()
143+
}
144+
.property instance int32 B()
145+
{
146+
.custom instance void assembly/Attr1Attribute::.ctor() = ( 01 00 00 00 )
147+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags,
148+
int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 )
149+
.get instance int32 assembly/R1::get_B()
150+
}
151+
}
152+
153+
.class auto ansi serializable sealed nested public R2
154+
extends [runtime]System.Object
155+
{
156+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 )
157+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 )
158+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.DefaultAugmentationAttribute::.ctor(bool) = ( 01 00 00 00 00 )
159+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 )
160+
.field assembly int32 B@
161+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
162+
.custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
163+
.field assembly string A@
164+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
165+
.custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
166+
.method public hidebysig specialname instance int32 get_B() cil managed
167+
{
168+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
169+
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
170+
171+
.maxstack 8
172+
IL_0000: ldarg.0
173+
IL_0001: ldfld int32 assembly/R2::B@
174+
IL_0006: ret
175+
}
176+
177+
.method public hidebysig specialname instance string get_A() cil managed
178+
{
179+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
180+
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
181+
182+
.maxstack 8
183+
IL_0000: ldarg.0
184+
IL_0001: ldfld string assembly/R2::A@
185+
IL_0006: ret
186+
}
187+
188+
.method public specialname rtspecialname instance void .ctor(int32 b, string a) cil managed
189+
{
190+
.custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
191+
class [runtime]System.Type) = ( 01 00 60 06 00 00 1D 54 79 70 65 5F 41 74 74 72
192+
69 62 75 74 65 73 41 72 65 53 68 61 64 6F 77 65
193+
64 2B 52 32 00 00 )
194+
195+
.maxstack 8
196+
IL_0000: ldarg.0
197+
IL_0001: call instance void [runtime]System.Object::.ctor()
198+
IL_0006: ldarg.0
199+
IL_0007: ldarg.1
200+
IL_0008: stfld int32 assembly/R2::B@
201+
IL_000d: ldarg.0
202+
IL_000e: ldarg.2
203+
IL_000f: stfld string assembly/R2::A@
204+
IL_0014: ret
205+
}
206+
207+
.method public strict virtual instance string ToString() cil managed
208+
{
209+
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
210+
211+
.maxstack 8
212+
IL_0000: ldstr "%+A"
213+
IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class assembly/R2,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class assembly/R2>::.ctor(string)
214+
IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class assembly/R2,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string>)
215+
IL_000f: ldarg.0
216+
IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<class assembly/R2,string>::Invoke(!0)
217+
IL_0015: ret
218+
}
219+
220+
.property instance int32 B()
221+
{
222+
.custom instance void assembly/Attr1Attribute::.ctor() = ( 01 00 00 00 )
223+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags,
224+
int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 )
225+
.get instance int32 assembly/R2::get_B()
226+
}
227+
.property instance string A()
228+
{
229+
.custom instance void assembly/Attr2Attribute::.ctor() = ( 01 00 00 00 )
230+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags,
231+
int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 )
232+
.get instance string assembly/R2::get_A()
233+
}
234+
}
235+
236+
}
237+
238+
.class private abstract auto ansi sealed '<StartupCode$assembly>'.$assembly
239+
extends [runtime]System.Object
240+
{
241+
.method public static void main@() cil managed
242+
{
243+
.entrypoint
244+
245+
.maxstack 8
246+
IL_0000: ret
247+
}
248+
249+
}
250+
251+
252+
253+
254+
255+

0 commit comments

Comments
 (0)