Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FSharpType.IsMeasureType #14978

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions src/Compiler/Symbols/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,13 @@ type FSharpType(cenv, ty:TType) =
| TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One) -> true
| _ -> false

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

member _.IsTupleType =
isResolved() &&
protect <| fun () ->
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Symbols/Symbols.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,9 @@ type FSharpType =
/// Get the generic arguments for a tuple type, a function type or a type constructed using a named entity
member GenericArguments: IList<FSharpType>

/// Indicates if the type is a measure type.
member IsMeasureType: bool

/// Indicates if the type is a tuple type (reference or struct). The GenericArguments property returns the elements of the tuple type.
member IsTupleType: bool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,7 @@ FSharp.Compiler.Symbols.FSharpType: Boolean IsAbbreviation
FSharp.Compiler.Symbols.FSharpType: Boolean IsAnonRecordType
FSharp.Compiler.Symbols.FSharpType: Boolean IsFunctionType
FSharp.Compiler.Symbols.FSharpType: Boolean IsGenericParameter
FSharp.Compiler.Symbols.FSharpType: Boolean IsMeasureType
FSharp.Compiler.Symbols.FSharpType: Boolean IsStructTupleType
FSharp.Compiler.Symbols.FSharpType: Boolean IsTupleType
FSharp.Compiler.Symbols.FSharpType: Boolean IsUnresolved
Expand All @@ -5074,6 +5075,7 @@ FSharp.Compiler.Symbols.FSharpType: Boolean get_IsAbbreviation()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsAnonRecordType()
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_IsStructTupleType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsTupleType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsUnresolved()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,7 @@ FSharp.Compiler.Symbols.FSharpType: Boolean IsAbbreviation
FSharp.Compiler.Symbols.FSharpType: Boolean IsAnonRecordType
FSharp.Compiler.Symbols.FSharpType: Boolean IsFunctionType
FSharp.Compiler.Symbols.FSharpType: Boolean IsGenericParameter
FSharp.Compiler.Symbols.FSharpType: Boolean IsMeasureType
FSharp.Compiler.Symbols.FSharpType: Boolean IsStructTupleType
FSharp.Compiler.Symbols.FSharpType: Boolean IsTupleType
FSharp.Compiler.Symbols.FSharpType: Boolean IsUnresolved
Expand All @@ -5074,6 +5075,7 @@ FSharp.Compiler.Symbols.FSharpType: Boolean get_IsAbbreviation()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsAnonRecordType()
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_IsStructTupleType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsTupleType()
FSharp.Compiler.Symbols.FSharpType: Boolean get_IsUnresolved()
Expand Down