Some diff minimization for RFC FS-1060 (#15155)

* cleanup

* more cleanup

* fantomas

* cleanup

* transfer a few more changes

* fantomas

* fix build
This commit is contained in:
Don Syme 2023-04-29 15:43:45 +01:00 коммит произвёл GitHub
Родитель b131422389
Коммит df3919d694
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
48 изменённых файлов: 381 добавлений и 335 удалений

Просмотреть файл

@ -228,7 +228,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) =
let fileStamp = FileSystem.GetLastWriteTimeShim fileName
/// The weak handle to the bytes for the file
let weakBytes = WeakReference<byte[]>(null)
let weakBytes = WeakReference<byte[] MaybeNull>(null)
member _.FileName = fileName
@ -254,7 +254,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) =
weakBytes.SetTarget bytes
tg
nonNull tg
ByteMemory.FromArray(strongBytes).AsReadOnly()
@ -941,10 +941,11 @@ let mkCacheInt32 lowMem _inbase _nm _sz =
fun f (idx: int32) ->
let cache =
match cache with
| null -> cache <- ConcurrentDictionary<int32, _>(Environment.ProcessorCount, 11)
| _ -> ()
cache
| Null ->
let v = ConcurrentDictionary<int32, _>(Environment.ProcessorCount, 11)
cache <- v
v
| NonNull v -> v
match cache.TryGetValue idx with
| true, res ->
@ -969,10 +970,11 @@ let mkCacheGeneric lowMem _inbase _nm _sz =
fun f (idx: 'T) ->
let cache =
match cache with
| null -> cache <- ConcurrentDictionary<_, _>(Environment.ProcessorCount, 11 (* sz: int *) )
| _ -> ()
cache
| Null ->
let v = ConcurrentDictionary<_, _>(Environment.ProcessorCount, 11 (* sz: int *) )
cache <- v
v
| NonNull v -> v
match cache.TryGetValue idx with
| true, v ->

Просмотреть файл

@ -265,7 +265,7 @@ type TypeBuilder with
let t = typB.CreateTypeAndLog()
let m =
if t <> null then
if box t <> null then
t.GetMethod(nm, (args |> Seq.map (fun x -> x.GetType()) |> Seq.toArray))
else
null
@ -546,10 +546,10 @@ let emEnv0 =
delayedFieldInits = []
}
let envBindTypeRef emEnv (tref: ILTypeRef) (typT, typB, typeDef) =
let envBindTypeRef emEnv (tref: ILTypeRef) (typT: System.Type MaybeNull, typB, typeDef) =
match typT with
| null -> failwithf "binding null type in envBindTypeRef: %s\n" tref.Name
| _ ->
| Null -> failwithf "binding null type in envBindTypeRef: %s\n" tref.Name
| NonNull typT ->
{ emEnv with
emTypMap = Zmap.add tref (typT, typB, typeDef, None) emEnv.emTypMap
}
@ -1018,7 +1018,7 @@ let queryableTypeGetMethod cenv emEnv parentT (mref: ILMethodRef) : MethodInfo =
cconv ||| BindingFlags.Public ||| BindingFlags.NonPublic,
null,
argTs,
(null: ParameterModifier[])
(null: ParameterModifier[] MaybeNull)
)
// This can fail if there is an ambiguity w.r.t. return type
with _ ->
@ -1102,14 +1102,14 @@ let queryableTypeGetConstructor cenv emEnv (parentT: Type) (mref: ILMethodRef) =
parentT.GetConstructor(BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Instance, null, reqArgTs, null)
match res with
| null ->
| Null ->
error (
Error(
FSComp.SR.itemNotFoundInTypeDuringDynamicCodeGen ("constructor", mref.Name, parentT.FullName, parentT.Assembly.FullName),
range0
)
)
| _ -> res
| NonNull res -> res
let nonQueryableTypeGetConstructor (parentTI: Type) (consInfo: ConstructorInfo) : ConstructorInfo MaybeNull =
if parentTI.IsGenericType then

Просмотреть файл

@ -4332,7 +4332,7 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn
TcLongIdentType kindOpt cenv newOk checkConstraints occ iwsam env tpenv synLongId
| MultiDimensionArrayType (rank, elemTy, m) ->
TcElementType cenv newOk checkConstraints occ env tpenv rank elemTy m
TcArrayType cenv newOk checkConstraints occ env tpenv rank elemTy m
| SynType.App (StripParenTypes (SynType.LongIdent longId), _, args, _, _, postfix, m) ->
TcLongIdentAppType kindOpt cenv newOk checkConstraints occ iwsam env tpenv longId postfix args m
@ -4353,7 +4353,7 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn
TcFunctionType cenv newOk checkConstraints occ env tpenv domainTy resultTy
| SynType.Array (rank , elemTy, m) ->
TcElementType cenv newOk checkConstraints occ env tpenv rank elemTy m
TcArrayType cenv newOk checkConstraints occ env tpenv rank elemTy m
| SynType.Var (tp, _) ->
TcTypeParameter kindOpt cenv env newOk tpenv tp
@ -4521,7 +4521,7 @@ and TcFunctionType (cenv: cenv) newOk checkConstraints occ env tpenv domainTy re
let tyR = mkFunTy g domainTyR resultTyR
tyR, tpenv
and TcElementType (cenv: cenv) newOk checkConstraints occ env tpenv rank elemTy m =
and TcArrayType (cenv: cenv) newOk checkConstraints occ env tpenv rank elemTy m =
let g = cenv.g
let elemTy, tpenv = TcTypeAndRecover cenv newOk checkConstraints occ WarnOnIWSAM.Yes env tpenv elemTy
let tyR = mkArrayTy g rank elemTy m
@ -5339,8 +5339,8 @@ and TcExprUndelayedNoType (cenv: cenv) env tpenv synExpr =
let expr, tpenv = TcExprUndelayed cenv (MustEqual overallTy) env tpenv synExpr
expr, overallTy, tpenv
/// Process a leaf construct where the actual type (or an approximation of it such as 'list<_>'
/// or 'array<_>') is already sufficiently pre-known, and the information in the overall type
/// Process a leaf construct where the actual type (or an approximation of it such as '_ list'
/// or '_ array') is already sufficiently pre-known, and the information in the overall type
/// can be eagerly propagated into the actual type (UnifyOverallType), including pre-calculating
/// any type-directed conversion. This must mean that types extracted when processing the expression are not
/// considered in determining any type-directed conversion.

Просмотреть файл

@ -1203,7 +1203,9 @@ and SolveTypeEqualsType (csenv: ConstraintSolverEnv) ndeep m2 (trace: OptionalTr
if not (typarsAEquiv g aenv tps1 tps2) then localAbortD else
SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace bodyTy1 bodyTy2
| TType_ucase (uc1, l1), TType_ucase (uc2, l2) when g.unionCaseRefEq uc1 uc2 -> SolveTypeEqualsTypeEqns csenv ndeep m2 trace None l1 l2
| TType_ucase (uc1, l1), TType_ucase (uc2, l2) when g.unionCaseRefEq uc1 uc2 ->
SolveTypeEqualsTypeEqns csenv ndeep m2 trace None l1 l2
| _ -> localAbortD
and SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace ty1 ty2 =

Просмотреть файл

@ -1067,7 +1067,7 @@ let MakeMethInfoCall (amap: ImportMap) m (minfo: MethInfo) minst args staticTyOp
let isProp = false // not necessarily correct, but this is only used post-creflect where this flag is irrelevant
let ilMethodRef = Import.ImportProvidedMethodBaseAsILMethodRef amap m mi
let isConstructor = mi.PUntaint((fun c -> c.IsConstructor), m)
let isStruct = mi.PUntaint((fun c -> c.DeclaringType.IsValueType), m)
let isStruct = mi.PUntaint((fun c -> (nonNull<ProvidedType> c.DeclaringType).IsValueType), m)
let actualTypeInst = [] // GENERIC TYPE PROVIDERS: for generics, we would have something here
let actualMethInst = [] // GENERIC TYPE PROVIDERS: for generics, we would have something here
let ilReturnTys = Option.toList (minfo.GetCompiledReturnType(amap, m, [])) // GENERIC TYPE PROVIDERS: for generics, we would have more here
@ -1080,7 +1080,7 @@ let MakeMethInfoCall (amap: ImportMap) m (minfo: MethInfo) minst args staticTyOp
// This imports a provided method, and checks if it is a known compiler intrinsic like "1 + 2"
let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap: Import.ImportMap, m: range, mbase: Tainted<ProvidedMethodBase>) =
let methodName = mbase.PUntaint((fun x -> x.Name), m)
let declaringType = Import.ImportProvidedType amap m (mbase.PApply((fun x -> x.DeclaringType), m))
let declaringType = Import.ImportProvidedType amap m (mbase.PApply((fun x -> nonNull<ProvidedType> x.DeclaringType), m))
match tryTcrefOfAppTy amap.g declaringType with
| ValueSome declaringEntity ->
if not declaringEntity.IsLocalRef && ccuEq declaringEntity.nlr.Ccu amap.g.fslibCcu then
@ -2042,7 +2042,7 @@ module ProvidedMethodCalls =
let thisArg, paramVars =
match objArgs with
| [objArg] ->
let erasedThisTy = eraseSystemType (amap, m, mi.PApply((fun mi -> mi.DeclaringType), m))
let erasedThisTy = eraseSystemType (amap, m, mi.PApply((fun mi -> nonNull<ProvidedType> mi.DeclaringType), m))
let thisVar = erasedThisTy.PApply((fun ty -> ty.AsProvidedVar("this")), m)
Some objArg, Array.append [| thisVar |] paramVars
| [] -> None, paramVars
@ -2062,7 +2062,7 @@ module ProvidedMethodCalls =
methInfoOpt, expr, exprTy
with
| :? TypeProviderError as tpe ->
let typeName = mi.PUntaint((fun mb -> mb.DeclaringType.FullName), m)
let typeName = mi.PUntaint((fun mb -> (nonNull<ProvidedType> mb.DeclaringType).FullName), m)
let methName = mi.PUntaint((fun mb -> mb.Name), m)
raise( tpe.WithContext(typeName, methName) ) // loses original stack trace
#endif

Просмотреть файл

@ -621,7 +621,7 @@ module DispatchSlotChecking =
// dispatch slots are ordered from the derived classes to base
// so we can check the topmost dispatch slot if it is final
match dispatchSlots with
| meth :: _ when meth.IsFinal -> errorR(Error(FSComp.SR.tcCannotOverrideSealedMethod (sprintf "%s::%s" (meth.ApparentEnclosingType.ToString()) meth.LogicalName), m))
| meth :: _ when meth.IsFinal -> errorR(Error(FSComp.SR.tcCannotOverrideSealedMethod((sprintf "%s::%s" (NicePrint.stringOfTy denv meth.ApparentEnclosingType) meth.LogicalName)), m))
| _ -> ()
/// Get the slots of a type that can or must be implemented. This depends

Просмотреть файл

@ -41,44 +41,47 @@ let GetSuperTypeOfType g amap m ty =
let ty = stripTyEqnsAndMeasureEqns g ty
#endif
match metadataOfTy g ty with
let resBeforeNull =
match metadataOfTy g ty with
#if !NO_TYPEPROVIDERS
| ProvidedTypeMetadata info ->
let st = info.ProvidedType
let superOpt = st.PApplyOption((fun st -> match st.BaseType with null -> None | t -> Some t), m)
match superOpt with
| None -> None
| Some super -> Some(ImportProvidedType amap m super)
| ProvidedTypeMetadata info ->
let st = info.ProvidedType
let superOpt = st.PApplyOption((fun st -> match st.BaseType with null -> None | t -> Some t), m)
match superOpt with
| None -> None
| Some super -> Some(ImportProvidedType amap m super)
#endif
| ILTypeMetadata (TILObjectReprData(scoref, _, tdef)) ->
let tinst = argsOfAppTy g ty
match tdef.Extends with
| None -> None
| Some ilTy -> Some (RescopeAndImportILType scoref amap m tinst ilTy)
| ILTypeMetadata (TILObjectReprData(scoref, _, tdef)) ->
let tinst = argsOfAppTy g ty
match tdef.Extends with
| None -> None
| Some ilTy -> Some (RescopeAndImportILType scoref amap m tinst ilTy)
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata ->
if isFSharpObjModelTy g ty || isFSharpExceptionTy g ty then
let tcref = tcrefOfAppTy g ty
Some (instType (mkInstForAppTy g ty) (superOfTycon g tcref.Deref))
elif isArrayTy g ty then
Some g.system_Array_ty
elif isRefTy g ty && not (isObjTy g ty) then
Some g.obj_ty
elif isStructTupleTy g ty then
Some g.system_Value_ty
elif isFSharpStructOrEnumTy g ty then
if isFSharpEnumTy g ty then
Some g.system_Enum_ty
else
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata ->
if isFSharpObjModelTy g ty || isFSharpExceptionTy g ty then
let tcref = tcrefOfAppTy g ty
Some (instType (mkInstForAppTy g ty) (superOfTycon g tcref.Deref))
elif isArrayTy g ty then
Some g.system_Array_ty
elif isRefTy g ty && not (isObjTy g ty) then
Some g.obj_ty
elif isStructTupleTy g ty then
Some g.system_Value_ty
elif isStructAnonRecdTy g ty then
Some g.system_Value_ty
elif isAnonRecdTy g ty then
Some g.obj_ty
elif isRecdTy g ty || isUnionTy g ty then
Some g.obj_ty
else
None
elif isFSharpStructOrEnumTy g ty then
if isFSharpEnumTy g ty then
Some g.system_Enum_ty
else
Some g.system_Value_ty
elif isStructAnonRecdTy g ty then
Some g.system_Value_ty
elif isAnonRecdTy g ty then
Some g.obj_ty
elif isRecdTy g ty || isUnionTy g ty then
Some g.obj_ty
else
None
resBeforeNull
/// Make a type for System.Collections.Generic.IList<ty>
let mkSystemCollectionsGenericIListTy (g: TcGlobals) ty =

Просмотреть файл

@ -38,7 +38,7 @@ type AssemblyLoader =
/// Get a flag indicating if an assembly is a provided assembly, plus the
/// table of information recording remappings from type names in the provided assembly to type
/// names in the statically linked, embedded assembly.
abstract GetProvidedAssemblyInfo : CompilationThreadToken * range * Tainted<ProvidedAssembly> -> bool * ProvidedAssemblyStaticLinkingMap option
abstract GetProvidedAssemblyInfo : CompilationThreadToken * range * Tainted<ProvidedAssembly MaybeNull> -> bool * ProvidedAssemblyStaticLinkingMap option
/// Record a root for a [<Generate>] type to help guide static linking & type relocation
abstract RecordGeneratedTypeRoot : ProviderGeneratedType -> unit
@ -183,16 +183,24 @@ let rec ImportILType (env: ImportMap) m tinst ty =
ImportTyconRefApp env tcref inst
| ILType.Byref ty -> mkByrefTy env.g (ImportILType env m tinst ty)
| ILType.Ptr ILType.Void when env.g.voidptr_tcr.CanDeref -> mkVoidPtrTy env.g
| ILType.Ptr ty -> mkNativePtrTy env.g (ImportILType env m tinst ty)
| ILType.FunctionPointer _ -> env.g.nativeint_ty (* failwith "cannot import this kind of type (ptr, fptr)" *)
| ILType.Modified(_, _, ty) ->
// All custom modifiers are ignored
ImportILType env m tinst ty
| ILType.TypeVar u16 ->
try List.item (int u16) tinst
with _ ->
error(Error(FSComp.SR.impNotEnoughTypeParamsInScopeWhileImporting(), m))
let ty =
try
List.item (int u16) tinst
with _ ->
error(Error(FSComp.SR.impNotEnoughTypeParamsInScopeWhileImporting(), m))
ty
/// Determines if an IL type can be imported as an F# type
let rec CanImportILType (env: ImportMap) m ty =
@ -354,15 +362,15 @@ let rec ImportProvidedType (env: ImportMap) (m: range) (* (tinst: TypeInst) *) (
/// Import a provided method reference as an Abstract IL method reference
let ImportProvidedMethodBaseAsILMethodRef (env: ImportMap) (m: range) (mbase: Tainted<ProvidedMethodBase>) =
let tref = GetILTypeRefOfProvidedType (mbase.PApply((fun mbase -> mbase.DeclaringType), m), m)
let tref = GetILTypeRefOfProvidedType (mbase.PApply((fun mbase -> nonNull<ProvidedType> mbase.DeclaringType), m), m)
let mbase =
// Find the formal member corresponding to the called member
match mbase.OfType<ProvidedMethodInfo>() with
| Some minfo when
minfo.PUntaint((fun minfo -> minfo.IsGenericMethod|| minfo.DeclaringType.IsGenericType), m) ->
minfo.PUntaint((fun minfo -> minfo.IsGenericMethod|| (nonNull<ProvidedType> minfo.DeclaringType).IsGenericType), m) ->
let declaringType = minfo.PApply((fun minfo -> minfo.DeclaringType), m)
let declaringType = minfo.PApply((fun minfo -> nonNull<ProvidedType> minfo.DeclaringType), m)
let declaringGenericTypeDefn =
if declaringType.PUntaint((fun t -> t.IsGenericType), m) then
@ -381,8 +389,8 @@ let ImportProvidedMethodBaseAsILMethodRef (env: ImportMap) (m: range) (mbase: Ta
error(Error(FSComp.SR.etIncorrectProvidedMethod(DisplayNameOfTypeProvider(minfo.TypeProvider, m), methodName, metadataToken, typeName), m))
| _ ->
match mbase.OfType<ProvidedConstructorInfo>() with
| Some cinfo when cinfo.PUntaint((fun x -> x.DeclaringType.IsGenericType), m) ->
let declaringType = cinfo.PApply((fun x -> x.DeclaringType), m)
| Some cinfo when cinfo.PUntaint((fun x -> (nonNull<ProvidedType> x.DeclaringType).IsGenericType), m) ->
let declaringType = cinfo.PApply((fun x -> nonNull<ProvidedType> x.DeclaringType), m)
let declaringGenericTypeDefn = declaringType.PApply((fun x -> x.GetGenericTypeDefinition()), m)
// We have to find the uninstantiated formal signature corresponding to this instantiated constructor.

Просмотреть файл

@ -75,7 +75,7 @@ type ValRef with
let GetCompiledReturnTyOfProvidedMethodInfo amap m (mi: Tainted<ProvidedMethodBase>) =
let returnType =
if mi.PUntaint((fun mi -> mi.IsConstructor), m) then
mi.PApply((fun mi -> mi.DeclaringType), m)
mi.PApply((fun mi -> nonNull<ProvidedType> mi.DeclaringType), m)
else mi.Coerce<ProvidedMethodInfo>(m).PApply((fun mi -> mi.ReturnType), m)
let ty = ImportProvidedType amap m returnType
if isVoidTy amap.g ty then None else Some ty
@ -344,8 +344,8 @@ type ILFieldInit with
/// Compute the ILFieldInit for the given provided constant value for a provided enum type.
static member FromProvidedObj m (v: obj) =
match v with
| null -> ILFieldInit.Null
| _ ->
| Null -> ILFieldInit.Null
| NonNull v ->
let objTy = v.GetType()
let v = if objTy.IsEnum then objTy.GetField("value__").GetValue v else v
match v with
@ -393,8 +393,8 @@ let OptionalArgInfoOfProvidedParameter (amap: ImportMap) m (provParam : Tainted<
/// Compute the ILFieldInit for the given provided constant value for a provided enum type.
let GetAndSanityCheckProviderMethod m (mi: Tainted<'T :> ProvidedMemberInfo>) (get : 'T -> ProvidedMethodInfo MaybeNull) err =
match mi.PApply((fun mi -> (get mi :> ProvidedMethodBase)), m) with
| Tainted.Null -> error(Error(err(mi.PUntaint((fun mi -> mi.Name), m), mi.PUntaint((fun mi -> mi.DeclaringType.Name), m)), m))
match mi.PApply((fun mi -> (get mi :> ProvidedMethodBase MaybeNull)),m) with
| Tainted.Null -> error(Error(err(mi.PUntaint((fun mi -> mi.Name),m),mi.PUntaint((fun mi -> (nonNull<ProvidedType> mi.DeclaringType).Name), m)), m)) // TODO NULLNESS: type isntantiation should not be needed
| meth -> meth
/// Try to get an arbitrary ProvidedMethodInfo associated with a property.
@ -404,7 +404,7 @@ let ArbitraryMethodInfoOfPropertyInfo (pi: Tainted<ProvidedPropertyInfo>) m =
elif pi.PUntaint((fun pi -> pi.CanWrite), m) then
GetAndSanityCheckProviderMethod m pi (fun pi -> pi.GetSetMethod()) FSComp.SR.etPropertyCanWriteButHasNoSetter
else
error(Error(FSComp.SR.etPropertyNeedsCanWriteOrCanRead(pi.PUntaint((fun mi -> mi.Name), m), pi.PUntaint((fun mi -> mi.DeclaringType.Name), m)), m))
error(Error(FSComp.SR.etPropertyNeedsCanWriteOrCanRead(pi.PUntaint((fun mi -> mi.Name), m), pi.PUntaint((fun mi -> (nonNull<ProvidedType> mi.DeclaringType).Name), m)), m))
#endif
@ -649,7 +649,7 @@ type MethInfo =
| DefaultStructCtor(_, ty) -> ty
#if !NO_TYPEPROVIDERS
| ProvidedMeth(amap, mi, _, m) ->
ImportProvidedType amap m (mi.PApply((fun mi -> mi.DeclaringType), m))
ImportProvidedType amap m (mi.PApply((fun mi -> nonNull<ProvidedType> mi.DeclaringType), m))
#endif
/// Get the enclosing type of the method info, using a nominal type for tuple types
@ -1137,7 +1137,7 @@ type MethInfo =
| DefaultStructCtor _ -> []
#if !NO_TYPEPROVIDERS
| ProvidedMeth(amap, mi, _, m) ->
if x.IsInstance then [ ImportProvidedType amap m (mi.PApply((fun mi -> mi.DeclaringType), m)) ] // find the type of the 'this' argument
if x.IsInstance then [ ImportProvidedType amap m (mi.PApply((fun mi -> nonNull<ProvidedType> mi.DeclaringType), m)) ] // find the type of the 'this' argument
else []
#endif
@ -1296,7 +1296,7 @@ type MethInfo =
let paramTy =
match p.PApply((fun p -> p.ParameterType), m) with
| Tainted.Null -> amap.g.unit_ty
| parameterType -> ImportProvidedType amap m parameterType
| Tainted.NonNull parameterType -> ImportProvidedType amap m parameterType
yield ParamNameAndType(paramName, paramTy) ] ]
#endif
@ -1349,7 +1349,7 @@ type ILFieldInfo =
match x with
| ILFieldInfo(tinfo, _) -> tinfo.ToType
#if !NO_TYPEPROVIDERS
| ProvidedField(amap, fi, m) -> (ImportProvidedType amap m (fi.PApply((fun fi -> fi.DeclaringType), m)))
| ProvidedField(amap, fi, m) -> (ImportProvidedType amap m (fi.PApply((fun fi -> nonNull<ProvidedType> fi.DeclaringType), m)))
#endif
member x.ApparentEnclosingAppType = x.ApparentEnclosingType
@ -1370,7 +1370,7 @@ type ILFieldInfo =
match x with
| ILFieldInfo(tinfo, _) -> tinfo.ILTypeRef
#if !NO_TYPEPROVIDERS
| ProvidedField(amap, fi, m) -> (ImportProvidedTypeAsILType amap m (fi.PApply((fun fi -> fi.DeclaringType), m))).TypeRef
| ProvidedField(amap, fi, m) -> (ImportProvidedTypeAsILType amap m (fi.PApply((fun fi -> nonNull<ProvidedType> fi.DeclaringType), m))).TypeRef
#endif
/// Get the scope used to interpret IL metadata
@ -1664,7 +1664,7 @@ type PropInfo =
| FSProp(_, ty, _, _) -> ty
#if !NO_TYPEPROVIDERS
| ProvidedProp(amap, pi, m) ->
ImportProvidedType amap m (pi.PApply((fun pi -> pi.DeclaringType), m))
ImportProvidedType amap m (pi.PApply((fun pi -> nonNull<ProvidedType> pi.DeclaringType), m))
#endif
/// Get the enclosing type of the method info, using a nominal type for tuple types
@ -2112,7 +2112,7 @@ type EventInfo =
| ILEvent ileinfo -> ileinfo.ApparentEnclosingType
| FSEvent (_, p, _, _) -> p.ApparentEnclosingType
#if !NO_TYPEPROVIDERS
| ProvidedEvent (amap, ei, m) -> ImportProvidedType amap m (ei.PApply((fun ei -> ei.DeclaringType), m))
| ProvidedEvent (amap, ei, m) -> ImportProvidedType amap m (ei.PApply((fun ei -> nonNull<ProvidedType> ei.DeclaringType), m))
#endif
/// Get the enclosing type of the method info, using a nominal type for tuple types

Просмотреть файл

@ -1006,7 +1006,7 @@ let convAlternativeDef
[ mkILParamNamed ("obj", altTy) ],
mkMethodBody (false, [], 3, debugProxyCode, None, imports)
))
.With(customAttrs = mkILCustomAttrs[GetDynamicDependencyAttribute g 0x660 baseTy])
.With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 baseTy ])
|> addMethodGeneratedAttrs
let debugProxyGetterMeths =
@ -1128,7 +1128,7 @@ let convAlternativeDef
let basicCtorMeth =
(mkILStorageCtor (basicCtorInstrs, altTy, basicCtorFields, basicCtorAccess, attr, imports))
.With(customAttrs = mkILCustomAttrs[GetDynamicDependencyAttribute g 0x660 baseTy])
.With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 baseTy ])
|> addMethodGeneratedAttrs
let altTypeDef =
@ -1261,7 +1261,7 @@ let mkClassUnionDef
cud.DebugPoint,
cud.DebugImports
))
.With(customAttrs = mkILCustomAttrs[GetDynamicDependencyAttribute g 0x660 baseTy])
.With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 baseTy ])
|> addMethodGeneratedAttrs
let props, meths =
@ -1319,7 +1319,7 @@ let mkClassUnionDef
cud.DebugPoint,
cud.DebugImports
))
.With(customAttrs = mkILCustomAttrs[GetDynamicDependencyAttribute g 0x7E0 baseTy])
.With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x7E0 baseTy ])
|> addMethodGeneratedAttrs
]

Просмотреть файл

@ -2065,7 +2065,7 @@ type AnonTypeGenerationTable() =
let ilCtorDef =
(mkILSimpleStorageCtorWithParamNames (ilBaseTySpec, ilTy, [], flds, ILMemberAccess.Public, None, None))
.With(customAttrs = mkILCustomAttrs[GetDynamicDependencyAttribute g 0x660 ilTy])
.With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 ilTy ])
// Create a tycon that looks exactly like a record definition, to help drive the generation of equality/comparison code
let m = range0
@ -11013,7 +11013,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
None,
eenv.imports
))
.With(customAttrs = mkILCustomAttrs[GetDynamicDependencyAttribute g 0x660 ilThisTy])
.With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 ilThisTy ])
yield ilMethodDef
// FSharp 1.0 bug 1988: Explicitly setting the ComVisible(true) attribute on an F# type causes an F# record to be emitted in a way that enables mutation for COM interop scenarios

Просмотреть файл

@ -3487,7 +3487,7 @@ type FsiStdinLexerProvider
IndentationAwareSyntaxStatus(initialIndentationAwareSyntaxStatus, warn = false)
let LexbufFromLineReader (fsiStdinSyphon: FsiStdinSyphon) readF =
let LexbufFromLineReader (fsiStdinSyphon: FsiStdinSyphon) (readF: unit -> string MaybeNull) =
UnicodeLexing.FunctionAsLexbuf(
true,
tcConfigB.langVersion,
@ -3499,7 +3499,11 @@ type FsiStdinLexerProvider
with :? EndOfStreamException ->
None
inputOption |> Option.iter (fun t -> fsiStdinSyphon.Add(t + "\n"))
inputOption
|> Option.iter (fun t ->
match t with
| Null -> ()
| NonNull t -> fsiStdinSyphon.Add(t + "\n"))
match inputOption with
| Some null
@ -3526,11 +3530,14 @@ type FsiStdinLexerProvider
// Reading stdin as a lex stream
//----------------------------------------------------------------------------
let removeZeroCharsFromString (str: string) =
if str <> null && str.Contains("\000") then
String(str |> Seq.filter (fun c -> c <> '\000') |> Seq.toArray)
else
str
let removeZeroCharsFromString (str: string MaybeNull) : string MaybeNull =
match str with
| Null -> str
| NonNull str ->
if str.Contains("\000") then
String(str |> Seq.filter (fun c -> c <> '\000') |> Seq.toArray)
else
str
let CreateLexerForLexBuffer (sourceFileName, lexbuf, diagnosticsLogger) =

Просмотреть файл

@ -78,7 +78,7 @@ module QuickParse =
| true, _, true when name.Length > 2 -> isValidStrippedName (name.AsSpan(1, name.Length - 2)) 0
| _ -> false
let GetCompleteIdentifierIslandImpl (lineStr: string) (index: int) : (string * int * bool) option =
let GetCompleteIdentifierIslandImplAux (lineStr: string) (index: int) : (string * int * bool) option =
if index < 0 || isNull lineStr || index >= lineStr.Length then
None
else
@ -172,6 +172,11 @@ module QuickParse =
let pos = r + MagicalAdjustmentConstant
Some(ident, pos, false))
let GetCompleteIdentifierIslandImpl (lineStr: string MaybeNull) (index: int) : (string * int * bool) option =
match lineStr with
| Null -> None
| NonNull lineStr -> GetCompleteIdentifierIslandImplAux lineStr index
/// Given a string and a position in that string, find an identifier as
/// expected by `GotoDefinition`. This will work when the cursor is
/// immediately before the identifier, within the identifier, or immediately
@ -209,10 +214,8 @@ module QuickParse =
let private defaultName = [], ""
/// Get the partial long name of the identifier to the left of index.
let GetPartialLongName (lineStr: string, index: int) =
if isNull lineStr then
defaultName
elif index < 0 then
let GetPartialLongNameAux (lineStr: string, index: int) =
if index < 0 then
defaultName
elif index >= lineStr.Length then
defaultName
@ -263,16 +266,19 @@ module QuickParse =
let result = InResidue(index, index)
result
let GetPartialLongName (lineStr: string MaybeNull, index: int) =
match lineStr with
| Null -> defaultName
| NonNull lineStr -> GetPartialLongNameAux(lineStr, index)
type private EatCommentCallContext =
| SkipWhiteSpaces of ident: string * current: string list * throwAwayNext: bool
| StartIdentifier of current: string list * throwAway: bool
/// Get the partial long name of the identifier to the left of index.
/// For example, for `System.DateTime.Now` it returns PartialLongName ([|"System"; "DateTime"|], "Now", Some 32), where "32" pos of the last dot.
let GetPartialLongNameEx (lineStr: string, index: int) : PartialLongName =
if isNull lineStr then
PartialLongName.Empty(index)
elif index < 0 then
let GetPartialLongNameExAux (lineStr: string, index: int) : PartialLongName =
if index < 0 then
PartialLongName.Empty(index)
elif index >= lineStr.Length then
PartialLongName.Empty(index)
@ -415,6 +421,11 @@ module QuickParse =
QualifyingIdents = plid
}
let GetPartialLongNameEx (lineStr: string MaybeNull, index: int) : PartialLongName =
match lineStr with
| Null -> PartialLongName.Empty(index)
| NonNull lineStr -> GetPartialLongNameExAux(lineStr, index)
let TokenNameEquals (tokenInfo: FSharpTokenInfo) (token2: string) =
String.Compare(tokenInfo.TokenName, token2, StringComparison.OrdinalIgnoreCase) = 0

Просмотреть файл

@ -1093,6 +1093,7 @@ let GetLongNameFromString x = SplitNamesForILPath x
// Uncompressed OptimizationData/SignatureData name for embedded resource
let FSharpOptimizationDataResourceName = "FSharpOptimizationData."
let FSharpSignatureDataResourceName = "FSharpSignatureData."
// Compressed OptimizationData/SignatureData name for embedded resource

Просмотреть файл

@ -90,21 +90,6 @@ module FSharpLib =
// Access the initial environment: helpers to build references
//-------------------------------------------------------------------------
// empty flags
let v_knownWithoutNull = 0uy
let private mkNonGenericTy tcref = TType_app(tcref, [], v_knownWithoutNull)
let mkNonLocalTyconRef2 ccu path n = mkNonLocalTyconRef (mkNonLocalEntityRef ccu path) n
let mk_MFCore_tcref ccu n = mkNonLocalTyconRef2 ccu CorePathArray n
let mk_MFQuotations_tcref ccu n = mkNonLocalTyconRef2 ccu QuotationsPath n
let mk_MFLinq_tcref ccu n = mkNonLocalTyconRef2 ccu LinqPathArray n
let mk_MFCollections_tcref ccu n = mkNonLocalTyconRef2 ccu CollectionsPathArray n
let mk_MFCompilerServices_tcref ccu n = mkNonLocalTyconRef2 ccu CompilerServicesPath n
let mk_MFRuntimeHelpers_tcref ccu n = mkNonLocalTyconRef2 ccu RuntimeHelpersPath n
let mk_MFControl_tcref ccu n = mkNonLocalTyconRef2 ccu ControlPathArray n
type
[<NoEquality; NoComparison; StructuredFormatDisplay("{DebugText}")>]
BuiltinAttribInfo =
@ -208,6 +193,21 @@ type TcGlobals(
pathMap: PathMap,
langVersion: LanguageVersion) =
// empty flags
let v_knownWithoutNull = 0uy
let mkNonGenericTy tcref = TType_app(tcref, [], v_knownWithoutNull)
let mkNonLocalTyconRef2 ccu path n = mkNonLocalTyconRef (mkNonLocalEntityRef ccu path) n
let mk_MFCore_tcref ccu n = mkNonLocalTyconRef2 ccu CorePathArray n
let mk_MFQuotations_tcref ccu n = mkNonLocalTyconRef2 ccu QuotationsPath n
let mk_MFLinq_tcref ccu n = mkNonLocalTyconRef2 ccu LinqPathArray n
let mk_MFCollections_tcref ccu n = mkNonLocalTyconRef2 ccu CollectionsPathArray n
let mk_MFCompilerServices_tcref ccu n = mkNonLocalTyconRef2 ccu CompilerServicesPath n
let mk_MFRuntimeHelpers_tcref ccu n = mkNonLocalTyconRef2 ccu RuntimeHelpersPath n
let mk_MFControl_tcref ccu n = mkNonLocalTyconRef2 ccu ControlPathArray n
let tryFindSysTypeCcu path nm =
tryFindSysTypeCcuHelper path nm false

Просмотреть файл

@ -230,9 +230,10 @@ let TryTypeMemberArray (st: Tainted<_>, fullName, memberName, m, f) =
let TryTypeMemberNonNull<'T, 'U when 'U : null and 'U : not struct>(st: Tainted<'T>, fullName, memberName, m, recover: 'U, (f: 'T -> 'U)) : Tainted<'U> =
match TryTypeMember(st, fullName, memberName, m, recover, f) with
| Tainted.Null ->
errorR(Error(FSComp.SR.etUnexpectedNullFromProvidedTypeMember(fullName, memberName), m));
errorR(Error(FSComp.SR.etUnexpectedNullFromProvidedTypeMember(fullName, memberName), m))
st.PApplyNoFailure(fun _ -> recover)
| Tainted.NonNull r -> r
| Tainted.NonNull r ->
r
/// Try to access a property or method on a provided member, catching and reporting errors
let TryMemberMember (mi: Tainted<_>, typeName, memberName, memberMemberName, m, recover, f) =
@ -346,7 +347,7 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) =
x.CustomAttributes
|> Seq.exists (fun a -> a.Constructor.DeclaringType.FullName = typeof<MeasureAttribute>.FullName)
let provide () = ProvidedCustomAttributeProvider (fun _provider -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
let provide () = ProvidedCustomAttributeProvider (fun _ -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
interface IProvidedCustomAttributeProvider with
member _.GetHasTypeProviderEditorHideMethodsAttribute provider = provide().GetHasTypeProviderEditorHideMethodsAttribute provider
@ -366,13 +367,13 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) =
member _.IsGenericType = x.IsGenericType
member _.Namespace = x.Namespace
member _.Namespace : string MaybeNull = x.Namespace
member _.FullName = x.FullName
member _.IsArray = x.IsArray
member _.Assembly: ProvidedAssembly = x.Assembly |> ProvidedAssembly.Create
member _.Assembly: ProvidedAssembly MaybeNull = x.Assembly |> ProvidedAssembly.Create
member _.GetInterfaces() = x.GetInterfaces() |> ProvidedType.CreateArray ctxt
@ -546,7 +547,7 @@ type ProvidedCustomAttributeProvider (attributes :ITypeProvider -> seq<CustomAtt
[<AllowNullLiteral; AbstractClass>]
type ProvidedMemberInfo (x: MemberInfo, ctxt) =
let provide () = ProvidedCustomAttributeProvider (fun _provider -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
let provide () = ProvidedCustomAttributeProvider (fun _ -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
member _.Name = x.Name
@ -568,7 +569,7 @@ type ProvidedMemberInfo (x: MemberInfo, ctxt) =
[<AllowNullLiteral; Sealed>]
type ProvidedParameterInfo (x: ParameterInfo, ctxt) =
let provide () = ProvidedCustomAttributeProvider (fun _provider -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
let provide () = ProvidedCustomAttributeProvider (fun _ -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
member _.Name = x.Name

Просмотреть файл

@ -754,11 +754,10 @@ let pickleObjWithDanglingCcus inMem file g scope p x =
st2
st2.os
let finalBytes = phase2bytes
(st1.os :> System.IDisposable).Dispose()
finalBytes
phase2bytes
let check (ilscope: ILScopeRef) (inMap : NodeInTable<_, _>) =
let check (ilscope: ILScopeRef) (inMap: NodeInTable<_, _>) =
for i = 0 to inMap.Count - 1 do
let n = inMap.Get i
if not (inMap.IsLinked n) then
@ -1661,16 +1660,20 @@ let _ = fill_p_ty2 (fun isStructThisArgPos ty st ->
p_ty2 isStructThisArgPos r st
| TType_measure unt ->
p_byte 6 st; p_measure_expr unt st
p_byte 6 st
p_measure_expr unt st
| TType_ucase (uc, tinst) ->
p_byte 7 st; p_tup2 p_ucref p_tys (uc, tinst) st
p_byte 7 st
p_ucref uc st
p_tys tinst st
// p_byte 8 taken by TType_tuple above
| TType_anon (anonInfo, l) ->
p_byte 9 st
p_anonInfo anonInfo st
p_tys l st)
p_tys l st
)
let _ = fill_u_ty (fun st ->
let tag = u_byte st

Просмотреть файл

@ -886,6 +886,8 @@ type internal ByteStream =
max: int
}
member b.IsEOF = (b.pos >= b.max)
member b.ReadByte() =
if b.pos >= b.max then
failwith "end of stream"

Просмотреть файл

@ -334,16 +334,27 @@ type internal ByteMemory with
/// Creates a ByteMemory object that is backed by a byte array.
static member FromArray: bytes: byte[] -> ByteMemory
/// Gets a ByteMemory object that is empty
static member Empty: ByteMemory
[<Sealed>]
type internal ByteStream =
member IsEOF: bool
member ReadByte: unit -> byte
member ReadBytes: int -> ReadOnlyByteMemory
member ReadUtf8String: int -> string
member Position: int
static member FromBytes: ReadOnlyByteMemory * start: int * length: int -> ByteStream
#if LAZY_UNPICKLE
member CloneAndSeek: int -> ByteStream
member Skip: int -> unit
#endif

Просмотреть файл

@ -80,8 +80,8 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value: not struct>(keepStron
| Weak (weakReference) ->
#if FX_NO_GENERIC_WEAKREFERENCE
match weakReference.Target with
| null -> ()
| value -> yield key, (value :?> 'Value)
| Null -> ()
| NonNull value -> yield key, (value :?> 'Value)
]
#else
match weakReference.TryGetTarget() with

Просмотреть файл

@ -128,14 +128,14 @@ type InlineDelayInit<'T when 'T: not struct> =
}
val mutable store: 'T
val mutable func: Func<'T>
val mutable func: Func<'T> MaybeNull
member x.Value =
match x.func with
| null -> x.store
| _ ->
let res = LazyInitializer.EnsureInitialized(&x.store, x.func)
x.func <- Unchecked.defaultof<_>
x.func <- null
res
//-------------------------------------------------------------------------
@ -182,7 +182,7 @@ module Array =
Array.length l1 = Array.length l2 && Array.forall2 p l1 l2
let order (eltOrder: IComparer<'T>) =
{ new IComparer<array<'T>> with
{ new IComparer<'T array> with
member _.Compare(xs, ys) =
let c = compare xs.Length ys.Length

Просмотреть файл

@ -26,8 +26,8 @@ module internal PervasiveAutoOpens =
/// Returns true if the argument is non-null.
val inline isNotNull: x: 'T -> bool when 'T: null
/// Indicates that a type may be null. 'MaybeNull<string>' used internally in the F# compiler as unchecked
/// replacement for 'string?' for example for future FS-1060.
/// Indicates that a type may be null. 'MaybeNull<string>' is used internally in the F# compiler as
/// replacement for 'string?' to align with FS-1060.
type 'T MaybeNull when 'T: null and 'T: not struct = 'T
/// Asserts the argument is non-null and raises an exception if it is

Просмотреть файл

@ -26,7 +26,10 @@ let isEnvVarSet s =
let GetEnvInteger e dflt = match Environment.GetEnvironmentVariable(e) with null -> dflt | t -> try int t with _ -> dflt
let dispose (x:IDisposable) = match x with null -> () | x -> x.Dispose()
let dispose (x: IDisposable MaybeNull) =
match x with
| Null -> ()
| NonNull x -> x.Dispose()
//-------------------------------------------------------------------------
// Library: bits
@ -329,16 +332,9 @@ type Graph<'Data, 'Id when 'Id : comparison and 'Id : equality>
// with care.
//----------------------------------------------------------------------------
// The following DEBUG code does not currently compile.
//#if DEBUG
//type 'T NonNullSlot = 'T option
//let nullableSlotEmpty() = None
//let nullableSlotFull(x) = Some x
//#else
type NonNullSlot<'T> = 'T
let nullableSlotEmpty() = Unchecked.defaultof<'T>
let nullableSlotFull x = x
//#endif
//---------------------------------------------------------------------------
// Caches, mainly for free variables

Просмотреть файл

@ -692,7 +692,7 @@ module Array =
// - when the predicate yields consecutive runs of true data that is >= 32 elements (and fall
// into maskArray buckets) are copied in chunks using System.Array.Copy
module Filter =
let private populateMask<'a> (f: 'a -> bool) (src: array<'a>) (maskArray: array<uint32>) =
let private populateMask<'a> (f: 'a -> bool) (src: 'a array) (maskArray: uint32 array) =
let mutable count = 0
for maskIdx = 0 to maskArray.Length - 1 do
@ -833,8 +833,8 @@ module Array =
let private createMask<'a>
(f: 'a -> bool)
(src: array<'a>)
(maskArrayOut: byref<array<uint32>>)
(src: 'a array)
(maskArrayOut: byref<uint32 array>)
(leftoverMaskOut: byref<uint32>)
=
let maskArrayLength = src.Length / 0x20
@ -842,7 +842,7 @@ module Array =
// null when there are less than 32 items in src array.
let maskArray =
if maskArrayLength = 0 then
Unchecked.defaultof<_>
null
else
Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked<uint32> maskArrayLength
@ -871,7 +871,7 @@ module Array =
leftoverMaskOut <- leftoverMask
count
let private populateDstViaMask<'a> (src: array<'a>) (maskArray: array<uint32>) (dst: array<'a>) =
let private populateDstViaMask<'a> (src: 'a array) (maskArray: uint32 array) (dst: 'a array) =
let mutable dstIdx = 0
let mutable batchCount = 0
@ -1026,7 +1026,7 @@ module Array =
dstIdx
let private filterViaMask (maskArray: array<uint32>) (leftoverMask: uint32) (count: int) (src: array<_>) =
let private filterViaMask (maskArray: uint32 array) (leftoverMask: uint32) (count: int) (src: _ array) =
let dst = Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked count
let mutable dstIdx = 0
@ -1049,7 +1049,7 @@ module Array =
dst
let filter f (src: array<_>) =
let filter f (src: _ array) =
let mutable maskArray = Unchecked.defaultof<_>
let mutable leftOverMask = Unchecked.defaultof<_>

Просмотреть файл

@ -522,7 +522,7 @@ module internal List =
loop 0 l
res
let ofArray (arr:'T[]) =
let ofArray (arr:'T array) =
let mutable res = ([]: 'T list)
for i = arr.Length-1 downto 0 do
res <- arr.[i] :: res
@ -531,7 +531,7 @@ module internal List =
let inline ofSeq (e : IEnumerable<'T>) =
match e with
| :? ('T list) as l -> l
| :? ('T[]) as arr -> ofArray arr
| :? ('T array) as arr -> ofArray arr
| _ ->
use ie = e.GetEnumerator()
if not (ie.MoveNext()) then []
@ -998,35 +998,35 @@ module internal Array =
let inline indexNotFound() = raise (KeyNotFoundException(SR.GetString(SR.keyNotFoundAlt)))
let findBack predicate (array: _[]) =
let findBack predicate (array: _ array) =
let rec loop i =
if i < 0 then indexNotFound()
elif predicate array.[i] then array.[i]
else loop (i - 1)
loop (array.Length - 1)
let tryFindBack predicate (array: _[]) =
let tryFindBack predicate (array: _ array) =
let rec loop i =
if i < 0 then None
elif predicate array.[i] then Some array.[i]
else loop (i - 1)
loop (array.Length - 1)
let findIndexBack predicate (array: _[]) =
let findIndexBack predicate (array: _ array) =
let rec loop i =
if i < 0 then indexNotFound()
elif predicate array.[i] then i
else loop (i - 1)
loop (array.Length - 1)
let tryFindIndexBack predicate (array: _[]) =
let tryFindIndexBack predicate (array: _ array) =
let rec loop i =
if i < 0 then None
elif predicate array.[i] then Some i
else loop (i - 1)
loop (array.Length - 1)
let permute indexMap (arr : _[]) =
let permute indexMap (arr : _ array) =
let res = zeroCreateUnchecked arr.Length
let inv = zeroCreateUnchecked arr.Length
for i = 0 to arr.Length - 1 do
@ -1038,7 +1038,7 @@ module internal Array =
if inv.[i] <> 1uy then invalidArg "indexMap" (SR.GetString(SR.notAPermutation))
res
let mapFold f acc (array : _[]) =
let mapFold f acc (array: _ array) =
match array.Length with
| 0 -> [| |], acc
| len ->
@ -1051,7 +1051,7 @@ module internal Array =
acc <- s'
res, acc
let mapFoldBack f (array : _[]) acc =
let mapFoldBack f (array: _ array) acc =
match array.Length with
| 0 -> [| |], acc
| len ->
@ -1064,7 +1064,7 @@ module internal Array =
acc <- s'
res, acc
let scanSubRight f (array : _[]) start fin initState =
let scanSubRight f (array: _ array) start fin initState =
let f = OptimizedClosures.FSharpFunc<_, _, _>.Adapt(f)
let mutable state = initState
let res = zeroCreateUnchecked (fin-start+2)
@ -1074,7 +1074,7 @@ module internal Array =
res.[i - start] <- state
res
let unstableSortInPlaceBy (projection: 'T -> 'U) (array : array<'T>) =
let unstableSortInPlaceBy (projection: 'T -> 'U) (array: 'T array) =
let len = array.Length
if len > 1 then
let keys = zeroCreateUnchecked len
@ -1082,11 +1082,11 @@ module internal Array =
keys.[i] <- projection array.[i]
Array.Sort<_, _>(keys, array, fastComparerForArraySort())
let unstableSortInPlace (array : array<'T>) =
let unstableSortInPlace (array: 'T array) =
if array.Length > 1 then
Array.Sort<_>(array, fastComparerForArraySort())
let stableSortWithKeysAndComparer (cFast:IComparer<'Key>) (c:IComparer<'Key>) (array:array<'T>) (keys:array<'Key>) =
let stableSortWithKeysAndComparer (cFast:IComparer<'Key>) (c:IComparer<'Key>) (array:'T array) (keys: 'Key array) =
// 'places' is an array or integers storing the permutation performed by the sort
let len = array.Length
let places = zeroCreateUnchecked len
@ -1094,7 +1094,7 @@ module internal Array =
places.[i] <- i
System.Array.Sort<_, _>(keys, places, cFast)
// 'array2' is a copy of the original values
let array2 = (array.Clone() :?> array<'T>)
let array2 = (array.Clone() :?> 'T array)
// Walk through any chunks where the keys are equal
let mutable i = 0
@ -1112,12 +1112,12 @@ module internal Array =
Array.Sort<_, _>(places, array, i, j-i, intCompare)
i <- j
let stableSortWithKeys (array:array<'T>) (keys:array<'Key>) =
let stableSortWithKeys (array:'T array) (keys:'Key array) =
let cFast = fastComparerForArraySort()
let c = LanguagePrimitives.FastGenericComparer<'Key>
stableSortWithKeysAndComparer cFast c array keys
let stableSortInPlaceBy (projection: 'T -> 'U) (array : array<'T>) =
let stableSortInPlaceBy (projection: 'T -> 'U) (array: 'T array) =
let len = array.Length
if len > 1 then
// 'keys' is an array storing the projected keys
@ -1126,7 +1126,7 @@ module internal Array =
keys.[i] <- projection array.[i]
stableSortWithKeys array keys
let stableSortInPlace (array : array<'T>) =
let stableSortInPlace (array: 'T array) =
let len = array.Length
if len > 1 then
let cFast = LanguagePrimitives.FastGenericComparerCanBeNull<'T>
@ -1137,19 +1137,19 @@ module internal Array =
Array.Sort<_, _>(array, null)
| _ ->
// 'keys' is an array storing the projected keys
let keys = (array.Clone() :?> array<'T>)
let keys = (array.Clone() :?> 'T array)
stableSortWithKeys array keys
let stableSortInPlaceWith (comparer:'T -> 'T -> int) (array : array<'T>) =
let stableSortInPlaceWith (comparer:'T -> 'T -> int) (array: 'T array) =
let len = array.Length
if len > 1 then
let keys = (array.Clone() :?> array<'T>)
let keys = (array.Clone() :?> 'T array)
let comparer = OptimizedClosures.FSharpFunc<_, _, _>.Adapt(comparer)
let c = { new IComparer<'T> with member _.Compare(x, y) = comparer.Invoke(x, y) }
stableSortWithKeysAndComparer c c array keys
let inline subUnchecked startIndex count (array : 'T[]) =
let res = zeroCreateUnchecked count : 'T[]
let inline subUnchecked startIndex count (array: 'T array) =
let res = zeroCreateUnchecked count : 'T array
if count < 64 then
for i = 0 to res.Length-1 do
res.[i] <- array.[startIndex+i]
@ -1157,13 +1157,13 @@ module internal Array =
Array.Copy(array, startIndex, res, 0, count)
res
let splitInto count (array : 'T[]) =
let splitInto count (array: 'T array) =
let len = array.Length
if len = 0 then
[| |]
else
let count = min count len
let res = zeroCreateUnchecked count : 'T[][]
let res = zeroCreateUnchecked count : 'T array array
let minChunkSize = len / count
let mutable startIndex = 0
for i = 0 to len % count - 1 do
@ -1178,7 +1178,7 @@ module internal Seq =
let tryLastV (source : seq<_>) =
//checkNonNull "source" source //done in main Seq.tryLast
match source with
| :? ('T[]) as a ->
| :? ('T array) as a ->
if a.Length = 0 then ValueNone
else ValueSome(a.[a.Length - 1])

Просмотреть файл

@ -542,7 +542,7 @@ module MapTree =
else
acc
let ofArray comparer (arr: array<'Key * 'Value>) =
let ofArray comparer (arr: ('Key * 'Value) array) =
let mutable res = empty
for (x, y) in arr do

Просмотреть файл

@ -149,7 +149,6 @@ namespace ProviderImplementation.ProvidedTypes
/// Internal code of .NET expects the obj[] returned by GetCustomAttributes to be an Attribute[] even in the case of empty arrays
let emptyAttributes = (([| |]: Attribute[]) |> box |> unbox<obj[]>)
let nonNull str x = if isNull x then failwithf "Null in '%s', stacktrace = '%s'" str Environment.StackTrace else x
let nonNone str x = match x with None -> failwithf "No value has been specified for '%s', stacktrace = '%s'" str Environment.StackTrace | Some v -> v
let patchOption v f = match v with None -> f() | Some _ -> failwithf "Already patched, stacktrace = '%s'" Environment.StackTrace

Просмотреть файл

@ -180,7 +180,7 @@ let test_find () =
with _ -> true)
module Array =
let findIndexi f (array : array<_>) =
let findIndexi f (array : _ array) =
let len = array.Length
let rec go n =
if n >= len then
@ -191,7 +191,7 @@ module Array =
go (n+1)
go 0
let tryFindIndexi f (array : array<_>) =
let tryFindIndexi f (array : _ array) =
let len = array.Length
let rec go n = if n >= len then None elif f n array.[n] then Some n else go (n+1)
go 0

Просмотреть файл

@ -51,10 +51,10 @@ module ComparersRegression =
union (union (raw item)) |]
type Collection<'item, 'reftype, 'valuetype, 'uniontype> = {
Array : array<'item>
Array : 'item array
ToRefType : 'item -> 'reftype
ToValueType : 'item -> 'valuetype
ToUnionTypes : 'item -> array<'uniontype>
ToUnionTypes : 'item -> 'uniontype array
} with
member this.ValueWrapArray =
this.Array
@ -95,7 +95,7 @@ module ComparersRegression =
module Bools =
type TestType = bool
let Values : array<TestType> = [| true; false|]
let Values : TestType array = [| true; false|]
type RefType = {
Item : TestType
@ -132,7 +132,7 @@ module ComparersRegression =
module NullableBools =
type TestType = Nullable<bool>
let Values : array<TestType> = createNullables Bools.Values
let Values : TestType array = createNullables Bools.Values
type RefType = {
Item : TestType
@ -171,7 +171,7 @@ module ComparersRegression =
module SBytes =
type TestType = sbyte
let Values : array<TestType> = [| SByte.MinValue; SByte.MaxValue; -1y; 0y; +1y |]
let Values : TestType array = [| SByte.MinValue; SByte.MaxValue; -1y; 0y; +1y |]
type RefType = {
Item : TestType
@ -210,7 +210,7 @@ module ComparersRegression =
module NullableSbytes =
type TestType = Nullable<sbyte>
let Values : array<TestType> = createNullables SBytes.Values
let Values : TestType array = createNullables SBytes.Values
type RefType = {
Item : TestType
@ -249,7 +249,7 @@ module ComparersRegression =
module Int16s =
type TestType = int16
let Values : array<TestType> = [| Int16.MaxValue; Int16.MaxValue; -1s; 0s; +1s |]
let Values : TestType array = [| Int16.MaxValue; Int16.MaxValue; -1s; 0s; +1s |]
type RefType = {
Item : TestType
@ -288,7 +288,7 @@ module ComparersRegression =
module NullableInt16s =
type TestType = Nullable<int16>
let Values : array<TestType> = createNullables Int16s.Values
let Values : TestType array = createNullables Int16s.Values
type RefType = {
Item : TestType
@ -327,7 +327,7 @@ module ComparersRegression =
module Int32s =
type TestType = int32
let Values : array<TestType> = [| Int32.MinValue; Int32.MaxValue; -1; 0; +1 |]
let Values : TestType array = [| Int32.MinValue; Int32.MaxValue; -1; 0; +1 |]
type RefType = {
Item : TestType
@ -366,7 +366,7 @@ module ComparersRegression =
module NullableInt32s =
type TestType = Nullable<int32>
let Values : array<TestType> = createNullables Int32s.Values
let Values : TestType array = createNullables Int32s.Values
type RefType = {
Item : TestType
@ -405,7 +405,7 @@ module ComparersRegression =
module Int64s =
type TestType = int64
let Values : array<TestType> = [| Int64.MinValue; Int64.MaxValue; -1L; 0L; +1L |]
let Values : TestType array = [| Int64.MinValue; Int64.MaxValue; -1L; 0L; +1L |]
type RefType = {
Item : TestType
@ -444,7 +444,7 @@ module ComparersRegression =
module NullableInt64s =
type TestType = Nullable<int64>
let Values : array<TestType> = createNullables Int64s.Values
let Values : TestType array = createNullables Int64s.Values
type RefType = {
Item : TestType
@ -483,7 +483,7 @@ module ComparersRegression =
module NativeInts =
type TestType = nativeint
let Values : array<TestType> = [| -1n; 0n; +1n |]
let Values : TestType array = [| -1n; 0n; +1n |]
type RefType = {
Item : TestType
@ -522,7 +522,7 @@ module ComparersRegression =
module NullableNativeInts =
type TestType = Nullable<nativeint>
let Values : array<TestType> = createNullables NativeInts.Values
let Values : TestType array = createNullables NativeInts.Values
type RefType = {
Item : TestType
@ -561,7 +561,7 @@ module ComparersRegression =
module Bytes =
type TestType = byte
let Values : array<TestType> = [| Byte.MinValue; Byte.MaxValue; 0uy; 1uy; 2uy |]
let Values : TestType array = [| Byte.MinValue; Byte.MaxValue; 0uy; 1uy; 2uy |]
type RefType = {
Item : TestType
@ -600,7 +600,7 @@ module ComparersRegression =
module NullableBytes =
type TestType = Nullable<byte>
let Values : array<TestType> = createNullables Bytes.Values
let Values : TestType array = createNullables Bytes.Values
type RefType = {
Item : TestType
@ -639,7 +639,7 @@ module ComparersRegression =
module Uint16s =
type TestType = uint16
let Values : array<TestType> = [| UInt16.MinValue; UInt16.MaxValue; 0us; 1us; 2us |]
let Values : TestType array = [| UInt16.MinValue; UInt16.MaxValue; 0us; 1us; 2us |]
type RefType = {
Item : TestType
@ -678,7 +678,7 @@ module ComparersRegression =
module NullableUInt16s =
type TestType = Nullable<uint16>
let Values : array<TestType> = createNullables Uint16s.Values
let Values : TestType array = createNullables Uint16s.Values
type RefType = {
Item : TestType
@ -717,7 +717,7 @@ module ComparersRegression =
module UInt32s =
type TestType = uint32
let Values : array<TestType> = [| UInt32.MinValue; UInt32.MaxValue; 0u; 1u; 2u|]
let Values : TestType array = [| UInt32.MinValue; UInt32.MaxValue; 0u; 1u; 2u|]
type RefType = {
Item : TestType
@ -756,7 +756,7 @@ module ComparersRegression =
module NullableUInt32s =
type TestType = Nullable<uint32>
let Values : array<TestType> = createNullables UInt32s.Values
let Values : TestType array = createNullables UInt32s.Values
type RefType = {
Item : TestType
@ -795,7 +795,7 @@ module ComparersRegression =
module UInt64s =
type TestType = uint64
let Values : array<TestType> = [| UInt64.MinValue; UInt64.MaxValue; 0UL; 1UL; 2UL|]
let Values : TestType array = [| UInt64.MinValue; UInt64.MaxValue; 0UL; 1UL; 2UL|]
type RefType = {
Item : TestType
@ -834,7 +834,7 @@ module ComparersRegression =
module NullableUInt64s =
type TestType = Nullable<uint64>
let Values : array<TestType> = createNullables UInt64s.Values
let Values : TestType array = createNullables UInt64s.Values
type RefType = {
Item : TestType
@ -873,7 +873,7 @@ module ComparersRegression =
module UNativeInts =
type TestType = unativeint
let Values : array<TestType> = [| 0un; 1un; 2un |]
let Values : TestType array = [| 0un; 1un; 2un |]
type RefType = {
Item : TestType
@ -912,7 +912,7 @@ module ComparersRegression =
module NullableUNativeInts =
type TestType = Nullable<unativeint>
let Values : array<TestType> = createNullables UNativeInts.Values
let Values : TestType array = createNullables UNativeInts.Values
type RefType = {
Item : TestType
@ -951,7 +951,7 @@ module ComparersRegression =
module Chars =
type TestType = char
let Values : array<TestType> = [| Char.MinValue; Char.MaxValue; '0'; '1'; '2' |]
let Values : TestType array = [| Char.MinValue; Char.MaxValue; '0'; '1'; '2' |]
type RefType = {
Item : TestType
@ -990,7 +990,7 @@ module ComparersRegression =
module NullableChars =
type TestType = Nullable<char>
let Values : array<TestType> = createNullables Chars.Values
let Values : TestType array = createNullables Chars.Values
type RefType = {
Item : TestType
@ -1029,7 +1029,7 @@ module ComparersRegression =
module Strings =
type TestType = string
let Values : array<TestType> = [| null; String.Empty; "Hello, world!"; String('\u0000', 3); "\u0061\u030a"; "\u00e5" |]
let Values : TestType array = [| null; String.Empty; "Hello, world!"; String('\u0000', 3); "\u0061\u030a"; "\u00e5" |]
type RefType = {
Item : TestType
@ -1068,7 +1068,7 @@ module ComparersRegression =
module Decimals =
type TestType = decimal
let Values : array<TestType> = [| Decimal.MinValue; Decimal.MaxValue; Decimal.MinusOne; Decimal.Zero; Decimal.One |]
let Values : TestType array = [| Decimal.MinValue; Decimal.MaxValue; Decimal.MinusOne; Decimal.Zero; Decimal.One |]
type RefType = {
Item : TestType
@ -1107,7 +1107,7 @@ module ComparersRegression =
module NullableDecimals =
type TestType = Nullable<decimal>
let Values : array<TestType> = createNullables Decimals.Values
let Values : TestType array = createNullables Decimals.Values
type RefType = {
Item : TestType
@ -1146,7 +1146,7 @@ module ComparersRegression =
module Floats =
type TestType = float
let Values : array<TestType> = [| Double.MinValue; Double.MaxValue; Double.Epsilon; Double.NaN; Double.NegativeInfinity; Double.PositiveInfinity; -1.; 0.; 1. |]
let Values : TestType array = [| Double.MinValue; Double.MaxValue; Double.Epsilon; Double.NaN; Double.NegativeInfinity; Double.PositiveInfinity; -1.; 0.; 1. |]
type RefType = {
Item : TestType
@ -1185,7 +1185,7 @@ module ComparersRegression =
module NullableFloats =
type TestType = Nullable<float>
let Values : array<TestType> = createNullables Floats.Values
let Values : TestType array = createNullables Floats.Values
type RefType = {
Item : TestType
@ -1224,7 +1224,7 @@ module ComparersRegression =
module Float32s =
type TestType = float32
let Values : array<TestType> = [| Single.MinValue; Single.MaxValue; Single.Epsilon; Single.NaN; Single.NegativeInfinity; Single.PositiveInfinity; -1.f; 0.f; 1.f |]
let Values : TestType array = [| Single.MinValue; Single.MaxValue; Single.Epsilon; Single.NaN; Single.NegativeInfinity; Single.PositiveInfinity; -1.f; 0.f; 1.f |]
type RefType = {
Item : TestType
@ -1263,7 +1263,7 @@ module ComparersRegression =
module NullableFloat32s =
type TestType = Nullable<float32>
let Values : array<TestType> = createNullables Float32s.Values
let Values : TestType array = createNullables Float32s.Values
type RefType = {
Item : TestType
@ -1302,7 +1302,7 @@ module ComparersRegression =
module DateTimes =
type TestType = System.DateTime
let Values : array<TestType> = [| DateTime.MinValue; DateTime.MaxValue; DateTime(2015, 10, 8, 5, 39, 23) |]
let Values : TestType array = [| DateTime.MinValue; DateTime.MaxValue; DateTime(2015, 10, 8, 5, 39, 23) |]
type RefType = {
Item : TestType
@ -1341,7 +1341,7 @@ module ComparersRegression =
module NullableDateTimes =
type TestType = Nullable<DateTime>
let Values : array<TestType> = createNullables DateTimes.Values
let Values : TestType array = createNullables DateTimes.Values
type RefType = {
Item : TestType
@ -1380,7 +1380,7 @@ module ComparersRegression =
module Tuple2s =
type TestType = float*float
let Values : array<TestType> = [| (nan, nan); (nan, 0.0); (0.0, nan); (0.0, 0.0) |]
let Values : TestType array = [| (nan, nan); (nan, 0.0); (0.0, nan); (0.0, 0.0) |]
type RefType = {
Item : TestType
@ -1418,7 +1418,7 @@ module ComparersRegression =
module Tuple3s =
type TestType = float*float*float
let Values : array<TestType> = [|
let Values : TestType array = [|
(nan, nan, nan); (nan, nan, 0.0); (nan, 0.0, nan); (nan, 0.0, 0.0);
(0.0, nan, nan); (0.0, nan, 0.0); (0.0, 0.0, nan); (0.0, 0.0, 0.0) |]
@ -1459,7 +1459,7 @@ module ComparersRegression =
module Tuple4s =
type TestType = float*float*float*float
let Values : array<TestType> = [|
let Values : TestType array = [|
(nan, nan, nan, nan); (nan, nan, nan, 0.0); (nan, nan, 0.0, nan); (nan, nan, 0.0, 0.0);
(nan, 0.0, nan, nan); (nan, 0.0, nan, 0.0); (nan, 0.0, 0.0, nan); (nan, 0.0, 0.0, 0.0);
(0.0, nan, nan, nan); (0.0, nan, nan, 0.0); (0.0, nan, 0.0, nan); (0.0, nan, 0.0, 0.0);
@ -1503,7 +1503,7 @@ module ComparersRegression =
module Tuple5s =
type TestType = float*float*float*float*float
let Values : array<TestType> = [|
let Values : TestType array = [|
(nan, nan, nan, nan, nan); (nan, nan, nan, nan, 0.0); (nan, nan, nan, 0.0, nan); (nan, nan, nan, 0.0, 0.0);
(nan, nan, 0.0, nan, nan); (nan, nan, 0.0, nan, 0.0); (nan, nan, 0.0, 0.0, nan); (nan, nan, 0.0, 0.0, 0.0);
(nan, 0.0, nan, nan, nan); (nan, 0.0, nan, nan, 0.0); (nan, 0.0, nan, 0.0, nan); (nan, 0.0, nan, 0.0, 0.0);
@ -1629,7 +1629,7 @@ module ComparersRegression =
static member N = noninlinable
module TestGenerationMethods =
let create<'a,'b when 'b : equality> name operation (f:IOperation<'a>) (items:array<'a>) =
let create<'a,'b when 'b : equality> name operation (f:IOperation<'a>) (items: 'a array) =
printf """ [<Fact>]
member _.``%s %s``() =
validate (%s) %s """ name operation name operation
@ -1643,7 +1643,7 @@ module ComparersRegression =
printf "%d" result)
printfn "\n |]\n"
let create_inequalities name (items:array<'a>) =
let create_inequalities name (items: 'a array) =
create name "C.I.equals" C.I.equals items
create name "C.I.equal" C.I.equal items
create name "C.I.not_equal" C.I.not_equal items
@ -1661,7 +1661,7 @@ module ComparersRegression =
create name "C.N.greater_than" C.N.greater_than items
create name "C.N.greater_or_equal" C.N.greater_or_equal items
let create_equalities name (items:array<'a>) =
let create_equalities name (items: 'a array) =
create name "E.I.equals" E.I.equals items
create name "E.I.equal" E.I.equal items
create name "E.I.not_equal" E.I.not_equal items
@ -1737,7 +1737,7 @@ module ComparersRegression =
create_tuples_tests "Tuple5s.Collection" Tuple5s.Collection
let validate (items:array<'a>) (f:IOperation<'a>) (expected:array<int>) =
let validate (items: 'a array) (f:IOperation<'a>) (expected: int array) =
try
make_result_set f items (Some expected) |> ignore
with

Просмотреть файл

@ -748,7 +748,7 @@ type ArrayModule() =
array
let checkFilter filter (array:array<_>) =
let checkFilter filter (array: _ array) =
let filtered = array |> filter (fun n -> n > 0)
let mutable idx = 0
@ -1588,7 +1588,7 @@ type ArrayModule() =
member this.``pairwise should not work on null``() =
CheckThrowsArgumentNullException(fun () -> Array.pairwise null |> ignore)
member private this.MapTester mapInt (mapString : (string -> int) -> array<string> -> array<int>) =
member private this.MapTester mapInt (mapString : (string -> int) -> string array -> int array) =
// empty array
let f x = x + 1
let result = mapInt f [| |]
@ -1635,11 +1635,11 @@ type ArrayModule() =
if result <> [| |] then Assert.Fail ()
// int array
let result : array<int*int> = mapiInt f [| 1..2 |]
let result : (int*int) array = mapiInt f [| 1..2 |]
if result <> [| (0,2); (1,3) |] then Assert.Fail ()
// string array
let result : array<int*int> = [| "a"; "aa"; "aaa" |] |> mapiString (fun i (s:string) -> i, s.Length)
let result : (int*int) array = [| "a"; "aa"; "aaa" |] |> mapiString (fun i (s:string) -> i, s.Length)
if result <> [| (0,1); (1,2); (2,3) |] then Assert.Fail ()
// null array

Просмотреть файл

@ -113,7 +113,7 @@ type SeqModule2() =
CheckThrowsArgumentException ( fun() -> Seq.last emptyArr)
// null Array
let nullArr: array<'a> = null
let nullArr: 'a array = null
CheckThrowsArgumentNullException (fun () ->Seq.last nullArr)
// ---- Test for IList -----
@ -185,7 +185,7 @@ type SeqModule2() =
Assert.True(emptyResult.IsNone)
// null Array
let nullArr:array<unit> = null
let nullArr: unit array = null
CheckThrowsArgumentNullException (fun () -> Seq.tryLast nullArr |> ignore)

Просмотреть файл

@ -260,11 +260,12 @@ module rec Compiler =
let private getWarnings diagnostics = diagnostics |> List.filter (fun e -> match e.Error with Warning _ -> true | _ -> false)
let private adjustRange (range: Range) (adjust: int) : Range =
{ range with
StartLine = range.StartLine - adjust
StartColumn = range.StartColumn + 1
EndLine = range.EndLine - adjust
EndColumn = range.EndColumn + 1 }
{
StartLine = range.StartLine - adjust
StartColumn = range.StartColumn + 1
EndLine = range.EndLine - adjust
EndColumn = range.EndColumn + 1
}
let FsxSourceCode source =
SourceCodeFileKind.Fsx({FileName="test.fsx"; SourceText=Some source})

Просмотреть файл

@ -191,7 +191,7 @@ module Array =
Array.length l1 = Array.length l2 && Array.forall2 p l1 l2
let order (eltOrder: IComparer<'T>) =
{ new IComparer<array<'T>> with
{ new IComparer<'T array> with
member _.Compare(xs, ys) =
let c = compare xs.Length ys.Length

Просмотреть файл

@ -191,7 +191,7 @@ module Array =
Array.length l1 = Array.length l2 && Array.forall2 p l1 l2
let order (eltOrder: IComparer<'T>) =
{ new IComparer<array<'T>> with
{ new IComparer<'T array> with
member _.Compare(xs, ys) =
let c = compare xs.Length ys.Length

Просмотреть файл

@ -180,7 +180,7 @@ let test_find () =
with _ -> true)
module Array =
let findIndexi f (array : array<_>) =
let findIndexi f (array : _ array) =
let len = array.Length
let rec go n =
if n >= len then
@ -191,7 +191,7 @@ module Array =
go (n+1)
go 0
let tryFindIndexi f (array : array<_>) =
let tryFindIndexi f (array : _ array) =
let len = array.Length
let rec go n = if n >= len then None elif f n array.[n] then Some n else go (n+1)
go 0

Просмотреть файл

@ -310,25 +310,25 @@ let f1 () : obj = 1
let f2 () : obj = if true then 1 else 3.0
module TestComputedListExpressionsAtList =
let x1 : list<int64> = [ yield 1 ]
let x2 : list<int64> = [ yield 1;
let x1 : int64 list = [ yield 1 ]
let x2 : int64 list = [ yield 1;
if true then yield 2L ]
let x3 : list<int64> = [ yield 1L;
let x3 : int64 list = [ yield 1L;
if true then yield 2 ]
let x4 : list<int64> = [ yield 1L;
let x4 : int64 list = [ yield 1L;
while false do yield 2 ]
let x5 : list<int64> = [ yield 1;
let x5 : int64 list = [ yield 1;
while false do yield 2L ]
let x6 : list<int64> = [ while false do yield 2L ]
let x7 : list<int64> = [ for i in 0 .. 10 do yield 2 ]
let x8 : list<int64> = [ yield 1L
let x6 : int64 list = [ while false do yield 2L ]
let x7 : int64 list = [ for i in 0 .. 10 do yield 2 ]
let x8 : int64 list = [ yield 1L
for i in 0 .. 10 do yield 2 ]
let x9 : list<int64> = [ yield 1
let x9 : int64 list = [ yield 1
for i in 0 .. 10 do yield 2L ]
let x10 : list<int64> = [ try yield 2 finally () ]
let x11 : list<int64> = [ yield 1L
let x10 : int64 list = [ try yield 2 finally () ]
let x11 : int64 list = [ yield 1L
try yield 2 finally () ]
let x12 : list<int64> = [ yield 1
let x12 : int64 list = [ yield 1
try yield 2L finally () ]
module TestComputedListExpressionsAtSeq =
@ -365,25 +365,25 @@ module TestComputedListExpressionsAtSeq =
try yield 2L finally () ]
module TestComputedArrayExpressionsAtArray =
let x1 : array<int64> = [| yield 1 |]
let x2 : array<int64> = [| yield 1;
let x1 : int64 array = [| yield 1 |]
let x2 : int64 array = [| yield 1;
if true then yield 2L |]
let x3 : array<int64> = [| yield 1L;
let x3 : int64 array = [| yield 1L;
if true then yield 2 |]
let x4 : array<int64> = [| yield 1L;
let x4 : int64 array = [| yield 1L;
while false do yield 2 |]
let x5 : array<int64> = [| yield 1;
let x5 : int64 array = [| yield 1;
while false do yield 2L |]
let x6 : array<int64> = [| while false do yield 2L |]
let x7 : array<int64> = [| for i in 0 .. 10 do yield 2 |]
let x8 : array<int64> = [| yield 1L
let x6 : int64 array = [| while false do yield 2L |]
let x7 : int64 array = [| for i in 0 .. 10 do yield 2 |]
let x8 : int64 array = [| yield 1L
for i in 0 .. 10 do yield 2 |]
let x9 : array<int64> = [| yield 1
let x9 : int64 array = [| yield 1
for i in 0 .. 10 do yield 2L |]
let x10 : array<int64> = [| try yield 2 finally () |]
let x11 : array<int64> = [| yield 1L
let x10 : int64 array = [| try yield 2 finally () |]
let x11 : int64 array = [| yield 1L
try yield 2 finally () |]
let x12 : array<int64> = [| yield 1
let x12 : int64 array = [| yield 1
try yield 2L finally () |]
module TestComputedArrayExpressionsAtSeq =

Просмотреть файл

@ -310,25 +310,25 @@ let f1 () : obj = 1
let f2 () : obj = if true then 1 else 3.0
module TestComputedListExpressionsAtList =
let x1 : list<int64> = [ yield 1 ]
let x2 : list<int64> = [ yield 1;
let x1 : int64 list = [ yield 1 ]
let x2 : int64 list = [ yield 1;
if true then yield 2L ]
let x3 : list<int64> = [ yield 1L;
let x3 : int64 list = [ yield 1L;
if true then yield 2 ]
let x4 : list<int64> = [ yield 1L;
let x4 : int64 list = [ yield 1L;
while false do yield 2 ]
let x5 : list<int64> = [ yield 1;
let x5 : int64 list = [ yield 1;
while false do yield 2L ]
let x6 : list<int64> = [ while false do yield 2L ]
let x7 : list<int64> = [ for i in 0 .. 10 do yield 2 ]
let x8 : list<int64> = [ yield 1L
let x6 : int64 list = [ while false do yield 2L ]
let x7 : int64 list = [ for i in 0 .. 10 do yield 2 ]
let x8 : int64 list = [ yield 1L
for i in 0 .. 10 do yield 2 ]
let x9 : list<int64> = [ yield 1
let x9 : int64 list = [ yield 1
for i in 0 .. 10 do yield 2L ]
let x10 : list<int64> = [ try yield 2 finally () ]
let x11 : list<int64> = [ yield 1L
let x10 : int64 list = [ try yield 2 finally () ]
let x11 : int64 list = [ yield 1L
try yield 2 finally () ]
let x12 : list<int64> = [ yield 1
let x12 : int64 list = [ yield 1
try yield 2L finally () ]
module TestComputedListExpressionsAtSeq =
@ -365,25 +365,25 @@ module TestComputedListExpressionsAtSeq =
try yield 2L finally () ]
module TestComputedArrayExpressionsAtArray =
let x1 : array<int64> = [| yield 1 |]
let x2 : array<int64> = [| yield 1;
let x1 : int64 array = [| yield 1 |]
let x2 : int64 array = [| yield 1;
if true then yield 2L |]
let x3 : array<int64> = [| yield 1L;
let x3 : int64 array = [| yield 1L;
if true then yield 2 |]
let x4 : array<int64> = [| yield 1L;
let x4 : int64 array = [| yield 1L;
while false do yield 2 |]
let x5 : array<int64> = [| yield 1;
let x5 : int64 array = [| yield 1;
while false do yield 2L |]
let x6 : array<int64> = [| while false do yield 2L |]
let x7 : array<int64> = [| for i in 0 .. 10 do yield 2 |]
let x8 : array<int64> = [| yield 1L
let x6 : int64 array = [| while false do yield 2L |]
let x7 : int64 array = [| for i in 0 .. 10 do yield 2 |]
let x8 : int64 array = [| yield 1L
for i in 0 .. 10 do yield 2 |]
let x9 : array<int64> = [| yield 1
let x9 : int64 array = [| yield 1
for i in 0 .. 10 do yield 2L |]
let x10 : array<int64> = [| try yield 2 finally () |]
let x11 : array<int64> = [| yield 1L
let x10 : int64 array = [| try yield 2 finally () |]
let x11 : int64 array = [| yield 1L
try yield 2 finally () |]
let x12 : array<int64> = [| yield 1
let x12 : int64 array = [| yield 1
try yield 2L finally () |]
module TestComputedArrayExpressionsAtSeq =

Просмотреть файл

@ -310,25 +310,25 @@ let f1 () : obj = 1
let f2 () : obj = if true then 1 else 3.0
module TestComputedListExpressionsAtList =
let x1 : list<int64> = [ yield 1 ]
let x2 : list<int64> = [ yield 1;
let x1 : int64 list = [ yield 1 ]
let x2 : int64 list = [ yield 1;
if true then yield 2L ]
let x3 : list<int64> = [ yield 1L;
let x3 : int64 list = [ yield 1L;
if true then yield 2 ]
let x4 : list<int64> = [ yield 1L;
let x4 : int64 list = [ yield 1L;
while false do yield 2 ]
let x5 : list<int64> = [ yield 1;
let x5 : int64 list = [ yield 1;
while false do yield 2L ]
let x6 : list<int64> = [ while false do yield 2L ]
let x7 : list<int64> = [ for i in 0 .. 10 do yield 2 ]
let x8 : list<int64> = [ yield 1L
let x6 : int64 list = [ while false do yield 2L ]
let x7 : int64 list = [ for i in 0 .. 10 do yield 2 ]
let x8 : int64 list = [ yield 1L
for i in 0 .. 10 do yield 2 ]
let x9 : list<int64> = [ yield 1
let x9 : int64 list = [ yield 1
for i in 0 .. 10 do yield 2L ]
let x10 : list<int64> = [ try yield 2 finally () ]
let x11 : list<int64> = [ yield 1L
let x10 : int64 list = [ try yield 2 finally () ]
let x11 : int64 list = [ yield 1L
try yield 2 finally () ]
let x12 : list<int64> = [ yield 1
let x12 : int64 list = [ yield 1
try yield 2L finally () ]
module TestComputedListExpressionsAtSeq =
@ -365,25 +365,25 @@ module TestComputedListExpressionsAtSeq =
try yield 2L finally () ]
module TestComputedArrayExpressionsAtArray =
let x1 : array<int64> = [| yield 1 |]
let x2 : array<int64> = [| yield 1;
let x1 : int64 array = [| yield 1 |]
let x2 : int64 array = [| yield 1;
if true then yield 2L |]
let x3 : array<int64> = [| yield 1L;
let x3 : int64 array = [| yield 1L;
if true then yield 2 |]
let x4 : array<int64> = [| yield 1L;
let x4 : int64 array = [| yield 1L;
while false do yield 2 |]
let x5 : array<int64> = [| yield 1;
let x5 : int64 array = [| yield 1;
while false do yield 2L |]
let x6 : array<int64> = [| while false do yield 2L |]
let x7 : array<int64> = [| for i in 0 .. 10 do yield 2 |]
let x8 : array<int64> = [| yield 1L
let x6 : int64 array = [| while false do yield 2L |]
let x7 : int64 array = [| for i in 0 .. 10 do yield 2 |]
let x8 : int64 array = [| yield 1L
for i in 0 .. 10 do yield 2 |]
let x9 : array<int64> = [| yield 1
let x9 : int64 array = [| yield 1
for i in 0 .. 10 do yield 2L |]
let x10 : array<int64> = [| try yield 2 finally () |]
let x11 : array<int64> = [| yield 1L
let x10 : int64 array = [| try yield 2 finally () |]
let x11 : int64 array = [| yield 1L
try yield 2 finally () |]
let x12 : array<int64> = [| yield 1
let x12 : int64 array = [| yield 1
try yield 2L finally () |]
module TestComputedArrayExpressionsAtSeq =

Просмотреть файл

@ -104,7 +104,7 @@ module ByrefNegativeTests =
let test1 () =
let aggregator =
new ConcurrentDictionary<
string, ConcurrentDictionary<string,array<float>>
string, ConcurrentDictionary<string, float array>
>()
for kvp in aggregator do

Просмотреть файл

@ -31,8 +31,8 @@ test "line number test" (__LINE__ = "100")
test "line number test" (__LINE__ = "102")
test "line number test" (__SOURCE_FILE__ = "file.fs")
# 29 "original-test-file.fs"
test "line number test" (__LINE__ = "29")
# 35 "original-test-file.fs"
test "line number test" (__LINE__ = "35")
test "line number test" (__SOURCE_FILE__ = "original-test-file.fs")

Просмотреть файл

@ -32,13 +32,13 @@ module BasicAnalysisTests =
let rec infiniteLoop2 (x1:int) (x2:int) : int = infiniteLoop2 x1 x2
let callGenericInfiniteLoop (x:'a) : 'a = genericInfiniteLoop x
let rec loopViaModuleFunction1 (f: 'T -> bool) (arr:array<'T>) i =
let rec loopViaModuleFunction1 (f: 'T -> bool) (arr: 'T array) i =
loopViaModuleFunction1 f arr (i+1)
let rec loopViaModuleFunction (f: 'T -> bool) (arr:array<'T>) i =
let rec loopViaModuleFunction (f: 'T -> bool) (arr: 'T array) i =
i >= arr.Length || (f arr.[i] && loopViaModuleFunction f arr (i+1))
let loopViaInnerFunction (f: 'T -> bool) (array:array<'T>) =
let loopViaInnerFunction (f: 'T -> bool) (array: 'T array) =
let len = array.Length
let rec loop i = i >= len || (f array.[i] && loop (i+1))
loop 0

Просмотреть файл

@ -7,13 +7,13 @@
[<AbstractClass>]
type BaseHashtable<'Entry, 'Key>(initialCapacity) =
abstract member Next : entries : array<'Entry> -> int
abstract member Next : entries : 'Entry array -> int
[<Struct>]
type StrongToWeakEntry<'Value when 'Value : not struct> =
val mutable public next : int
let f() = { new BaseHashtable<_,_>(2) with
override this.Next (entries:array<StrongToWeakEntry<_>>) = 1
override this.Next (entries:StrongToWeakEntry<_> array) = 1
override this.Next entries = 1
}

Просмотреть файл

@ -22,11 +22,11 @@ type T4() =
inherit CSLib5.B1()
override x.M(i : int) = 2 // ERROR {expected}
//<Expects status="error" span="(9,16-9,17)" id="FS3070">Cannot override inherited member 'B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(15,16-15,17)" id="FS3070">Cannot override inherited member 'B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(19,16-19,17)" id="FS3070">Cannot override inherited member 'B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(9,16-9,17)" id="FS3070">Cannot override inherited member 'CSLib.B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(15,16-15,17)" id="FS3070">Cannot override inherited member 'CSLib2.B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(19,16-19,17)" id="FS3070">Cannot override inherited member 'CSLib4.B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(21,6-21,8)" id="FS0365">No implementation was given for those members:</Expects>
//<Expects span="(21,6-21,8)"> 'CSLib5\.B0\.M\(c: char, a: int\) : int'</Expects>
//<Expects span="(21,6-21,8)"> 'CSLib5\.B0\.N\(c: char, a: int\) : int'</Expects>
//<Expects status="error" span="(21,6-21,8)" id="FS0054">This type is 'abstract' since some abstract members have not been given an implementation\. If this is intentional then add the '\[<AbstractClass>\]' attribute to your type\.$</Expects>
//<Expects status="error" span="(23,16-23,17)" id="FS3070">Cannot override inherited member 'B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(23,16-23,17)" id="FS3070">Cannot override inherited member 'CSLib5.B1::M' because it is sealed$</Expects>

Просмотреть файл

@ -14,5 +14,5 @@ type T2() =
override x.M(o : obj) = 12
override x.M(i : int) = 2 // ERROR {expected}
//<Expects status="error" span="(9,16-9,17)" id="FS3070">Cannot override inherited member 'B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(15,16-15,17)" id="FS3070">Cannot override inherited member 'B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(9,16-9,17)" id="FS3070">Cannot override inherited member 'CSLib.B1::M' because it is sealed$</Expects>
//<Expects status="error" span="(15,16-15,17)" id="FS3070">Cannot override inherited member 'CSLib2.B1::M' because it is sealed$</Expects>

Просмотреть файл

@ -1,6 +1,6 @@
// #Regression #NoMT #Import
// Dev11 Bug 90642
//<Expects status="error" span="(8,19)" id="FS3070">Cannot override inherited member 'Class2::F' because it is sealed$</Expects>
//<Expects status="error" span="(8,19)" id="FS3070">Cannot override inherited member 'ClassLibrary1.Class2::F' because it is sealed$</Expects>
type MyClass() =
inherit ClassLibrary1.Class2()

Просмотреть файл

@ -344,7 +344,7 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
let mutable vsProject : VSLangProj.VSProject = null
let mutable trackDocumentsHandle = 0u
let mutable addFilesNotification : option<(array<string> -> unit)> = None // this object is only used for helping re-order newly added files (VS defaults to alphabetical order)
let mutable addFilesNotification : (string array -> unit) option = None // this object is only used for helping re-order newly added files (VS defaults to alphabetical order)
let mutable updateSolnEventsHandle = 0u
let mutable updateSolnEventsHandle2 = 0u

Просмотреть файл

@ -149,7 +149,6 @@ namespace ProviderImplementation.ProvidedTypes
/// Internal code of .NET expects the obj[] returned by GetCustomAttributes to be an Attribute[] even in the case of empty arrays
let emptyAttributes = (([| |]: Attribute[]) |> box |> unbox<obj[]>)
let nonNull str x = if isNull x then failwithf "Null in '%s', stacktrace = '%s'" str Environment.StackTrace else x
let nonNone str x = match x with None -> failwithf "No value has been specified for '%s', stacktrace = '%s'" str Environment.StackTrace | Some v -> v
let patchOption v f = match v with None -> f() | Some _ -> failwithf "Already patched, stacktrace = '%s'" Environment.StackTrace

Просмотреть файл

@ -203,9 +203,9 @@ type Miscellaneous() =
let prjCfg = project.ConfigProvider.GetProjectConfiguration(new ConfigCanonicalName("Debug","AnyCPU")) :> IVsProjectCfg2
let count = [| 0u |]
prjCfg.get_OutputGroups(0u, null, count) |> ValidateOK
let ogs : array<IVsOutputGroup> = Array.create (int count.[0]) null
let ogs : IVsOutputGroup array = Array.create (int count.[0]) null
prjCfg.get_OutputGroups(count.[0], ogs, count) |> ValidateOK
let ogs : array<IVsOutputGroup2> = ogs |> Array.map (fun x -> downcast x)
let ogs : IVsOutputGroup2 array = ogs |> Array.map (fun x -> downcast x)
let ogInfos =
[for og in ogs do
let mutable canonicalName = ""
@ -218,7 +218,7 @@ type Miscellaneous() =
let keyOutputResult = og.get_KeyOutput(&keyOutput)
let count = [| 0u |]
og.get_Outputs(0u, null, count) |> ValidateOK
let os : array<IVsOutput2> = Array.create (int count.[0]) null
let os : IVsOutput2 array = Array.create (int count.[0]) null
og.get_Outputs(count.[0], os, count) |> ValidateOK
yield canonicalName, description, displayName, keyOutput, keyOutputResult, [
for o in os do