Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### Added
* FSharpType: add ImportILType ([PR #19300](https://github.com/dotnet/fsharp/pull/19300))
* FSharpType: add more predefined type checks ([PR #19325](https://github.com/dotnet/fsharp/pull/19325))

### Changed

Expand Down
67 changes: 46 additions & 21 deletions src/Compiler/Symbols/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2557,24 +2557,55 @@ type FSharpType(cenv, ty:TType) =

member _.IsMeasureType =
isResolved() &&
protect <| fun () ->
match stripTyparEqns ty with
| TType_measure _ -> true
| _ -> false
protect <| fun () -> isMeasureTy cenv.g ty

member _.IsTupleType =
isResolved() &&
protect <| fun () ->
match stripTyparEqns ty with
| TType_tuple _ -> true
| _ -> false
protect <| fun () -> isRefTupleTy cenv.g ty

member _.IsStructTupleType =
isResolved() &&
protect <| fun () ->
match stripTyparEqns ty with
| TType_tuple (tupInfo, _) -> evalTupInfoIsStruct tupInfo
| _ -> false
protect <| fun () -> isStructTupleTy cenv.g ty

member _.IsUnitType =
isResolved () &&
protect <| fun () -> isUnitTy cenv.g ty

member _.IsArrayType =
isResolved () &&
protect <| fun () -> isArrayTy cenv.g ty

member _.IsNativePointerType =
isResolved () &&
protect <| fun () -> isNativePtrTy cenv.g ty

member _.IsFSharpList =
isResolved () &&
protect <| fun () -> isListTy cenv.g ty

member _.IsFSharpChoice =
isResolved () &&
protect <| fun () -> isChoiceTy cenv.g ty

member _.IsFSharpOption =
isResolved () &&
protect <| fun () -> isOptionTy cenv.g ty

member _.IsFSharpValueOption =
isResolved () &&
protect <| fun () -> isValueOptionTy cenv.g ty

member _.IsStringType =
isResolved () &&
protect <| fun () -> isStringTy cenv.g ty

member _.IsObjectType =
isResolved () &&
protect <| fun () -> isObjTyAnyNullness cenv.g ty

member _.IsBooleanType =
isResolved () &&
protect <| fun () -> isBoolTy cenv.g ty

member _.TypeDefinition =
protect <| fun () ->
Expand Down Expand Up @@ -2633,17 +2664,11 @@ type FSharpType(cenv, ty:TType) =

member _.IsFunctionType =
isResolved() &&
protect <| fun () ->
match stripTyparEqns ty with
| TType_fun _ -> true
| _ -> false
protect <| fun () -> isFunTy cenv.g ty

member _.IsAnonRecordType =
isResolved() &&
protect <| fun () ->
match stripTyparEqns ty with
| TType_anon _ -> true
| _ -> false
protect <| fun () -> isAnonRecdTy cenv.g ty

member _.AnonRecordTypeDetails =
protect <| fun () ->
Expand Down Expand Up @@ -2676,7 +2701,7 @@ type FSharpType(cenv, ty:TType) =
GetSuperTypeOfType cenv.g cenv.amap range0 ty
|> Option.map (fun ty -> FSharpType(cenv, ty))

member x.ErasedType=
member x.ErasedType =
FSharpType(cenv, stripTyEqnsWrtErasure EraseAll cenv.g ty)

member x.BasicQualifiedName =
Expand Down
11 changes: 11 additions & 0 deletions src/Compiler/Symbols/Symbols.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,17 @@ type FSharpType =
/// Indicates if the type is a struct tuple type. The GenericArguments property returns the elements of the tuple type.
member IsStructTupleType: bool

member IsArrayType: bool
member IsNativePointerType: bool
member IsUnitType: bool
member IsFSharpList: bool
member IsFSharpChoice: bool
member IsFSharpOption: bool
member IsFSharpValueOption: bool
member IsStringType: bool
member IsObjectType: bool
member IsBooleanType: bool

/// Indicates if the type is a function type. The GenericArguments property returns the domain and range of the function type.
member IsFunctionType: bool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5835,23 +5835,43 @@ FSharp.Compiler.Symbols.FSharpType: Boolean HasNullAnnotation
FSharp.Compiler.Symbols.FSharpType: Boolean HasTypeDefinition
FSharp.Compiler.Symbols.FSharpType: Boolean IsAbbreviation
FSharp.Compiler.Symbols.FSharpType: Boolean IsAnonRecordType
FSharp.Compiler.Symbols.FSharpType: Boolean IsArrayType
FSharp.Compiler.Symbols.FSharpType: Boolean IsBooleanType
FSharp.Compiler.Symbols.FSharpType: Boolean IsFSharpChoice
FSharp.Compiler.Symbols.FSharpType: Boolean IsFSharpList
FSharp.Compiler.Symbols.FSharpType: Boolean IsFSharpOption
FSharp.Compiler.Symbols.FSharpType: Boolean IsFSharpValueOption
FSharp.Compiler.Symbols.FSharpType: Boolean IsFunctionType
FSharp.Compiler.Symbols.FSharpType: Boolean IsGenericParameter
FSharp.Compiler.Symbols.FSharpType: Boolean IsMeasureType
FSharp.Compiler.Symbols.FSharpType: Boolean IsNativePointerType
FSharp.Compiler.Symbols.FSharpType: Boolean IsNullAmbivalent
FSharp.Compiler.Symbols.FSharpType: Boolean IsObjectType
FSharp.Compiler.Symbols.FSharpType: Boolean IsStringType
FSharp.Compiler.Symbols.FSharpType: Boolean IsStructTupleType
FSharp.Compiler.Symbols.FSharpType: Boolean IsTupleType
FSharp.Compiler.Symbols.FSharpType: Boolean IsUnitType
FSharp.Compiler.Symbols.FSharpType: Boolean IsUnresolved
FSharp.Compiler.Symbols.FSharpType: Boolean get_HasNullAnnotation()
FSharp.Compiler.Symbols.FSharpType: Boolean get_HasTypeDefinition()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsAbbreviation()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsAnonRecordType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsArrayType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsBooleanType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsFSharpChoice()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsFSharpList()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsFSharpOption()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsFSharpValueOption()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsFunctionType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsGenericParameter()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsMeasureType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsNativePointerType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsNullAmbivalent()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsObjectType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsStringType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsStructTupleType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsTupleType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsUnitType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsUnresolved()
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpAnonRecordTypeDetails AnonRecordTypeDetails
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpAnonRecordTypeDetails get_AnonRecordTypeDetails()
Expand Down
Loading