Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a9a072

Browse files
authored
Merge pull requestdotnet#5029 from Microsoft/merges/master-to-dev15.8
Merge master to dev15.8
2 parentsd4647f9 +b648e19 commit6a9a072

File tree

5 files changed

+76
-7
lines changed

5 files changed

+76
-7
lines changed

‎src/fsharp/IlxGen.fs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6299,15 +6299,17 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon:Tycon) =
62996299
[for fspecin tycon.AllFieldsAsListdo
63006300

63016301
letuseGenuineField= useGenuineField tycon fspec
6302-
6302+
63036303
// The property (or genuine IL field) is hidden in these circumstances:
63046304
// - secret fields apart from "__value" fields for enums
63056305
// - the representation of the type is hidden
63066306
// - the F# field is hidden by a signature or private declaration
6307-
letisPropHidden=
6308-
((fspec.IsCompilerGenerated&&not tycon.IsEnumTycon)||
6309-
hiddenRepr||
6310-
IsHiddenRecdField eenv.sigToImplRemapInfo(tcref.MakeNestedRecdFieldRef fspec))
6307+
letisPropHidden=
6308+
// Enums always have public cases irrespective of Enum Visibility
6309+
if tycon.IsEnumTyconthenfalse
6310+
else
6311+
(fspec.IsCompilerGenerated|| hiddenRepr||
6312+
IsHiddenRecdField eenv.sigToImplRemapInfo(tcref.MakeNestedRecdFieldRef fspec))
63116313
letilType= GenType cenv.amap m eenvinner.tyenv fspec.FormalType
63126314
letilFieldName= ComputeFieldName tycon fspec
63136315

‎src/fsharp/service/service.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ type TypeCheckInfo
997997
| Item.FakeInterfaceCtor(TType_app(tcref,_))
998998
| Item.DelegateCtor(TType_app(tcref,_))-> tcref.CompiledName
999999
| Item.CtorGroup(_,(cinfo::_))->
1000-
(tcrefOfAppTy gcinfo.ApparentEnclosingType).CompiledName
1000+
cinfo.ApparentEnclosingTyconRef.CompiledName
10011001
|_-> d.Item.DisplayName)
10021002

10031003
// Filter out operators (and list)

‎src/fsharp/symbols/SymbolHelpers.fs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,8 @@ module internal SymbolHelpers =
966966
letg= infoReader.g
967967
letamap= infoReader.amap
968968
match itemwith
969-
| Item.Types(_,((TType_app(tcref,_))::_))->
969+
| Item.Types(_,((TType_app(tcref,_))::_))
970+
| Item.UnqualifiedType(tcref::_)->
970971
letty= generalizedTyconRef tcref
971972
Infos.ExistsHeadTypeInEntireHierarchy g amap range0 ty g.tcref_System_Attribute
972973
|_->false

‎tests/fsharp/core/enum/test.fsx‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// #Conformance #Regression
2+
#if TESTS_AS_APP
3+
moduleCore_enum
4+
#endif
5+
6+
openSystem.Reflection
7+
letfailures= ref[]
8+
9+
letreport_failure(s:string)=
10+
stderr.Write" Failed:"
11+
stderr.WriteLine s
12+
failures:=!failures@[s]
13+
14+
lettest(s:string)b=
15+
stderr.Write(s)
16+
if bthen stderr.WriteLine" Passed"
17+
else report_failure(s)
18+
19+
letcheck s b1 b2= test s(b1= b2)
20+
21+
typeinternalinternalEnum= Red=0| Yellow=1| Blue=2
22+
typepublicpublicEnum= Red=0| Yellow=1| Blue=2
23+
24+
moduleenum=
25+
26+
letAreCasesPublic(t:System.Type)=
27+
letbindingFlags= BindingFlags.Static||| BindingFlags.Public
28+
try
29+
letred= t.GetField("Red", bindingFlags)
30+
letyellow= t.GetField("Yellow", bindingFlags)
31+
letblue= t.GetField("Blue", bindingFlags)
32+
letvalue__= t.GetField("value__", bindingFlags||| BindingFlags.Instance)
33+
34+
if isNull red||not(red.IsPublic)then failwith(sprintf"Type:%s) - Red is not public. All enum cases should always be public" t.FullName)
35+
if isNull yellow||not(yellow.IsPublic)then failwith(sprintf"Type:%s) - Yellow is not public. All enum cases should always be public" t.FullName)
36+
if isNull blue||not(blue.IsPublic)then failwith(sprintf"Type:%s) - Blue is not public. All enum cases should always be public" t.FullName)
37+
if isNull value__||not(value__.IsPublic)then failwith(sprintf"Type:%s) - value__ is not public. value__ should always be public" t.FullName)
38+
true
39+
with_->false
40+
41+
do check"publicEnum"(AreCasesPublic typeof<publicEnum>)true
42+
do check"internalEnum"(AreCasesPublic typeof<internalEnum>)true
43+
44+
45+
#if TESTS_AS_APP
46+
letRUN()=!failures
47+
#else
48+
letaa=
49+
match!failureswith
50+
|[]->
51+
stdout.WriteLine"Test Passed"
52+
System.IO.File.WriteAllText("test.ok","ok")
53+
exit0
54+
|_->
55+
stdout.WriteLine"Test Failed"
56+
exit1
57+
#endif
58+

‎tests/fsharp/tests.fs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ module CoreTests =
237237
[<Test>]
238238
letcsext()= singleTestBuildAndRun"core/csext" FSC_BASIC
239239

240+
241+
[<Test>]
242+
letfscenum()= singleTestBuildAndRun"core/enum" FSC_BASIC
243+
244+
[<Test>]
245+
letfsienum()= singleTestBuildAndRun"core/enum" FSI_BASIC
246+
247+
240248
#if!FSHARP_SUITE_DRIVES_CORECLR_TESTS
241249

242250
[<Test>]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp