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

Commita71bbdc

Browse files
dsymelatkin
authored andcommitted
Let provided types be non-nullable
commit edc4d9bf4a3a6ac017ccf85c1e765374cc63b529Author: latkin <latkin@microsoft.com>Date: Mon Dec 1 13:32:55 2014 -0800 Updating surface area testscommit 9380ad5e64cfead4af96558a3bbd9fa121d10860Author: latkin <latkin@microsoft.com>Date: Mon Dec 1 11:27:14 2014 -0800 Fixups to correct build issuescommit b280e160d717966e0b3128e0e608988ec31e0af3Merge:48f3fd6 7deeecaAuthor: latkin <latkin@microsoft.com>Date: Mon Dec 1 10:29:45 2014 -0800 Merge branch 'feature1' ofhttps://git01.codeplex.com/forks/dsyme/cleanup into nonullprovtypescommit 7deeeca8ef04d2d776e38f33721ef24f3197255cAuthor: Don Syme <dsyme@microsoft.com>Date: Tue Jun 24 19:53:03 2014 +0100 Let provided types be non-nullable
1 parent48f3fd6 commita71bbdc

File tree

20 files changed

+181
-94
lines changed

20 files changed

+181
-94
lines changed

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.4.0.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,12 +741,15 @@ Microsoft.FSharp.Core.AbstractClassAttribute: Void .ctor()
741741
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean Equals(System.Object)
742742
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean IsDefaultAttribute()
743743
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean Match(System.Object)
744+
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean Value
745+
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean get_Value()
744746
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Int32 GetHashCode()
745747
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.Object TypeId
746748
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.Object get_TypeId()
747749
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.String ToString()
748750
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.Type GetType()
749751
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Void .ctor()
752+
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Void .ctor(Boolean)
750753
Microsoft.FSharp.Core.AutoOpenAttribute: Boolean Equals(System.Object)
751754
Microsoft.FSharp.Core.AutoOpenAttribute: Boolean IsDefaultAttribute()
752755
Microsoft.FSharp.Core.AutoOpenAttribute: Boolean Match(System.Object)

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.Portable.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,15 @@ Microsoft.FSharp.Core.AbstractClassAttribute: Void .ctor()
734734
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean Equals(System.Object)
735735
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean IsDefaultAttribute()
736736
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean Match(System.Object)
737+
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean Value
738+
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Boolean get_Value()
737739
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Int32 GetHashCode()
738740
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.Object TypeId
739741
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.Object get_TypeId()
740742
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.String ToString()
741743
Microsoft.FSharp.Core.AllowNullLiteralAttribute: System.Type GetType()
742744
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Void .ctor()
745+
Microsoft.FSharp.Core.AllowNullLiteralAttribute: Void .ctor(Boolean)
743746
Microsoft.FSharp.Core.AutoOpenAttribute: Boolean Equals(System.Object)
744747
Microsoft.FSharp.Core.AutoOpenAttribute: Boolean IsDefaultAttribute()
745748
Microsoft.FSharp.Core.AutoOpenAttribute: Boolean Match(System.Object)

‎src/fsharp/FSharp.Core/prim-types.fs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ namespace Microsoft.FSharp.Core
127127

128128
[<AttributeUsage(AttributeTargets.Class,AllowMultiple=false)>]
129129
[<Sealed>]
130-
typeAllowNullLiteralAttribute()=
130+
typeAllowNullLiteralAttribute(value: bool)=
131131
inherit System.Attribute()
132+
memberx.Value= value
133+
new()=new AllowNullLiteralAttribute(true)
132134

133135
[<AttributeUsage(AttributeTargets.Field,AllowMultiple=false)>]
134136
[<Sealed>]

‎src/fsharp/FSharp.Core/prim-types.fsi‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ namespace Microsoft.FSharp.Core
238238
/// <returns>AllowNullLiteralAttribute</returns>
239239
new: unit-> AllowNullLiteralAttribute
240240

241+
/// <summary>Creates an instance of the attribute with the specified value</summary>
242+
/// <returns>AllowNullLiteralAttribute</returns>
243+
new: value: bool-> AllowNullLiteralAttribute
244+
245+
/// <summary>The value of the attribute, indicating whether the type allows the null literal or not</summary>
246+
memberValue:bool
247+
241248
/// <summary>Adding this attribute to a value causes it to be compiled as a CLI constant literal.</summary>
242249
[<AttributeUsage(AttributeTargets.Field,AllowMultiple=false)>]
243250
[<Sealed>]

‎src/fsharp/check.fs‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -900,14 +900,7 @@ and CheckAttribs cenv env (attribs: Attribs) =
900900
|> Seq.map fst
901901
|> Seq.toList
902902
// Filter for allowMultiple = false
903-
|> List.filter(fun(tcref,m)->
904-
letallowMultiple=
905-
Infos.AttributeChecking.TryBindTyconRefAttribute cenv.g m cenv.g.attrib_AttributeUsageAttribute tcref
906-
(fun(_,named)-> named|> List.tryPick(function("AllowMultiple",_,_,ILAttribElem.Bool res)-> Some res|_-> None))
907-
(fun(Attrib(_,_,_,named,_,_,_))-> named|> List.tryPick(function AttribNamedArg("AllowMultiple",_,_,AttribBoolArg(res))-> Some res|_-> None))
908-
(fun _-> None)
909-
910-
(allowMultiple<> Some(true)))
903+
|> List.filter(fun(tcref,m)-> TryFindAttributeUsageAttribute cenv.g m tcref<> Some(true))
911904
if cenv.reportErrorsthen
912905
for(tcref,m)in duplicatesdo
913906
errorR(Error(FSComp.SR.chkAttrHasAllowMultiFalse(tcref.DisplayName), m))
@@ -1384,7 +1377,7 @@ let CheckEntityDefn cenv env (tycon:Entity) =
13841377
letzeroInitUnsafe= TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_DefaultValueAttribute f.FieldAttribs
13851378
if zeroInitUnsafe= Some(true)then
13861379
letty'= generalizedTyconRef(mkLocalTyconRef tycon)
1387-
ifnot(TypeHasDefaultValue cenv.g ty')then
1380+
ifnot(TypeHasDefaultValue cenv.gmty')then
13881381
errorR(Error(FSComp.SR.chkValueWithDefaultValueMustHaveDefaultValue(), m));
13891382
)
13901383
match tycon.TypeAbbrevwith(* And type abbreviations*)

‎src/fsharp/csolve.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ and SolveTypSupportsNull (csenv:ConstraintSolverEnv) ndeep m2 trace ty =
15851585
if isTyparTy g tythen
15861586
AddConstraint csenv ndeep m2 trace(destTyparTy g ty)(TyparConstraint.SupportsNull(m))
15871587
elif
1588-
TypeSatisfiesNullConstraint g tythen CompleteD
1588+
TypeSatisfiesNullConstraint gmtythen CompleteD
15891589
else
15901590
match tywith
15911591
| NullableTy g_->
@@ -1757,7 +1757,7 @@ and SolveTypRequiresDefaultConstructor (csenv:ConstraintSolverEnv) ndeep m2 trac
17571757
letty= stripTyEqnsAndMeasureEqns g typ
17581758
if isTyparTy g tythen
17591759
AddConstraint csenv ndeep m2 trace(destTyparTy g ty)(TyparConstraint.RequiresDefaultConstructor(m))
1760-
elif isStructTy g ty&& TypeHasDefaultValue g tythen
1760+
elif isStructTy g ty&& TypeHasDefaultValue gmtythen
17611761
CompleteD
17621762
elif
17631763
GetIntrinsicConstructorInfosOfType csenv.InfoReader m ty

‎src/fsharp/env.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa
812812

813813

814814
letmk_MFCore_attrib nm:BuiltinAttribInfo=
815-
AttribInfo(mkILTyRef(IlxSettings.ilxFsharpCoreLibScopeRef(), nm),mk_MFCore_tcref fslibCcu nm)
815+
AttribInfo(mkILTyRef(IlxSettings.ilxFsharpCoreLibScopeRef(),FSharpLib.Core+"."+nm),mk_MFCore_tcref fslibCcu nm)
816816

817817
letmkAttrib(nm:string)scopeRef:BuiltinAttribInfo=
818818
letpath,typeName= splitILTypeName nm

‎src/fsharp/est.fs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ module internal ExtensionTyping =
609609
abstractGetDefinitionLocationAttribute : provider:ITypeProvider->(string*int*int)option
610610
abstractGetXmlDocAttributes : provider:ITypeProvider->string[]
611611
abstractGetHasTypeProviderEditorHideMethodsAttribute : provider:ITypeProvider->bool
612-
abstractGetAttributeConstructorArgs: provider:ITypeProvider* attribName:string->objoptionlistoption
612+
abstractGetAttributeConstructorArgs: provider:ITypeProvider* attribName:string->(objoptionlist*(string*objoption)list)option
613613

614614
andProvidedCustomAttributeProvider=
615615
static memberCreate(attributes:(ITypeProvider-> System.Collections.Generic.IList<CustomAttributeData>)):IProvidedCustomAttributeProvider=
@@ -622,9 +622,15 @@ module internal ExtensionTyping =
622622
attributes(provider)
623623
|> Seq.tryFind(findAttribByName attribName)
624624
|> Option.map(fun a->
625-
a.ConstructorArguments
626-
|> Seq.toList
627-
|> List.map(function Argnull-> None| Arg obj-> Some obj|_-> None))
625+
letctorArgs=
626+
a.ConstructorArguments
627+
|> Seq.toList
628+
|> List.map(function Argnull-> None| Arg obj-> Some obj|_-> None)
629+
letnamedArgs=
630+
a.NamedArguments
631+
|> Seq.toList
632+
|> List.map(fun arg-> arg.MemberName,match arg.TypedValuewith Argnull-> None| Arg obj-> Some obj|_-> None)
633+
ctorArgs, namedArgs)
628634

629635
member__.GetHasTypeProviderEditorHideMethodsAttribute provider=
630636
attributes(provider)

‎src/fsharp/est.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ module internal ExtensionTyping =
178178
abstractGetHasTypeProviderEditorHideMethodsAttribute : provider:ITypeProvider->bool
179179
abstractGetDefinitionLocationAttribute : provider:ITypeProvider->(string*int*int)option
180180
abstractGetXmlDocAttributes : provider:ITypeProvider->string[]
181-
abstractGetAttributeConstructorArgs: provider:ITypeProvider* attribName:string->objoptionlistoption
181+
abstractGetAttributeConstructorArgs: provider:ITypeProvider* attribName:string->(objoptionlist*(string*objoption)list)option
182182

183183
and [<AllowNullLiteral; Sealed; Class>]
184184
ProvidedAssembly=

‎src/fsharp/infos.fs‎

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,29 +2496,6 @@ exception ObsoleteError of string * range
24962496
/// formats.
24972497
moduleAttributeChecking=
24982498

2499-
/// Analyze three cases for attributes declared on type definitions: IL-declared attributes, F#-declared attributes and
2500-
/// provided attributes.
2501-
//
2502-
// This is used for AttributeUsageAttribute, DefaultMemberAttribute and ConditionalAttribute (on attribute types)
2503-
letTryBindTyconRefAttribute g m(AttribInfo(atref,_)as args)(tcref:TyconRef)f1 f2 f3=
2504-
ignore m; ignore f3
2505-
match metadataOfTycon tcref.Derefwith
2506-
#if EXTENSIONTYPING
2507-
| ProvidedTypeMetadata info->
2508-
letprovAttribs= info.ProvidedType.PApply((fun a->(a:> IProvidedCustomAttributeProvider)),m)
2509-
match provAttribs.PUntaint((fun a-> a.GetAttributeConstructorArgs(provAttribs.TypeProvider.PUntaintNoFailure(id), atref.FullName)),m)with
2510-
| Some args-> f3 args
2511-
| None-> None
2512-
#endif
2513-
| ILTypeMetadata(_,tdef)->
2514-
match TryDecodeILAttribute g atref(Some(atref.Scope)) tdef.CustomAttrswith
2515-
| Some attr-> f1 attr
2516-
|_-> None
2517-
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata->
2518-
match TryFindFSharpAttribute g args tcref.Attribswith
2519-
| Some attr-> f2 attr
2520-
|_-> None
2521-
25222499
/// Analyze three cases for attributes declared on methods: IL-declared attributes, F#-declared attributes and
25232500
/// provided attributes.
25242501
letBindMethInfoAttributes m minfo f1 f2 f3=
@@ -2553,7 +2530,7 @@ module AttributeChecking =
25532530
TryBindMethInfoAttribute g m attribSpec minfo
25542531
(function([ILAttribElem.String(Some msg)],_)-> Some msg|_-> None)
25552532
(function(Attrib(_,_,[ AttribStringArg msg],_,_,_,_))-> Some msg|_-> None)
2556-
(function[ Some((:? stringas msg): obj)]-> Some msg|_-> None)
2533+
(function([ Some((:? stringas msg): obj)],_)-> Some msg|_-> None)
25572534

25582535
/// Check if a method has a specific attribute.
25592536
letMethInfoHasAttribute g m attribSpec minfo=
@@ -2563,22 +2540,6 @@ module AttributeChecking =
25632540
(fun _-> Some())
25642541
|> Option.isSome
25652542

2566-
/// Try to find a specific attribute on a type definition, where the attribute accepts a string argument.
2567-
///
2568-
/// This is used to detect the 'DefaultMemberAttribute' and 'ConditionalAttribute' attributes (on type definitions)
2569-
letTryFindTyconRefStringAttribute g m attribSpec tcref=
2570-
TryBindTyconRefAttribute g m attribSpec tcref
2571-
(function([ILAttribElem.String(Some(msg))],_)-> Some msg|_-> None)
2572-
(function(Attrib(_,_,[ AttribStringArg(msg)],_,_,_,_))-> Some msg|_-> None)
2573-
(function[ Some((:? stringas msg): obj)]-> Some msg|_-> None)
2574-
2575-
/// Check if a type definition has a specific attribute
2576-
letTyconRefHasAttribute g m attribSpec tcref=
2577-
TryBindTyconRefAttribute g m attribSpec tcref
2578-
(fun _-> Some())
2579-
(fun _-> Some())
2580-
(fun _-> Some())
2581-
|> Option.isSome
25822543

25832544

25842545
/// Check IL attributes for 'ObsoleteAttribute', returning errors and warnings as data
@@ -2652,13 +2613,13 @@ module AttributeChecking =
26522613
letprivateCheckProvidedAttributes g m(provAttribs:Tainted<IProvidedCustomAttributeProvider>)=
26532614
let(AttribInfo(tref,_))= g.attrib_SystemObsolete
26542615
match provAttribs.PUntaint((fun a-> a.GetAttributeConstructorArgs(provAttribs.TypeProvider.PUntaintNoFailure(id), tref.FullName)),m)with
2655-
| Some[ Some(:? stringas msg)]-> WarnD(ObsoleteWarning(msg,m))
2656-
| Some[ Some(:? stringas msg); Some(:?boolas isError)]->
2616+
| Some([ Some(:? stringas msg)],_)-> WarnD(ObsoleteWarning(msg,m))
2617+
| Some([ Some(:? stringas msg); Some(:?boolas isError)],_)->
26572618
if isErrorthen
26582619
ErrorD(ObsoleteError(msg,m))
26592620
else
26602621
WarnD(ObsoleteWarning(msg,m))
2661-
| Some[ None]->
2622+
| Some([ None],_)->
26622623
WarnD(ObsoleteWarning("",m))
26632624
| Some_->
26642625
WarnD(ObsoleteWarning("",m))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp