diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index eb92de29cba..0489528c062 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -601,20 +601,19 @@ namespace Microsoft.FSharp.Core // duplicated from above since we're using integers in this section let CompilationRepresentationFlags_PermitNull = 8 - let getTypeInfo (ty:Type) = - if ty.IsValueType + let private getTypeInfo<'T> = + if typeof<'T>.IsValueType then TypeNullnessSemantics_NullNever else - let mappingAttrs = ty.GetCustomAttributes(typeof, false) - if mappingAttrs.Length = 0 + if not (typeof<'T>.IsDefined(typeof, false)) then TypeNullnessSemantics_NullIsExtraValue - elif ty.Equals(typeof) then + elif typeof<'T>.Equals(typeof) then TypeNullnessSemantics_NullTrueValue - elif typeof.IsAssignableFrom(ty) then + elif typeof.IsAssignableFrom(typeof<'T>) then TypeNullnessSemantics_NullIsExtraValue - elif ty.GetCustomAttributes(typeof, false).Length > 0 then + elif typeof<'T>.IsDefined(typeof, false) then TypeNullnessSemantics_NullIsExtraValue else - let reprAttrs = ty.GetCustomAttributes(typeof, false) + let reprAttrs = typeof<'T>.GetCustomAttributes(typeof, false) if reprAttrs.Length = 0 then TypeNullnessSemantics_NullNotLiked else @@ -627,7 +626,7 @@ namespace Microsoft.FSharp.Core type TypeInfo<'T>() = // Compute an on-demand per-instantiation static field - static let info = getTypeInfo typeof<'T> + static let info = getTypeInfo<'T> // Publish the results of that computation static member TypeInfo = info