diff --git a/lib/fcs/FSharp.Compiler.Service.dll b/lib/fcs/FSharp.Compiler.Service.dll
index 550cc16db0..7198b1b133 100644
Binary files a/lib/fcs/FSharp.Compiler.Service.dll and b/lib/fcs/FSharp.Compiler.Service.dll differ
diff --git a/lib/fcs/FSharp.Compiler.Service.xml b/lib/fcs/FSharp.Compiler.Service.xml
index 2f322f0ada..658298b7a3 100644
--- a/lib/fcs/FSharp.Compiler.Service.xml
+++ b/lib/fcs/FSharp.Compiler.Service.xml
@@ -30347,6 +30347,11 @@ Get the signature for the value's XML documentation
Indicates if the type is a struct tuple type. The GenericArguments property returns the elements of the tuple type.
+
+
+ Indicates if the type is a measure type.
+
+
Indicates if the type is a variable type, whether declared, generalized or an inference type parameter
diff --git a/lib/fcs/FSharp.Core.dll b/lib/fcs/FSharp.Core.dll
index 6dbb3b27f1..f464081a89 100644
Binary files a/lib/fcs/FSharp.Core.dll and b/lib/fcs/FSharp.Core.dll differ
diff --git a/lib/fcs/FSharp.DependencyManager.Nuget.dll b/lib/fcs/FSharp.DependencyManager.Nuget.dll
index 7106e9218c..d5133cd1b0 100644
Binary files a/lib/fcs/FSharp.DependencyManager.Nuget.dll and b/lib/fcs/FSharp.DependencyManager.Nuget.dll differ
diff --git a/lib/fcs/FSharp.DependencyManager.Nuget.xml b/lib/fcs/FSharp.DependencyManager.Nuget.xml
index 53df9bdcbf..ef041700fd 100644
--- a/lib/fcs/FSharp.DependencyManager.Nuget.xml
+++ b/lib/fcs/FSharp.DependencyManager.Nuget.xml
@@ -96,13 +96,13 @@
%s for F# %s
- (Originally from /home/dev/Projects/fsharp/src/Compiler/Facilities/UtilsStrings.txt:2)
+ (Originally from /home/alfonso/repos/fsharp_fable/src/Compiler/Facilities/UtilsStrings.txt:2)
Microsoft (R) F# Compiler version %s
- (Originally from /home/dev/Projects/fsharp/src/Compiler/Facilities/UtilsStrings.txt:1)
+ (Originally from /home/alfonso/repos/fsharp_fable/src/Compiler/Facilities/UtilsStrings.txt:1)
diff --git a/src/Fable.Transforms/BabelPrinter.fs b/src/Fable.Transforms/BabelPrinter.fs
index 733d2d1842..c5efe81ea6 100644
--- a/src/Fable.Transforms/BabelPrinter.fs
+++ b/src/Fable.Transforms/BabelPrinter.fs
@@ -797,10 +797,11 @@ module PrinterExtensions =
member printer.PrintObjectMethod(kind, key, parameters, body, isComputed, returnType, typeParameters, loc) =
printer.AddLocation(loc)
- match kind with
- | ObjectGetter -> printer.Print("get ")
- | ObjectSetter -> printer.Print("set ")
- | ObjectMeth -> ()
+ let isSetter =
+ match kind with
+ | ObjectGetter -> printer.Print("get "); false
+ | ObjectSetter -> printer.Print("set "); true
+ | ObjectMeth -> false
if isComputed then
printer.Print("[")
@@ -813,7 +814,8 @@ module PrinterExtensions =
printer.Print("(")
printer.PrintParameters(parameters)
printer.Print(")")
- printer.PrintOptional(returnType, ": ")
+ if not isSetter then
+ printer.PrintOptional(returnType, ": ")
printer.Print(" ")
printer.PrintBlock(body.Body, skipNewLineAtEnd=true)
@@ -904,10 +906,12 @@ module PrinterExtensions =
if isStatic then printer.Print("static ")
if isAbstract then printer.Print("abstract ")
- match kind with
- | ClassSetter _ -> printer.Print("set ")
- | ClassGetter _ -> printer.Print("get ")
- | ClassPrimaryConstructor _ | ClassFunction _ -> ()
+
+ let isSetter =
+ match kind with
+ | ClassGetter _ -> printer.Print("get "); false
+ | ClassSetter _ -> printer.Print("set "); true
+ | ClassPrimaryConstructor _ | ClassFunction _ -> false
let key, isComputed, accessModifiers =
match kind with
@@ -928,7 +932,8 @@ module PrinterExtensions =
printer.Print("(")
printer.PrintParameters(parameters, accessModifiers)
printer.Print(")")
- printer.PrintOptional(returnType, ": ")
+ if not isSetter then
+ printer.PrintOptional(returnType, ": ")
printer.Print(" ")
printer.Print(body)
diff --git a/src/Fable.Transforms/Dart/Fable2Dart.fs b/src/Fable.Transforms/Dart/Fable2Dart.fs
index f30eb993b9..3e0ea7bc54 100644
--- a/src/Fable.Transforms/Dart/Fable2Dart.fs
+++ b/src/Fable.Transforms/Dart/Fable2Dart.fs
@@ -172,44 +172,36 @@ module Util =
let genArg = transformType com ctx genArg
Type.reference(libValue com ctx Fable.MetaType "Types" "Some", [genArg]) |> Nullable
- let transformDeclaredTypeIgnoreMeasure ignoreMeasure (com: IDartCompiler) ctx (entRef: Fable.EntityRef) genArgs =
+ let transformDeclaredType (com: IDartCompiler) ctx (entRef: Fable.EntityRef) genArgs =
let genArgs = transformGenArgs com ctx genArgs
let makeIterator genArg = Type.reference(makeImmutableIdent MetaType "Iterator", [genArg])
let makeMapEntry key value = Type.reference(makeImmutableIdent MetaType "MapEntry", [key; value])
match entRef.FullName, genArgs with
- | Types.enum_, _ -> Integer |> Some
+ | Types.enum_, _ -> Integer
// List without generics is same as List
- | Types.array, _ -> List Dynamic |> Some
- | "System.Tuple`1", _ -> transformTupleType com ctx genArgs |> Some
- | Types.valueType, _ -> Some Object
+ | Types.array, _ -> List Dynamic
+ | "System.Tuple`1", _ -> transformTupleType com ctx genArgs
+ | Types.valueType, _ -> Object
| Types.nullable, [genArg]
- | "Fable.Core.Dart.DartNullable`1", [genArg] -> Nullable genArg |> Some
- | "System.Text.RegularExpressions.Group", _ -> Nullable String |> Some
+ | "Fable.Core.Dart.DartNullable`1", [genArg] -> Nullable genArg
+ | "System.Text.RegularExpressions.Group", _ -> Nullable String
| "System.Text.RegularExpressions.Match", _ ->
- makeTypeRefFromName "Match" [] |> Some
- | Types.measureOne, _ when ignoreMeasure -> None
- | Types.measureProduct2, _ when ignoreMeasure -> None
+ makeTypeRefFromName "Match" []
// We use `dynamic` for now because there doesn't seem to be a type that catches all errors in Dart
- | Naming.EndsWith "Exception" _, _ -> Dynamic |> Some
- | "System.Collections.Generic.Dictionary`2.Enumerator", [key; value] -> makeMapEntry key value |> makeIterator |> Some
- | "System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator", [key; _] -> makeIterator key |> Some
- | "System.Collections.Generic.Dictionary`2.ValueCollection.Enumerator", [_; value] -> makeIterator value |> Some
+ | Naming.EndsWith "Exception" _, _ -> Dynamic
+ | "System.Collections.Generic.Dictionary`2.Enumerator", [key; value] -> makeMapEntry key value |> makeIterator
+ | "System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator", [key; _] -> makeIterator key
+ | "System.Collections.Generic.Dictionary`2.ValueCollection.Enumerator", [_; value] -> makeIterator value
| _ ->
let ent = com.GetEntity(entRef)
- if ignoreMeasure && ent.IsMeasure then
- None
- else
- let ident, genArgs =
- match getEntityIdent com ctx ent with
- // If Iterator has more than one genArg assume we need to use MapEntry
- | { Name = "Iterator"; ImportModule = None } as ident when List.isMultiple genArgs ->
- ident, [Type.reference(makeImmutableIdent MetaType "MapEntry", genArgs)]
- | ident -> ident, genArgs
- Type.reference(ident, genArgs, isRecord=ent.IsFSharpRecord, isUnion=ent.IsFSharpUnion) |> Some
-
- let transformDeclaredType (com: IDartCompiler) ctx (entRef: Fable.EntityRef) genArgs =
- transformDeclaredTypeIgnoreMeasure false com ctx entRef genArgs |> Option.get
+ let ident, genArgs =
+ match getEntityIdent com ctx ent with
+ // If Iterator has more than one genArg assume we need to use MapEntry
+ | { Name = "Iterator"; ImportModule = None } as ident when List.isMultiple genArgs ->
+ ident, [Type.reference(makeImmutableIdent MetaType "MapEntry", genArgs)]
+ | ident -> ident, genArgs
+ Type.reference(ident, genArgs, isRecord=ent.IsFSharpRecord, isUnion=ent.IsFSharpUnion)
let get t left memberName =
PropertyAccess(left, memberName, t, isConst=false)
@@ -488,10 +480,9 @@ module Util =
/// Discards Measure generic arguments
let transformGenArgs com ctx (genArgs: Fable.Type list) =
- genArgs |> List.choose (function
- | Fable.GenericParam(isMeasure=true) -> None
- | Fable.DeclaredType(entRef, genArgs) -> transformDeclaredTypeIgnoreMeasure true com ctx entRef genArgs
- | t -> transformType com ctx t |> Some)
+ genArgs |> List.choose (fun t ->
+ if isUnitOfMeasure t then None
+ else transformType com ctx t |> Some)
let transformType (com: IDartCompiler) (ctx: Context) (t: Fable.Type) =
match t with
diff --git a/src/Fable.Transforms/FSharp2Fable.Util.fs b/src/Fable.Transforms/FSharp2Fable.Util.fs
index bee3c87180..b3327c2ef2 100644
--- a/src/Fable.Transforms/FSharp2Fable.Util.fs
+++ b/src/Fable.Transforms/FSharp2Fable.Util.fs
@@ -1047,11 +1047,10 @@ module TypeHelpers =
// Currently for Dart we're doing it in the Fable2Dart step
let makeTypeGenArgsWithConstraints withConstraints ctxTypeArgs (genArgs: IList) =
genArgs
- |> Seq.map (fun genArg ->
+ |> Seq.mapToList (fun genArg ->
if genArg.IsGenericParameter
then resolveGenParam withConstraints ctxTypeArgs genArg.GenericParameter
else makeTypeWithConstraints withConstraints ctxTypeArgs genArg)
- |> Seq.toList
let makeTypeGenArgs ctxTypeArgs (genArgs: IList) =
makeTypeGenArgsWithConstraints true ctxTypeArgs genArgs
@@ -1131,8 +1130,10 @@ module TypeHelpers =
"FSharp.UMX.string`1", Choice1Of2 Fable.String
"FSharp.UMX.Guid`1", Choice2Of2 Types.guid
"FSharp.UMX.TimeSpan`1", Choice2Of2 Types.timespan
+ "FSharp.UMX.TimeOnly`1", Choice2Of2 Types.timeOnly
"FSharp.UMX.DateTime`1", Choice2Of2 Types.datetime
"FSharp.UMX.DateTimeOffset`1", Choice2Of2 Types.datetimeOffset
+ "FSharp.UMX.DateOnly`1", Choice2Of2 Types.dateOnly
]
let private getMeasureFullName (genArgs: IList) =
@@ -1193,7 +1194,6 @@ module TypeHelpers =
| DicContains numbersWithMeasure kind ->
let info = getMeasureFullName genArgs |> Fable.NumberInfo.IsMeasure
Fable.Number(kind, info)
- // | Types.measureProduct2 as fullName -> makeFSharpCoreType [] fullName
| DicContains runtimeTypesWithMeasure choice ->
match choice with
| Choice1Of2 t -> t
@@ -1245,7 +1245,10 @@ module TypeHelpers =
else
#endif
makeTypeFromDef withConstraints ctxTypeArgs t.GenericArguments t.TypeDefinition
- else Fable.Any // failwithf "Unexpected non-declared F# type: %A" t
+ elif t.IsMeasureType then
+ Fable.Measure ""
+ else
+ Fable.Any // failwithf "Unexpected non-declared F# type: %A" t
let makeType (ctxTypeArgs: Map) t =
makeTypeWithConstraints true ctxTypeArgs t
diff --git a/src/Fable.Transforms/Fable2Babel.fs b/src/Fable.Transforms/Fable2Babel.fs
index b4cc64912e..7c4984486b 100644
--- a/src/Fable.Transforms/Fable2Babel.fs
+++ b/src/Fable.Transforms/Fable2Babel.fs
@@ -73,8 +73,12 @@ module Lib =
| consExpr -> consExpr |> Option.map (fun e -> com.TransformAsExpr(ctx, e))
let tryJsConstructorForAnnotation forAnnotation (com: IBabelCompiler) ctx (ent: Fable.Entity) =
- // TODO: Check this is not an StringEnum or Erase union
- let suffix = if not forAnnotation && com.Options.Language = TypeScript && ent.IsFSharpUnion then "_Cons" else ""
+ let suffix =
+ if not forAnnotation
+ && Annotation.isTypeScript com
+ && ent.IsFSharpUnion
+ then "_" + Util.UnionHelpers.CONS
+ else ""
tryJsConstructorWithSuffix com ctx ent suffix
/// Cannot be used for annotations (use `tryJsConstructorForAnnotation true` instead)
@@ -393,16 +397,14 @@ module Annotation =
| _ -> None)
let makeTypeParamInstantiation (com: IBabelCompiler) ctx genArgs =
- genArgs |> List.chooseToArray (function
- | Fable.DeclaredType(entRef, genArgs) ->
- let ent = com.GetEntity(entRef)
- if ent.IsMeasure then None
- else makeEntityTypeAnnotation com ctx ent genArgs |> Some
- | t -> makeTypeAnnotation com ctx t |> Some)
+ if List.isEmpty genArgs then [||]
+ else
+ genArgs |> List.chooseToArray (fun t ->
+ if isUnitOfMeasure t then None
+ else makeTypeAnnotation com ctx t |> Some)
let makeTypeParamInstantiationIfTypeScript (com: IBabelCompiler) ctx genArgs =
- if com.Options.Language = TypeScript then
- makeTypeParamInstantiation com ctx genArgs |> Some
+ if isTypeScript com then makeTypeParamInstantiation com ctx genArgs |> Some
else None
let getGenericTypeAnnotation com ctx name genArgs =
@@ -443,7 +445,7 @@ module Annotation =
makeEntityTypeAnnotation com ctx ent genArgs
let makeTypeAnnotationIfTypeScript (com: IBabelCompiler) ctx typ expr =
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
match typ, expr with
| Fable.Option _, _ -> makeTypeAnnotation com ctx typ |> Some
// Use type annotation for NullLiteral and enum cases
@@ -463,7 +465,7 @@ module Annotation =
FableTransforms.uncurryType fieldType |> makeTypeAnnotation com ctx
let makeFieldAnnotationIfTypeScript (com: IBabelCompiler) ctx (fieldType: Fable.Type) =
- if com.Options.Language = TypeScript
+ if isTypeScript com
then makeFieldAnnotation com ctx fieldType |> Some
else None
@@ -637,7 +639,7 @@ module Annotation =
AnyTypeAnnotation // TODO:
let transformFunctionWithAnnotations (com: IBabelCompiler) ctx name typeParams (args: Fable.Ident list) (body: Fable.Expr) =
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
let argTypes = args |> List.map (fun id -> id.Type)
let scopedTypeParams, genParams =
match typeParams with
@@ -1100,7 +1102,7 @@ module Util =
let genMap = if List.contains "allow-generics" tags then None else Some Map.empty
transformTypeInfo com ctx r genMap t
| Fable.Null _t ->
- // if com.Options.Language = TypeScript
+ // if isTypeScript com
// let ta = makeTypeAnnotation com ctx t |> TypeAnnotation |> Some
// upcast Identifier("null", ?typeAnnotation=ta, ?loc=r)
// else
@@ -1139,7 +1141,7 @@ module Util =
| Fable.ArrayFrom expr -> makeArrayFrom com ctx typ kind expr
| Fable.NewTuple(vals,_) ->
let tup = makeArray com ctx vals
- if com.Options.Language = TypeScript
+ if isTypeScript com
then AsExpression(tup, makeTypeAnnotation com ctx value.Type)
else tup
// | Fable.NewList (headAndTail, _) when List.contains "FABLE_LIBRARY" com.Options.Define ->
@@ -1175,7 +1177,7 @@ module Util =
let values = List.mapToArray (fun x -> com.TransformAsExpr(ctx, x)) values
let consRef = ent |> jsConstructor com ctx
let typeParamInst =
- if com.Options.Language = TypeScript && (ent.FullName = Types.refCell)
+ if isTypeScript com && (ent.FullName = Types.refCell)
then makeTypeParamInstantiation com ctx genArgs |> Some
else None
Expression.newExpression(consRef, values, ?typeArguments=typeParamInst, ?loc=r)
@@ -1184,7 +1186,7 @@ module Util =
Array.zip fieldNames values |> makeJsObject
| Fable.NewUnion(values, tag, ent, genArgs) ->
let ent = com.GetEntity(ent)
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
let case = ent.UnionCases[tag]
match tryJsConstructorWithSuffix com ctx ent ("_" + case.Name) with
| Some helperRef when not(UnionHelpers.caseNameClashes case.Name)->
@@ -1590,7 +1592,7 @@ module Util =
| Fable.OptionValue ->
let expr = com.TransformAsExpr(ctx, fableExpr)
- if mustWrapOption typ || com.Options.Language = TypeScript
+ if mustWrapOption typ || isTypeScript com
then libCall com ctx None "Option" "value" [] [expr]
else expr
@@ -1651,7 +1653,7 @@ module Util =
if nonEmpty then Expression.unaryExpression(UnaryNot, expr, ?loc=range) else expr
| Fable.UnionCaseTest tag ->
let expected =
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
match expr.Type with
| Fable.DeclaredType(ent, _) ->
let ent = com.GetEntity(ent)
@@ -1827,7 +1829,7 @@ module Util =
/// and another to execute the actual target
let transformDecisionTreeWithTwoSwitches (com: IBabelCompiler) ctx returnStrategy (targets: (Fable.Ident list * Fable.Expr) list) treeExpr =
// Most of the time, TypeScript will complain the variable declared on top are not initialized
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
let ctx = { ctx with DecisionTargets = targets }
com.TransformAsStatements(ctx, returnStrategy, treeExpr)
else
@@ -2221,7 +2223,7 @@ module Util =
let declareClassWithParams (com: IBabelCompiler) ctx (ent: Fable.Entity) entName (consArgs: Parameter[]) (consArgsModifiers: AccessModifier[]) (consBody: BlockStatement) (superClass: SuperClass option) classMembers typeParamDecl =
let implements =
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
let implements = Util.getClassImplements com ctx ent |> Seq.toArray
if Array.isEmpty implements then None else Some implements
else None
@@ -2230,7 +2232,7 @@ module Util =
ClassMember.classMethod(ClassPrimaryConstructor consArgsModifiers, consArgs, consBody)
let classFields =
- if com.Options.Language = TypeScript && not ent.IsFSharpUnion then
+ if isTypeScript com && not ent.IsFSharpUnion then
ent.FSharpFields |> List.mapToArray (fun field ->
let prop, isComputed = memberFromName field.Name
let ta = makeFieldAnnotation com ctx field.FieldType
@@ -2251,14 +2253,14 @@ module Util =
|> declareModuleMember com ctx classExpr
let declareClass (com: IBabelCompiler) ctx ent entName consArgs consBody superClass classMembers =
- if com.Options.Language = TypeScript
+ if isTypeScript com
then FSharp2Fable.Util.getEntityGenArgs ent |> makeTypeParamDecl com ctx |> Some
else None
|> declareClassWithParams com ctx ent entName consArgs [||] consBody superClass classMembers
let declareTypeReflection (com: IBabelCompiler) ctx (ent: Fable.Entity) entName: ModuleDeclaration =
let ta =
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
makeImportTypeAnnotation com ctx [] "Reflection" "TypeInfo" |> Some
else None
let genArgs = Array.init (ent.GenericParameters.Length) (fun i -> "gen" + string i |> makeIdent)
@@ -2351,7 +2353,8 @@ module Util =
|> BlockStatement
ClassMember.classMethod(ClassFunction(Expression.identifier("cases"), false), [||], body)
- if com.Options.Language = TypeScript then
+ // TODO: Don't emit helpers for unions with just one case
+ if isTypeScript com then
// Merge this with makeTypeParamDecl/makeTypeParamInstantiation?
let entParams = ent.GenericParameters |> List.chooseToArray (fun p ->
if not p.IsMeasure then Some p.Name else None)
@@ -2454,7 +2457,7 @@ module Util =
let returnType, typeParamDecl =
// change constructor's return type from void to entity type
- if com.Options.Language = TypeScript then
+ if isTypeScript com then
let genArgs = FSharp2Fable.Util.getEntityGenArgs classEnt
let returnType = getGenericTypeAnnotation com ctx classDecl.Name genArgs
let typeParamDecl = makeTypeParamDecl com ctx genArgs |> Some
diff --git a/src/Fable.Transforms/Rust/Fable2Rust.fs b/src/Fable.Transforms/Rust/Fable2Rust.fs
index 88f28ba177..dde4472502 100644
--- a/src/Fable.Transforms/Rust/Fable2Rust.fs
+++ b/src/Fable.Transforms/Rust/Fable2Rust.fs
@@ -621,16 +621,9 @@ module TypeInfo =
let args = Util.transformCallArgs com ctx args [] []
makeLibCall com ctx genArgsOpt moduleName memberName args
- let isUnitOfMeasure = function
- | Fable.Measure _
- | Fable.GenericParam(_, true, _)
- | Replacements.Util.IsEntity (Types.measureProduct2) _
- -> true
- | _ -> false
-
let transformGenTypes com ctx genArgs: Rust.Ty list =
genArgs
- |> List.filter (fun t -> not (isUnitOfMeasure t))
+ |> List.filter (isUnitOfMeasure >> not)
|> List.map (transformType com ctx)
let transformGenArgs com ctx genArgs: Rust.GenericArgs option =
diff --git a/src/Fable.Transforms/Transforms.Util.fs b/src/Fable.Transforms/Transforms.Util.fs
index f885c91c3e..42604b488e 100644
--- a/src/Fable.Transforms/Transforms.Util.fs
+++ b/src/Fable.Transforms/Transforms.Util.fs
@@ -139,6 +139,7 @@ module Types =
let [] createEvent = "Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.CreateEvent"
let [] measureProduct2 = "Microsoft.FSharp.Core.CompilerServices.MeasureProduct`2"
let [] measureOne = "Microsoft.FSharp.Core.CompilerServices.MeasureOne"
+ let [] measureInverse = "Microsoft.FSharp.Core.CompilerServices.MeasureInverse`1"
// Types compatible with Inject attribute (fable library)
let [] icomparerGeneric = "System.Collections.Generic.IComparer`1"
@@ -463,6 +464,18 @@ module AST =
| Any | Unit | GenericParam _ | Option _ -> true
| _ -> false
+ let isUnitOfMeasure t =
+ match t with
+ | Measure _
+ | GenericParam(_, true, _) -> true
+ | Fable.DeclaredType(ent, _) ->
+ match ent.FullName with
+ | Types.measureProduct2
+ | Types.measureOne
+ | Types.measureInverse -> true
+ | _ -> false
+ | _ -> false
+
/// ATTENTION: Make sure the ident name is unique
let makeTypedIdent typ name =
{ Name = name
@@ -803,6 +816,7 @@ module AST =
&& Array.zip fields1 fields2 |> Array.forall (fun (f1, f2) -> f1 = f2)
&& listEquals (typeEquals strict) gen1 gen2
&& isStruct1 = isStruct2
+ | Measure _, Measure _ -> true
| _ -> false
let rec getEntityFullName prettify (entRef: EntityRef) gen =
diff --git a/src/fcs-fable/src/Compiler/Symbols/Symbols.fs b/src/fcs-fable/src/Compiler/Symbols/Symbols.fs
index 90cf0e9b71..cb9e56983a 100644
--- a/src/fcs-fable/src/Compiler/Symbols/Symbols.fs
+++ b/src/fcs-fable/src/Compiler/Symbols/Symbols.fs
@@ -27,18 +27,18 @@ open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TypeHierarchy
-type FSharpAccessibility(a:Accessibility, ?isProtected) =
+type FSharpAccessibility(a:Accessibility, ?isProtected) =
let isProtected = defaultArg isProtected false
- let isInternalCompPath x =
- match x with
- | CompPath(ILScopeRef.Local, []) -> true
+ let isInternalCompPath x =
+ match x with
+ | CompPath(ILScopeRef.Local, []) -> true
| _ -> false
-
- let (|Public|Internal|Private|) (TAccess p) =
- match p with
- | [] -> Public
- | _ when List.forall isInternalCompPath p -> Internal
+
+ let (|Public|Internal|Private|) (TAccess p) =
+ match p with
+ | [] -> Public
+ | _ when List.forall isInternalCompPath p -> Internal
| _ -> Private
member _.IsPublic = not isProtected && (match a with TAccess [] -> true | _ -> false)
@@ -51,12 +51,12 @@ type FSharpAccessibility(a:Accessibility, ?isProtected) =
member internal _.Contents = a
- override _.ToString() =
+ override _.ToString() =
let (TAccess paths) = a
- let mangledTextOfCompPath (CompPath(scoref, path)) = getNameOfScopeRef scoref + "/" + textOfPath (List.map fst path)
+ let mangledTextOfCompPath (CompPath(scoref, path)) = getNameOfScopeRef scoref + "/" + textOfPath (List.map fst path)
String.concat ";" (List.map mangledTextOfCompPath paths)
-type SymbolEnv(g: TcGlobals, thisCcu: CcuThunk, thisCcuTyp: ModuleOrNamespaceType option, tcImports: TcImports, amap: Import.ImportMap, infoReader: InfoReader) =
+type SymbolEnv(g: TcGlobals, thisCcu: CcuThunk, thisCcuTyp: ModuleOrNamespaceType option, tcImports: TcImports, amap: Import.ImportMap, infoReader: InfoReader) =
let tcVal = CheckExpressions.LightweightTcValForUsingInBuildMethodCall g
@@ -74,77 +74,77 @@ type SymbolEnv(g: TcGlobals, thisCcu: CcuThunk, thisCcuTyp: ModuleOrNamespaceTyp
member _.tcValF = tcVal
[]
-module Impl =
- let protect f =
- DiagnosticsLogger.protectAssemblyExplorationF
+module Impl =
+ let protect f =
+ DiagnosticsLogger.protectAssemblyExplorationF
(fun (asmName, path) -> invalidOp (sprintf "The entity or value '%s' does not exist or is in an unresolved assembly. You may need to add a reference to assembly '%s'" path asmName))
f
- let makeReadOnlyCollection (arr: seq<'T>) =
+ let makeReadOnlyCollection (arr: seq<'T>) =
#if FABLE_COMPILER
System.Collections.Generic.List<_>(Seq.toArray arr) :> IList<_>
#else
System.Collections.ObjectModel.ReadOnlyCollection<_>(Seq.toArray arr) :> IList<_>
#endif
-
+
let makeXmlDoc (doc: XmlDoc) =
FSharpXmlDoc.FromXmlText doc
-
+
let makeElaboratedXmlDoc (doc: XmlDoc) =
makeReadOnlyCollection (doc.GetElaboratedXmlLines())
-
- let rescopeEntity optViewedCcu (entity: Entity) =
- match optViewedCcu with
+
+ let rescopeEntity optViewedCcu (entity: Entity) =
+ match optViewedCcu with
| None -> mkLocalEntityRef entity
- | Some viewedCcu ->
+ | Some viewedCcu ->
match tryRescopeEntity viewedCcu entity with
| ValueNone -> mkLocalEntityRef entity
| ValueSome eref -> eref
- let entityIsUnresolved(entity:EntityRef) =
+ let entityIsUnresolved(entity:EntityRef) =
match entity with
- | ERefNonLocal(NonLocalEntityRef(ccu, _)) ->
+ | ERefNonLocal(NonLocalEntityRef(ccu, _)) ->
ccu.IsUnresolvedReference && entity.TryDeref.IsNone
| _ -> false
- let checkEntityIsResolved(entity:EntityRef) =
- if entityIsUnresolved entity then
+ let checkEntityIsResolved(entity:EntityRef) =
+ if entityIsUnresolved entity then
let poorQualifiedName =
- if entity.nlr.AssemblyName = "mscorlib" then
+ if entity.nlr.AssemblyName = "mscorlib" then
entity.nlr.DisplayName + ", mscorlib"
- else
+ else
entity.nlr.DisplayName + ", " + entity.nlr.Ccu.AssemblyName
invalidOp (sprintf "The entity '%s' does not exist or is in an unresolved assembly." poorQualifiedName)
/// Checking accessibility that arise from different compilations needs more care - this is a duplicate of the F# compiler code for this case
- let checkForCrossProjectAccessibility (ilg: ILGlobals) (thisCcu2:CcuThunk, ad2) (thisCcu1, taccess1) =
- match ad2 with
+ let checkForCrossProjectAccessibility (ilg: ILGlobals) (thisCcu2:CcuThunk, ad2) (thisCcu1, taccess1) =
+ match ad2 with
| AccessibleFrom(cpaths2, _) ->
- let nameOfScoRef (thisCcu:CcuThunk) scoref =
- match scoref with
- | ILScopeRef.Local -> thisCcu.AssemblyName
- | ILScopeRef.Assembly aref -> aref.Name
+ let nameOfScoRef (thisCcu:CcuThunk) scoref =
+ match scoref with
+ | ILScopeRef.Local -> thisCcu.AssemblyName
+ | ILScopeRef.Assembly aref -> aref.Name
| ILScopeRef.Module mref -> mref.Name
| ILScopeRef.PrimaryAssembly -> ilg.primaryAssemblyName
let canAccessCompPathFromCrossProject (CompPath(scoref1, cpath1)) (CompPath(scoref2, cpath2)) =
- let rec loop p1 p2 =
- match p1, p2 with
+ let rec loop p1 p2 =
+ match p1, p2 with
| (a1, k1) :: rest1, (a2, k2) :: rest2 -> (a1=a2) && (k1=k2) && loop rest1 rest2
- | [], _ -> true
+ | [], _ -> true
| _ -> false // cpath1 is longer
loop cpath1 cpath2 &&
nameOfScoRef thisCcu1 scoref1 = nameOfScoRef thisCcu2 scoref2
let canAccessFromCrossProject (TAccess x1) cpath2 = x1 |> List.forall (fun cpath1 -> canAccessCompPathFromCrossProject cpath1 cpath2)
- cpaths2 |> List.exists (canAccessFromCrossProject taccess1)
+ cpaths2 |> List.exists (canAccessFromCrossProject taccess1)
| _ -> true // otherwise use the normal check
/// Convert an IL member accessibility into an F# accessibility
- let getApproxFSharpAccessibilityOfMember (declaringEntity: EntityRef) (ilAccess: ILMemberAccess) =
- match ilAccess with
+ let getApproxFSharpAccessibilityOfMember (declaringEntity: EntityRef) (ilAccess: ILMemberAccess) =
+ match ilAccess with
| ILMemberAccess.CompilerControlled
- | ILMemberAccess.FamilyAndAssembly
- | ILMemberAccess.Assembly ->
+ | ILMemberAccess.FamilyAndAssembly
+ | ILMemberAccess.Assembly ->
taccessPrivate (CompPath(declaringEntity.CompilationPath.ILScopeRef, []))
| ILMemberAccess.Private ->
@@ -155,25 +155,25 @@ module Impl =
// This is an approximation - the thing is actually "protected", but F# accessibilities can't express "protected", so we report it as "public"
| ILMemberAccess.FamilyOrAssembly
| ILMemberAccess.Family ->
- taccessPublic
+ taccessPublic
/// Convert an IL type definition accessibility into an F# accessibility
- let getApproxFSharpAccessibilityOfEntity (entity: EntityRef) =
- match metadataOfTycon entity.Deref with
+ let getApproxFSharpAccessibilityOfEntity (entity: EntityRef) =
+ match metadataOfTycon entity.Deref with
#if !NO_TYPEPROVIDERS
- | ProvidedTypeMetadata _info ->
+ | ProvidedTypeMetadata _info ->
// This is an approximation - for generative type providers some type definitions can be private.
taccessPublic
#endif
- | ILTypeMetadata (TILObjectReprData(_, _, td)) ->
- match td.Access with
- | ILTypeDefAccess.Public
- | ILTypeDefAccess.Nested ILMemberAccess.Public -> taccessPublic
+ | ILTypeMetadata (TILObjectReprData(_, _, td)) ->
+ match td.Access with
+ | ILTypeDefAccess.Public
+ | ILTypeDefAccess.Nested ILMemberAccess.Public -> taccessPublic
| ILTypeDefAccess.Private -> taccessPrivate (CompPath(entity.CompilationPath.ILScopeRef, []))
| ILTypeDefAccess.Nested nested -> getApproxFSharpAccessibilityOfMember entity nested
- | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata ->
+ | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata ->
entity.Accessibility
let getLiteralValue = function
@@ -198,14 +198,14 @@ module Impl =
| Const.Unit
| Const.Zero -> None
| None -> None
-
+
let getXmlDocSigForEntity (cenv: SymbolEnv) (ent:EntityRef)=
match GetXmlDocSigOfEntityRef cenv.infoReader ent.Range ent with
| Some (_, docsig) -> docsig
| _ -> ""
-type FSharpDisplayContext(denv: TcGlobals -> DisplayEnv) =
+type FSharpDisplayContext(denv: TcGlobals -> DisplayEnv) =
member _.Contents g = denv g
static member Empty = FSharpDisplayContext(fun g -> DisplayEnv.Empty g)
@@ -222,15 +222,15 @@ type FSharpDisplayContext(denv: TcGlobals -> DisplayEnv) =
// delay the realization of 'item' in case it is unresolved
type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> CcuThunk -> AccessorDomain -> bool) =
- member x.Assembly =
- let ccu = defaultArg (SymbolHelpers.ccuOfItem cenv.g x.Item) cenv.thisCcu
+ member x.Assembly =
+ let ccu = defaultArg (SymbolHelpers.ccuOfItem cenv.g x.Item) cenv.thisCcu
FSharpAssembly(cenv, ccu)
member x.IsAccessible(rights: FSharpAccessibilityRights) = access x rights.ThisCcu rights.Contents
member x.IsExplicitlySuppressed = SymbolHelpers.IsExplicitlySuppressed cenv.g x.Item
- member x.FullName = SymbolHelpers.FullNameOfItem cenv.g x.Item
+ member x.FullName = SymbolHelpers.FullNameOfItem cenv.g x.Item
member x.DeclarationLocation = SymbolHelpers.rangeOfItem cenv.g None x.Item
@@ -238,7 +238,7 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
member x.SignatureLocation = SymbolHelpers.rangeOfItem cenv.g (Some true) x.Item
- member x.IsEffectivelySameAs(other:FSharpSymbol) =
+ member x.IsEffectivelySameAs(other:FSharpSymbol) =
x.Equals other || ItemsAreEffectivelyEqual cenv.g x.Item other.Item
member x.GetEffectivelySameAsHash() = ItemsAreEffectivelyEqualHash cenv.g x.Item
@@ -251,7 +251,7 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
member _.DisplayName = item().DisplayName
- // This is actually overridden in all cases below. However some symbols are still just of type FSharpSymbol,
+ // This is actually overridden in all cases below. However some symbols are still just of type FSharpSymbol,
// see 'FSharpSymbol.Create' further below.
override x.Equals(other: obj) =
box x === other ||
@@ -259,17 +259,17 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
| :? FSharpSymbol as otherSymbol -> ItemsAreEffectivelyEqual cenv.g x.Item otherSymbol.Item
| _ -> false
- override x.GetHashCode() = hash x.ImplementationLocation
+ override x.GetHashCode() = hash x.ImplementationLocation
override x.ToString() = "symbol " + (try item().DisplayNameCore with _ -> "?")
// TODO: there are several cases where we may need to report more interesting
// symbol information below. By default we return a vanilla symbol.
- static member Create(g, thisCcu, thisCcuTyp, tcImports, item): FSharpSymbol =
+ static member Create(g, thisCcu, thisCcuTyp, tcImports, item): FSharpSymbol =
FSharpSymbol.Create(SymbolEnv(g, thisCcu, Some thisCcuTyp, tcImports), item)
- static member Create(cenv, item): FSharpSymbol =
- let dflt() = FSharpSymbol(cenv, (fun () -> item), (fun _ _ _ -> true))
+ static member Create(cenv, item): FSharpSymbol =
+ let dflt() = FSharpSymbol(cenv, (fun () -> item), (fun _ _ _ -> true))
match item with
| Item.Value v when v.Deref.IsClassConstructor ->
FSharpMemberOrFunctionOrValue(cenv, C (FSMeth(cenv.g, generalizeTyconRef cenv.g v.DeclaringEntity |> snd, v, None)), item) :> _
@@ -283,35 +283,35 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
| Item.ILField finfo -> FSharpField(cenv, ILField finfo) :> _
| Item.AnonRecdField (anonInfo, tinst, n, m) -> FSharpField(cenv, AnonField (anonInfo, tinst, n, m)) :> _
-
- | Item.Event einfo ->
+
+ | Item.Event einfo ->
FSharpMemberOrFunctionOrValue(cenv, E einfo, item) :> _
-
- | Item.Property(_, pinfo :: _) ->
+
+ | Item.Property(_, pinfo :: _) ->
FSharpMemberOrFunctionOrValue(cenv, P pinfo, item) :> _
-
- | Item.MethodGroup(_, minfo :: _, _) ->
+
+ | Item.MethodGroup(_, minfo :: _, _) ->
FSharpMemberOrFunctionOrValue(cenv, M minfo, item) :> _
- | Item.CtorGroup(_, cinfo :: _) ->
+ | Item.CtorGroup(_, cinfo :: _) ->
FSharpMemberOrFunctionOrValue(cenv, C cinfo, item) :> _
- | Item.DelegateCtor (AbbrevOrAppTy tcref) ->
- FSharpEntity(cenv, tcref) :>_
+ | Item.DelegateCtor (AbbrevOrAppTy tcref) ->
+ FSharpEntity(cenv, tcref) :>_
- | Item.UnqualifiedType(tcref :: _)
- | Item.Types(_, AbbrevOrAppTy tcref :: _) ->
- FSharpEntity(cenv, tcref) :>_
+ | Item.UnqualifiedType(tcref :: _)
+ | Item.Types(_, AbbrevOrAppTy tcref :: _) ->
+ FSharpEntity(cenv, tcref) :>_
- | Item.ModuleOrNamespaces(modref :: _) ->
+ | Item.ModuleOrNamespaces(modref :: _) ->
FSharpEntity(cenv, modref) :> _
| Item.SetterArg (_id, item) -> FSharpSymbol.Create(cenv, item)
- | Item.CustomOperation (_customOpName, _, Some minfo) ->
+ | Item.CustomOperation (_customOpName, _, Some minfo) ->
FSharpMemberOrFunctionOrValue(cenv, M minfo, item) :> _
- | Item.CustomBuilder (_, vref) ->
+ | Item.CustomBuilder (_, vref) ->
FSharpMemberOrFunctionOrValue(cenv, V vref, item) :> _
| Item.TypeVar (_, tp) ->
@@ -320,7 +320,7 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
| Item.Trait traitInfo ->
FSharpGenericParameterMemberConstraint(cenv, traitInfo) :> _
- | Item.ActivePatternCase apref ->
+ | Item.ActivePatternCase apref ->
FSharpActivePatternCase(cenv, apref.ActivePatternInfo, apref.ActivePatternVal.Type, apref.CaseIndex, Some apref.ActivePatternVal, item) :> _
| Item.ActivePatternResult (apinfo, ty, n, _) ->
@@ -334,11 +334,11 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
// TODO: the following don't currently return any interesting subtype
| Item.ImplicitOp _
- | Item.ILField _
+ | Item.ILField _
| Item.FakeInterfaceCtor _
| Item.NewDef _ -> dflt()
// These cases cover unreachable cases
- | Item.CustomOperation (_, _, None)
+ | Item.CustomOperation (_, _, None)
| Item.UnqualifiedType []
| Item.ModuleOrNamespaces []
| Item.Property (_, [])
@@ -350,7 +350,7 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
abstract Accessibility: FSharpAccessibility
default _.Accessibility = FSharpAccessibility(taccessPublic)
-
+
abstract Attributes: IList
default _.Attributes = makeReadOnlyCollection []
@@ -360,21 +360,21 @@ type FSharpSymbol(cenv: SymbolEnv, item: unit -> Item, access: FSharpSymbol -> C
member sym.TryGetAttribute<'T>() =
sym.Attributes |> Seq.tryFind (fun attr -> attr.IsAttribute<'T>())
-type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
- inherit FSharpSymbol(cenv,
- (fun () ->
+type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
+ inherit FSharpSymbol(cenv,
+ (fun () ->
checkEntityIsResolved entity
- if entity.IsModuleOrNamespace then Item.ModuleOrNamespaces [entity]
- else Item.UnqualifiedType [entity]),
- (fun _this thisCcu2 ad ->
- checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, getApproxFSharpAccessibilityOfEntity entity))
+ if entity.IsModuleOrNamespace then Item.ModuleOrNamespaces [entity]
+ else Item.UnqualifiedType [entity]),
+ (fun _this thisCcu2 ad ->
+ checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, getApproxFSharpAccessibilityOfEntity entity))
// && AccessibilityLogic.IsEntityAccessible cenv.amap range0 ad entity)
)
- // If an entity is in an assembly not available to us in the resolution set,
+ // If an entity is in an assembly not available to us in the resolution set,
// we generally return "false" from predicates like IsClass, since we know
// nothing about that type.
- let isResolvedAndFSharp() =
+ let isResolvedAndFSharp() =
match entity with
| ERefNonLocal(NonLocalEntityRef(ccu, _)) -> not ccu.IsUnresolvedReference && ccu.IsFSharp
| _ -> cenv.thisCcu.IsFSharp
@@ -389,51 +389,51 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
| Some ccu -> ccuEq ccu cenv.g.fslibCcu
member _.Entity = entity
-
- member _.LogicalName =
+
+ member _.LogicalName =
checkIsResolved()
- entity.LogicalName
+ entity.LogicalName
- member _.CompiledName =
+ member _.CompiledName =
checkIsResolved()
- entity.CompiledName
+ entity.CompiledName
- member _.DisplayNameCore =
+ member _.DisplayNameCore =
checkIsResolved()
entity.DisplayNameCore
- member _.DisplayName =
+ member _.DisplayName =
checkIsResolved()
entity.DisplayName
- member _.AccessPath =
+ member _.AccessPath =
checkIsResolved()
- match entity.CompilationPathOpt with
- | None -> "global"
- | Some (CompPath(_, [])) -> "global"
+ match entity.CompilationPathOpt with
+ | None -> "global"
+ | Some (CompPath(_, [])) -> "global"
| Some cp -> buildAccessPath (Some cp)
-
- member x.DeclaringEntity =
- match entity.CompilationPathOpt with
+
+ member x.DeclaringEntity =
+ match entity.CompilationPathOpt with
| None -> None
| Some (CompPath(_, [])) -> None
- | Some cp ->
+ | Some cp ->
match x.Assembly.Contents.FindEntityByPath cp.MangledPath with
| Some res -> Some res
- | None ->
+ | None ->
// The declaring entity may be in this assembly, including a type possibly hidden by a signature.
- match cenv.thisCcuTy with
- | Some t ->
+ match cenv.thisCcuTy with
+ | Some t ->
let s = FSharpAssemblySignature(cenv, None, None, t)
- s.FindEntityByPath cp.MangledPath
+ s.FindEntityByPath cp.MangledPath
| None -> None
- member _.Namespace =
+ member _.Namespace =
checkIsResolved()
- match entity.CompilationPathOpt with
+ match entity.CompilationPathOpt with
| None -> None
| Some (CompPath(_, [])) -> None
- | Some cp when cp.AccessPath |> List.forall (function _, ModuleOrNamespaceKind.Namespace _ -> true | _ -> false) ->
+ | Some cp when cp.AccessPath |> List.forall (function _, ModuleOrNamespaceKind.Namespace _ -> true | _ -> false) ->
Some (buildAccessPath (Some cp))
| Some _ -> None
@@ -458,13 +458,13 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
member x.BasicQualifiedName =
x.CompiledRepresentation.BasicQualifiedName
- member x.FullName =
+ member x.FullName =
checkIsResolved()
- match x.TryFullName with
+ match x.TryFullName with
| None -> invalidOp (sprintf "the type '%s' does not have a qualified name" x.LogicalName)
| Some nm -> nm
-
- member _.TryFullName =
+
+ member _.TryFullName =
if isUnresolved() then None
#if !NO_TYPEPROVIDERS
elif entity.IsTypeAbbrev || entity.IsProvidedErasedTycon then None
@@ -473,41 +473,41 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
#endif
elif entity.IsNamespace then Some entity.DemangledModuleOrNamespaceName
else
- match entity.CompiledRepresentation with
+ match entity.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref, _, _) -> Some tref.FullName
- | CompiledTypeRepr.ILAsmOpen _ -> None
+ | CompiledTypeRepr.ILAsmOpen _ -> None
- member _.DeclarationLocation =
+ member _.DeclarationLocation =
checkIsResolved()
entity.Range
- member _.GenericParameters =
+ member _.GenericParameters =
checkIsResolved()
entity.TyparsNoRange |> List.map (fun tp -> FSharpGenericParameter(cenv, tp)) |> makeReadOnlyCollection
- member _.IsMeasure =
+ member _.IsMeasure =
isResolvedAndFSharp() && (entity.TypeOrMeasureKind = TyparKind.Measure)
- member _.IsAbstractClass =
+ member _.IsAbstractClass =
isResolved() && isAbstractTycon entity.Deref
- member _.IsFSharpModule =
+ member _.IsFSharpModule =
isResolvedAndFSharp() && entity.IsModule
- member _.HasFSharpModuleSuffix =
- isResolvedAndFSharp() &&
- entity.IsModule &&
+ member _.HasFSharpModuleSuffix =
+ isResolvedAndFSharp() &&
+ entity.IsModule &&
(entity.ModuleOrNamespaceType.ModuleOrNamespaceKind = ModuleOrNamespaceKind.FSharpModuleWithSuffix)
- member _.IsValueType =
+ member _.IsValueType =
isResolved() &&
- entity.IsStructOrEnumTycon
+ entity.IsStructOrEnumTycon
- member _.IsArrayType =
+ member _.IsArrayType =
isResolved() &&
isArrayTyconRef cenv.g entity
- member _.ArrayRank =
+ member _.ArrayRank =
checkIsResolved()
if isArrayTyconRef cenv.g entity then
rankOfArrayTyconRef cenv.g entity
@@ -515,150 +515,150 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
0
#if !NO_TYPEPROVIDERS
- member _.IsProvided =
+ member _.IsProvided =
isResolved() &&
entity.IsProvided
- member _.IsProvidedAndErased =
+ member _.IsProvidedAndErased =
isResolved() &&
entity.IsProvidedErasedTycon
- member _.IsStaticInstantiation =
+ member _.IsStaticInstantiation =
isResolved() &&
entity.IsStaticInstantiationTycon
- member _.IsProvidedAndGenerated =
+ member _.IsProvidedAndGenerated =
isResolved() &&
entity.IsProvidedGeneratedTycon
#endif
- member _.IsClass =
+ member _.IsClass =
isResolved() &&
match metadataOfTycon entity.Deref with
-#if !NO_TYPEPROVIDERS
+#if !NO_TYPEPROVIDERS
| ProvidedTypeMetadata info -> info.IsClass
#endif
| ILTypeMetadata (TILObjectReprData(_, _, td)) -> td.IsClass
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.Deref.IsFSharpClassTycon
- member _.IsByRef =
+ member _.IsByRef =
isResolved() &&
isByrefTyconRef cenv.g entity
- member _.IsOpaque =
+ member _.IsOpaque =
isResolved() &&
entity.IsHiddenReprTycon
- member _.IsInterface =
+ member _.IsInterface =
isResolved() &&
isInterfaceTyconRef entity
- member _.IsDelegate =
+ member _.IsDelegate =
isResolved() &&
- match metadataOfTycon entity.Deref with
+ match metadataOfTycon entity.Deref with
#if !NO_TYPEPROVIDERS
| ProvidedTypeMetadata info -> info.IsDelegate ()
#endif
| ILTypeMetadata (TILObjectReprData(_, _, td)) -> td.IsDelegate
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.IsFSharpDelegateTycon
- member _.IsEnum =
+ member _.IsEnum =
isResolved() &&
entity.IsEnumTycon
-
- member _.IsFSharpExceptionDeclaration =
+
+ member _.IsFSharpExceptionDeclaration =
isResolvedAndFSharp() && entity.IsFSharpException
- member _.IsUnresolved =
+ member _.IsUnresolved =
isUnresolved()
- member _.IsFSharp =
+ member _.IsFSharp =
isResolvedAndFSharp()
- member _.IsFSharpAbbreviation =
- isResolvedAndFSharp() && entity.IsTypeAbbrev
+ member _.IsFSharpAbbreviation =
+ isResolvedAndFSharp() && entity.IsTypeAbbrev
- member _.IsFSharpRecord =
+ member _.IsFSharpRecord =
isResolvedAndFSharp() && entity.IsRecordTycon
- member _.IsFSharpUnion =
+ member _.IsFSharpUnion =
isResolvedAndFSharp() && entity.IsUnionTycon
- member _.HasAssemblyCodeRepresentation =
+ member _.HasAssemblyCodeRepresentation =
isResolvedAndFSharp() && (entity.IsAsmReprTycon || entity.IsMeasureableReprTycon)
member _.FSharpDelegateSignature =
checkIsResolved()
- match entity.TypeReprInfo with
- | TFSharpObjectRepr r when entity.IsFSharpDelegateTycon ->
- match r.fsobjmodel_kind with
+ match entity.TypeReprInfo with
+ | TFSharpObjectRepr r when entity.IsFSharpDelegateTycon ->
+ match r.fsobjmodel_kind with
| TFSharpDelegate ss -> FSharpDelegateSignature(cenv, ss)
| _ -> invalidOp "not a delegate type"
| _ -> invalidOp "not a delegate type"
- override _.Accessibility =
+ override _.Accessibility =
if isUnresolved() then FSharpAccessibility taccessPublic else
- FSharpAccessibility(getApproxFSharpAccessibilityOfEntity entity)
+ FSharpAccessibility(getApproxFSharpAccessibilityOfEntity entity)
- member _.RepresentationAccessibility =
+ member _.RepresentationAccessibility =
if isUnresolved() then FSharpAccessibility taccessPublic else
FSharpAccessibility(entity.TypeReprAccessibility)
- member _.DeclaredInterfaces =
+ member _.DeclaredInterfaces =
if isUnresolved() then makeReadOnlyCollection [] else
let ty = generalizedTyconRef cenv.g entity
- DiagnosticsLogger.protectAssemblyExploration [] (fun () ->
- [ for intfTy in GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes cenv.g cenv.amap range0 ty do
+ DiagnosticsLogger.protectAssemblyExploration [] (fun () ->
+ [ for intfTy in GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes cenv.g cenv.amap range0 ty do
yield FSharpType(cenv, intfTy) ])
|> makeReadOnlyCollection
- member _.AllInterfaces =
+ member _.AllInterfaces =
if isUnresolved() then makeReadOnlyCollection [] else
let ty = generalizedTyconRef cenv.g entity
- DiagnosticsLogger.protectAssemblyExploration [] (fun () ->
- [ for ity in AllInterfacesOfType cenv.g cenv.amap range0 AllowMultiIntfInstantiations.Yes ty do
+ DiagnosticsLogger.protectAssemblyExploration [] (fun () ->
+ [ for ity in AllInterfacesOfType cenv.g cenv.amap range0 AllowMultiIntfInstantiations.Yes ty do
yield FSharpType(cenv, ity) ])
|> makeReadOnlyCollection
-
+
member _.IsAttributeType =
if isUnresolved() then false else
let ty = generalizedTyconRef cenv.g entity
- DiagnosticsLogger.protectAssemblyExploration false <| fun () ->
+ DiagnosticsLogger.protectAssemblyExploration false <| fun () ->
ExistsHeadTypeInEntireHierarchy cenv.g cenv.amap range0 ty cenv.g.tcref_System_Attribute
-
+
member _.IsDisposableType =
if isUnresolved() then false else
let ty = generalizedTyconRef cenv.g entity
- DiagnosticsLogger.protectAssemblyExploration false <| fun () ->
+ DiagnosticsLogger.protectAssemblyExploration false <| fun () ->
ExistsHeadTypeInEntireHierarchy cenv.g cenv.amap range0 ty cenv.g.tcref_System_IDisposable
- member _.BaseType =
- checkIsResolved()
+ member _.BaseType =
+ checkIsResolved()
let ty = generalizedTyconRef cenv.g entity
GetSuperTypeOfType cenv.g cenv.amap range0 ty
- |> Option.map (fun ty -> FSharpType(cenv, ty))
-
- member _.UsesPrefixDisplay =
+ |> Option.map (fun ty -> FSharpType(cenv, ty))
+
+ member _.UsesPrefixDisplay =
if isUnresolved() then true else
not (isResolvedAndFSharp()) || entity.Deref.IsPrefixDisplay
member _.IsNamespace = entity.IsNamespace
- member x.MembersFunctionsAndValues =
+ member x.MembersFunctionsAndValues =
if isUnresolved() then makeReadOnlyCollection [] else
- protect <| fun () ->
+ protect <| fun () ->
([ let entityTy = generalizedTyconRef cenv.g entity
let createMember (minfo: MethInfo) =
if minfo.IsConstructor || minfo.IsClassConstructor then
FSharpMemberOrFunctionOrValue(cenv, C minfo, Item.CtorGroup (minfo.DisplayName, [minfo]))
else
FSharpMemberOrFunctionOrValue(cenv, M minfo, Item.MethodGroup (minfo.DisplayName, [minfo], None))
- if x.IsFSharpAbbreviation then
+ if x.IsFSharpAbbreviation then
()
- elif x.IsFSharp then
+ elif x.IsFSharp then
// For F# code we emit methods members in declaration order
- for v in entity.MembersOfFSharpTyconSorted do
+ for v in entity.MembersOfFSharpTyconSorted do
// Ignore members representing the generated .cctor
- if not v.Deref.IsClassConstructor then
+ if not v.Deref.IsClassConstructor then
yield createMember (FSMeth(cenv.g, entityTy, v, None))
else
for minfo in GetImmediateIntrinsicMethInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy do
@@ -679,62 +679,62 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
// For F#-declared extension members, yield a value-backed member and a property info if possible
let vref = mkNestedValRef entity v
- yield FSharpMemberOrFunctionOrValue(cenv, V vref, Item.Value vref)
+ yield FSharpMemberOrFunctionOrValue(cenv, V vref, Item.Value vref)
match v.MemberInfo.Value.MemberFlags.MemberKind, v.ApparentEnclosingEntity with
- | SynMemberKind.PropertyGet, Parent tcref ->
+ | SynMemberKind.PropertyGet, Parent tcref ->
let pinfo = FSProp(cenv.g, generalizedTyconRef cenv.g tcref, Some vref, None)
yield FSharpMemberOrFunctionOrValue(cenv, P pinfo, Item.Property (pinfo.PropertyName, [pinfo]))
- | SynMemberKind.PropertySet, Parent p ->
+ | SynMemberKind.PropertySet, Parent p ->
let pinfo = FSProp(cenv.g, generalizedTyconRef cenv.g p, None, Some vref)
yield FSharpMemberOrFunctionOrValue(cenv, P pinfo, Item.Property (pinfo.PropertyName, [pinfo]))
| _ -> ()
elif not v.IsMember then
let vref = mkNestedValRef entity v
- yield FSharpMemberOrFunctionOrValue(cenv, V vref, Item.Value vref) ]
+ yield FSharpMemberOrFunctionOrValue(cenv, V vref, Item.Value vref) ]
|> makeReadOnlyCollection)
-
- member _.XmlDocSig =
+
+ member _.XmlDocSig =
checkIsResolved()
getXmlDocSigForEntity cenv entity
-
- member _.XmlDoc =
+
+ member _.XmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeXmlDoc else
entity.XmlDoc |> makeXmlDoc
- member _.ElaboratedXmlDoc =
+ member _.ElaboratedXmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeElaboratedXmlDoc else
entity.XmlDoc |> makeElaboratedXmlDoc
- member x.StaticParameters =
- match entity.TypeReprInfo with
+ member x.StaticParameters =
+ match entity.TypeReprInfo with
#if !NO_TYPEPROVIDERS
- | TProvidedTypeRepr info ->
+ | TProvidedTypeRepr info ->
let m = x.DeclarationLocation
- let typeBeforeArguments = info.ProvidedType
- let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m)
+ let typeBeforeArguments = info.ProvidedType
+ let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m)
let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m)
[| for p in staticParameters -> FSharpStaticParameter(cenv, p, m) |]
#endif
| _ -> [| |]
|> makeReadOnlyCollection
- member _.NestedEntities =
+ member _.NestedEntities =
if isUnresolved() then makeReadOnlyCollection [] else
- entity.ModuleOrNamespaceType.AllEntities
+ entity.ModuleOrNamespaceType.AllEntities
|> QueueList.toList
|> List.map (fun x -> FSharpEntity(cenv, entity.NestedTyconRef x))
|> makeReadOnlyCollection
- member _.UnionCases =
+ member _.UnionCases =
if isUnresolved() then makeReadOnlyCollection [] else
entity.UnionCasesAsRefList
- |> List.map (fun x -> FSharpUnionCase(cenv, x))
+ |> List.map (fun x -> FSharpUnionCase(cenv, x))
|> makeReadOnlyCollection
member _.FSharpFields =
if isUnresolved() then makeReadOnlyCollection [] else
-
+
if entity.IsILEnumTycon then
let (TILObjectReprData(_scoref, _enc, tdef)) = entity.ILTyconInfo
let formalTypars = entity.Typars(range.Zero)
@@ -752,7 +752,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
|> List.map (fun x -> FSharpField(cenv, mkRecdFieldRef entity x.LogicalName))
|> makeReadOnlyCollection
- member _.AbbreviatedType =
+ member _.AbbreviatedType =
checkIsResolved()
match entity.TypeAbbrev with
@@ -763,7 +763,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
let ty = generalizedTyconRef cenv.g entity
FSharpType(cenv, ty)
- override _.Attributes =
+ override _.Attributes =
if isUnresolved() then makeReadOnlyCollection [] else
GetAttribInfosOfEntity cenv.g cenv.amap range0 entity
|> List.map (fun a -> FSharpAttribute(cenv, a))
@@ -792,17 +792,17 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
| ModuleOrNamespaceKind.FSharpModuleWithSuffix ->
[ yield! loop (mapEachCurrentPath currentPaths name) rest
yield! loop (mapEachCurrentPath currentPaths name[..name.Length - 7]) rest ]
- | _ ->
+ | _ ->
loop (mapEachCurrentPath currentPaths name) rest
loop [] parts |> List.map (List.rev >> String.concat ".")
-
+
let res =
[ for parts in partsList do
yield! walkParts parts ]
res
member x.ActivePatternCases =
- protect <| fun () ->
+ protect <| fun () ->
ActivePatternElemsOfModuleOrNamespace cenv.g x.Entity
|> Map.toList
|> List.map (fun (_, apref) ->
@@ -810,35 +810,35 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
FSharpActivePatternCase(cenv, apref.ActivePatternInfo, apref.ActivePatternVal.Type, apref.CaseIndex, Some apref.ActivePatternVal, item))
member x.TryGetFullName() =
- try x.TryFullName
- with _ ->
+ try x.TryFullName
+ with _ ->
try Some(String.Join(".", x.AccessPath, x.DisplayName))
with _ -> None
member x.TryGetFullDisplayName() =
let fullName = x.TryGetFullName() |> Option.map (fun fullName -> fullName.Split '.')
- let res =
+ let res =
match fullName with
| Some fullName ->
match Option.attempt (fun _ -> x.DisplayName) with
| Some shortDisplayName when not (shortDisplayName.Contains ".") ->
Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName)
| _ -> Some fullName
- | None -> None
+ | None -> None
|> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName))
//debug "GetFullDisplayName: FullName = %A, Result = %A" fullName res
res
member x.TryGetFullCompiledName() =
let fullName = x.TryGetFullName() |> Option.map (fun fullName -> fullName.Split '.')
- let res =
+ let res =
match fullName with
| Some fullName ->
match Option.attempt (fun _ -> x.CompiledName) with
| Some shortCompiledName when not (shortCompiledName.Contains ".") ->
Some (fullName |> Array.replace (fullName.Length - 1) shortCompiledName)
| _ -> Some fullName
- | None -> None
+ | None -> None
|> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName))
//debug "GetFullCompiledName: FullName = %A, Result = %A" fullName res
res
@@ -846,7 +846,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
member x.GetPublicNestedEntities() =
x.NestedEntities |> Seq.filter (fun entity -> entity.Accessibility.IsPublic)
- member x.TryGetMembersFunctionsAndValues() =
+ member x.TryGetMembersFunctionsAndValues() =
try x.MembersFunctionsAndValues with _ -> [||] :> _
member this.TryGetMetadataText() =
@@ -871,7 +871,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
getOpenPath accessPath (name :: acc)
getOpenPath cpath.AccessPath []
- | _ ->
+ | _ ->
[]
|> List.rev
@@ -900,7 +900,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
Layout.emptyL
else
Layout.sepListL (Layout.sepL TaggedText.dot) openPathL
-
+
let headerL =
if List.isEmpty extraOpenPath then
Layout.emptyL
@@ -909,7 +909,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
(Layout.wordL (TaggedText.tagKeyword "namespace"))
pathL
- let openL =
+ let openL =
if List.isEmpty openPathL then Layout.emptyL
else
let openKeywordL =
@@ -918,7 +918,7 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
(Layout.wordL (TaggedText.tagKeyword "open"))
(Layout.wordL TaggedText.keywordType)
else
- Layout.wordL (TaggedText.tagKeyword "open")
+ Layout.wordL (TaggedText.tagKeyword "open")
Layout.(^^)
openKeywordL
pathL
@@ -948,32 +948,32 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
override x.ToString() = x.CompiledName
type FSharpUnionCase(cenv, v: UnionCaseRef) =
- inherit FSharpSymbol (cenv,
- (fun () ->
+ inherit FSharpSymbol (cenv,
+ (fun () ->
checkEntityIsResolved v.TyconRef
- Item.UnionCase(UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange, v), false)),
- (fun _this thisCcu2 ad ->
- checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, v.UnionCase.Accessibility))
+ Item.UnionCase(UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange, v), false)),
+ (fun _this thisCcu2 ad ->
+ checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, v.UnionCase.Accessibility))
//&& AccessibilityLogic.IsUnionCaseAccessible cenv.amap range0 ad v)
)
let isUnresolved() =
- entityIsUnresolved v.TyconRef || v.TryUnionCase.IsNone
-
- let checkIsResolved() =
+ entityIsUnresolved v.TyconRef || v.TryUnionCase.IsNone
+
+ let checkIsResolved() =
checkEntityIsResolved v.TyconRef
- if v.TryUnionCase.IsNone then
+ if v.TryUnionCase.IsNone then
invalidOp (sprintf "The union case '%s' could not be found in the target type" v.CaseName)
- member _.IsUnresolved =
+ member _.IsUnresolved =
isUnresolved()
- member _.Name =
+ member _.Name =
checkIsResolved()
v.UnionCase.LogicalName
- member _.DeclarationLocation =
+ member _.DeclarationLocation =
checkIsResolved()
v.Range
@@ -981,11 +981,11 @@ type FSharpUnionCase(cenv, v: UnionCaseRef) =
if isUnresolved() then false else
v.UnionCase.RecdFieldsArray.Length <> 0
- member _.Fields =
+ member _.Fields =
if isUnresolved() then makeReadOnlyCollection [] else
v.UnionCase.RecdFieldsArray |> Array.mapi (fun i _ -> FSharpField(cenv, FSharpFieldData.Union (v, i))) |> makeReadOnlyCollection
- member _.ReturnType =
+ member _.ReturnType =
checkIsResolved()
FSharpType(cenv, v.ReturnType)
@@ -993,26 +993,26 @@ type FSharpUnionCase(cenv, v: UnionCaseRef) =
checkIsResolved()
v.UnionCase.CompiledName
- member _.XmlDocSig =
+ member _.XmlDocSig =
checkIsResolved()
let unionCase = UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange, v)
match GetXmlDocSigOfUnionCaseRef unionCase.UnionCaseRef with
| Some (_, docsig) -> docsig
| _ -> ""
- member _.XmlDoc =
+ member _.XmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeXmlDoc else
v.UnionCase.XmlDoc |> makeXmlDoc
- member _.ElaboratedXmlDoc =
+ member _.ElaboratedXmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeElaboratedXmlDoc else
v.UnionCase.XmlDoc |> makeElaboratedXmlDoc
- override _.Attributes =
+ override _.Attributes =
if isUnresolved() then makeReadOnlyCollection [] else
v.Attribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a))) |> makeReadOnlyCollection
- override _.Accessibility =
+ override _.Accessibility =
if isUnresolved() then FSharpAccessibility taccessPublic else
FSharpAccessibility(v.UnionCase.Accessibility)
@@ -1027,21 +1027,21 @@ type FSharpUnionCase(cenv, v: UnionCaseRef) =
override x.ToString() = x.CompiledName
-type FSharpFieldData =
+type FSharpFieldData =
| AnonField of AnonRecdTypeInfo * TTypes * int * range
| ILField of ILFieldInfo
| RecdOrClass of RecdFieldRef
| Union of UnionCaseRef * int
member x.TryRecdField =
- match x with
+ match x with
| AnonField (anonInfo, tinst, n, m) -> (anonInfo, tinst, n, m) |> Choice3Of3
| RecdOrClass v -> v.RecdField |> Choice1Of3
| Union (v, n) -> v.FieldByIndex n |> Choice1Of3
| ILField f -> f |> Choice2Of3
member x.TryDeclaringTyconRef =
- match x with
+ match x with
| RecdOrClass v -> Some v.TyconRef
| ILField f -> Some f.DeclaringTyconRef
| _ -> None
@@ -1059,44 +1059,44 @@ type FSharpAnonRecordTypeDetails(cenv: SymbolEnv, anonInfo: AnonRecdTypeInfo) =
member _.SortedFieldNames = anonInfo.SortedNames
type FSharpField(cenv: SymbolEnv, d: FSharpFieldData) =
- inherit FSharpSymbol (cenv,
- (fun () ->
- match d with
- | AnonField (anonInfo, tinst, n, m) ->
+ inherit FSharpSymbol (cenv,
+ (fun () ->
+ match d with
+ | AnonField (anonInfo, tinst, n, m) ->
Item.AnonRecdField(anonInfo, tinst, n, m)
- | RecdOrClass v ->
+ | RecdOrClass v ->
checkEntityIsResolved v.TyconRef
Item.RecdField(RecdFieldInfo(generalizeTypars v.TyconRef.TyparsNoRange, v))
| Union (v, fieldIndex) ->
checkEntityIsResolved v.TyconRef
Item.UnionCaseField (UnionCaseInfo (generalizeTypars v.TyconRef.TyparsNoRange, v), fieldIndex)
- | ILField f ->
- Item.ILField f),
- (fun this thisCcu2 ad ->
- checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, (this :?> FSharpField).Accessibility.Contents))
+ | ILField f ->
+ Item.ILField f),
+ (fun this thisCcu2 ad ->
+ checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, (this :?> FSharpField).Accessibility.Contents))
//&&
- //match d with
+ //match d with
//| Recd v -> AccessibilityLogic.IsRecdFieldAccessible cenv.amap range0 ad v
//| Union (v, _) -> AccessibilityLogic.IsUnionCaseAccessible cenv.amap range0 ad v)
)
- let isUnresolved() =
+ let isUnresolved() =
d.TryDeclaringTyconRef |> Option.exists entityIsUnresolved ||
match d with
| AnonField _ -> false
- | RecdOrClass v -> v.TryRecdField.IsNone
- | Union (v, _) -> v.TryUnionCase.IsNone
+ | RecdOrClass v -> v.TryRecdField.IsNone
+ | Union (v, _) -> v.TryUnionCase.IsNone
| ILField _ -> false
- let checkIsResolved() =
- d.TryDeclaringTyconRef |> Option.iter checkEntityIsResolved
- match d with
+ let checkIsResolved() =
+ d.TryDeclaringTyconRef |> Option.iter checkEntityIsResolved
+ match d with
| AnonField _ -> ()
- | RecdOrClass v ->
- if v.TryRecdField.IsNone then
+ | RecdOrClass v ->
+ if v.TryRecdField.IsNone then
invalidOp (sprintf "The record field '%s' could not be found in the target type" v.FieldName)
- | Union (v, _) ->
- if v.TryUnionCase.IsNone then
+ | Union (v, _) ->
+ if v.TryUnionCase.IsNone then
invalidOp (sprintf "The union case '%s' could not be found in the target type" v.CaseName)
| ILField _ -> ()
@@ -1104,59 +1104,59 @@ type FSharpField(cenv: SymbolEnv, d: FSharpFieldData) =
new (cenv, rfref: RecdFieldRef) = FSharpField(cenv, FSharpFieldData.RecdOrClass rfref)
- member _.DeclaringEntity =
+ member _.DeclaringEntity =
d.TryDeclaringTyconRef |> Option.map (fun tcref -> FSharpEntity(cenv, tcref))
- member _.IsUnresolved =
+ member _.IsUnresolved =
isUnresolved()
- member _.IsMutable =
- if isUnresolved() then false else
- match d.TryRecdField with
+ member _.IsMutable =
+ if isUnresolved() then false else
+ match d.TryRecdField with
| Choice1Of3 r -> r.IsMutable
| Choice2Of3 f -> not f.IsInitOnly && f.LiteralValue.IsNone
| Choice3Of3 _ -> false
- member _.IsLiteral =
- if isUnresolved() then false else
- match d.TryRecdField with
+ member _.IsLiteral =
+ if isUnresolved() then false else
+ match d.TryRecdField with
| Choice1Of3 r -> r.LiteralValue.IsSome
| Choice2Of3 f -> f.LiteralValue.IsSome
| Choice3Of3 _ -> false
- member _.LiteralValue =
- if isUnresolved() then None else
- match d.TryRecdField with
+ member _.LiteralValue =
+ if isUnresolved() then None else
+ match d.TryRecdField with
| Choice1Of3 r -> getLiteralValue r.LiteralValue
| Choice2Of3 f -> f.LiteralValue |> Option.map (fun v -> v.AsObject())
| Choice3Of3 _ -> None
- member _.IsVolatile =
- if isUnresolved() then false else
- match d.TryRecdField with
+ member _.IsVolatile =
+ if isUnresolved() then false else
+ match d.TryRecdField with
| Choice1Of3 r -> r.IsVolatile
| Choice2Of3 _ -> false // F# doesn't actually respect "volatile" from other assemblies in any case
| Choice3Of3 _ -> false
- member _.IsDefaultValue =
- if isUnresolved() then false else
- match d.TryRecdField with
+ member _.IsDefaultValue =
+ if isUnresolved() then false else
+ match d.TryRecdField with
| Choice1Of3 r -> r.IsZeroInit
- | Choice2Of3 _ -> false
+ | Choice2Of3 _ -> false
| Choice3Of3 _ -> false
- member _.IsAnonRecordField =
- match d with
+ member _.IsAnonRecordField =
+ match d with
| AnonField _ -> true
| _ -> false
- member _.AnonRecordFieldDetails =
- match d with
+ member _.AnonRecordFieldDetails =
+ match d with
| AnonField (anonInfo, types, n, _) -> FSharpAnonRecordTypeDetails(cenv, anonInfo), [| for ty in types -> FSharpType(cenv, ty) |], n
| _ -> invalidOp "not an anonymous record field"
- member _.IsUnionCaseField =
- match d with
+ member _.IsUnionCaseField =
+ match d with
| Union _ -> true
| _ -> false
@@ -1165,65 +1165,65 @@ type FSharpField(cenv: SymbolEnv, d: FSharpFieldData) =
| Union (v, _) -> Some (FSharpUnionCase (cenv, v))
| _ -> None
- member _.XmlDocSig =
+ member _.XmlDocSig =
checkIsResolved()
let xmlsig =
- match d with
- | RecdOrClass v ->
+ match d with
+ | RecdOrClass v ->
let recd = RecdFieldInfo(generalizeTypars v.TyconRef.TyparsNoRange, v)
GetXmlDocSigOfRecdFieldRef recd.RecdFieldRef
- | Union (v, _) ->
+ | Union (v, _) ->
let unionCase = UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange, v)
GetXmlDocSigOfUnionCaseRef unionCase.UnionCaseRef
- | ILField f ->
+ | ILField f ->
GetXmlDocSigOfILFieldInfo cenv.infoReader range0 f
| AnonField _ -> None
match xmlsig with
| Some (_, docsig) -> docsig
| _ -> ""
- member _.XmlDoc =
+ member _.XmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeXmlDoc else
- match d.TryRecdField with
- | Choice1Of3 r -> r.XmlDoc
+ match d.TryRecdField with
+ | Choice1Of3 r -> r.XmlDoc
| Choice2Of3 _ -> XmlDoc.Empty
| Choice3Of3 _ -> XmlDoc.Empty
|> makeXmlDoc
- member _.ElaboratedXmlDoc =
+ member _.ElaboratedXmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeElaboratedXmlDoc else
- match d.TryRecdField with
- | Choice1Of3 r -> r.XmlDoc
+ match d.TryRecdField with
+ | Choice1Of3 r -> r.XmlDoc
| Choice2Of3 _ -> XmlDoc.Empty
| Choice3Of3 _ -> XmlDoc.Empty
|> makeElaboratedXmlDoc
- member _.FieldType =
+ member _.FieldType =
checkIsResolved()
- let fty =
- match d.TryRecdField with
+ let fty =
+ match d.TryRecdField with
| Choice1Of3 r -> r.FormalType
| Choice2Of3 f -> f.FieldType(cenv.amap, range0)
| Choice3Of3 (_,tinst,n,_) -> tinst[n]
FSharpType(cenv, fty)
- member _.IsStatic =
- if isUnresolved() then false else
- match d.TryRecdField with
+ member _.IsStatic =
+ if isUnresolved() then false else
+ match d.TryRecdField with
| Choice1Of3 r -> r.IsStatic
| Choice2Of3 f -> f.IsStatic
| Choice3Of3 _ -> false
- member _.Name =
+ member _.Name =
checkIsResolved()
- match d.TryRecdField with
+ match d.TryRecdField with
| Choice1Of3 r -> r.LogicalName
| Choice2Of3 f -> f.FieldName
| Choice3Of3 (anonInfo, _tinst, n, _) -> anonInfo.SortedNames[n]
- member _.IsCompilerGenerated =
- if isUnresolved() then false else
- match d.TryRecdField with
+ member _.IsCompilerGenerated =
+ if isUnresolved() then false else
+ match d.TryRecdField with
| Choice1Of3 r -> r.IsCompilerGenerated
| Choice2Of3 _ -> false
| Choice3Of3 _ -> false
@@ -1234,45 +1234,45 @@ type FSharpField(cenv: SymbolEnv, d: FSharpFieldData) =
| Choice1Of3 r -> r.rfield_name_generated
| _ -> false
- member _.DeclarationLocation =
+ member _.DeclarationLocation =
checkIsResolved()
- match d.TryRecdField with
+ match d.TryRecdField with
| Choice1Of3 r -> r.Range
| Choice2Of3 _ -> range0
| Choice3Of3 (_anonInfo, _tinst, _n, m) -> m
- member _.FieldAttributes =
- if isUnresolved() then makeReadOnlyCollection [] else
- match d.TryRecdField with
- | Choice1Of3 r -> r.FieldAttribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
- | Choice2Of3 _ -> []
+ member _.FieldAttributes =
+ if isUnresolved() then makeReadOnlyCollection [] else
+ match d.TryRecdField with
+ | Choice1Of3 r -> r.FieldAttribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
+ | Choice2Of3 _ -> []
| Choice3Of3 _ -> []
|> makeReadOnlyCollection
- member _.PropertyAttributes =
- if isUnresolved() then makeReadOnlyCollection [] else
- match d.TryRecdField with
- | Choice1Of3 r -> r.PropertyAttribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
- | Choice2Of3 _ -> []
+ member _.PropertyAttributes =
+ if isUnresolved() then makeReadOnlyCollection [] else
+ match d.TryRecdField with
+ | Choice1Of3 r -> r.PropertyAttribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
+ | Choice2Of3 _ -> []
| Choice3Of3 _ -> []
|> makeReadOnlyCollection
- override _.Accessibility: FSharpAccessibility =
- if isUnresolved() then FSharpAccessibility taccessPublic else
- let access =
- match d.TryRecdField with
+ override _.Accessibility: FSharpAccessibility =
+ if isUnresolved() then FSharpAccessibility taccessPublic else
+ let access =
+ match d.TryRecdField with
| Choice1Of3 r -> r.Accessibility
| Choice2Of3 _ -> taccessPublic
| Choice3Of3 _ -> taccessPublic
- FSharpAccessibility access
+ FSharpAccessibility access
member private x.V = d
override x.Equals(other: obj) =
box x === other ||
match other with
- | :? FSharpField as uc ->
- match d, uc.V with
+ | :? FSharpField as uc ->
+ match d, uc.V with
| RecdOrClass r1, RecdOrClass r2 -> recdFieldRefOrder.Compare(r1, r2) = 0
| Union (u1, n1), Union (u2, n2) -> cenv.g.unionCaseRefEq u1 u2 && n1 = n2
| AnonField (anonInfo1, _, _, _), AnonField (anonInfo2, _, _, _) -> x.Name = uc.Name && anonInfoEquiv anonInfo1 anonInfo2
@@ -1288,10 +1288,10 @@ type [] FSharpAccessibilityRights(thisCcu: CcuThunk, ad:AccessorDomain) =
member internal _.Contents = ad
-type FSharpActivePatternCase(cenv, apinfo: ActivePatternInfo, ty, n, valOpt: ValRef option, item) =
+type FSharpActivePatternCase(cenv, apinfo: ActivePatternInfo, ty, n, valOpt: ValRef option, item) =
- inherit FSharpSymbol (cenv,
- (fun () -> item),
+ inherit FSharpSymbol (cenv,
+ (fun () -> item),
(fun _ _ _ -> true))
member _.Name = apinfo.ActiveTags[n]
@@ -1302,16 +1302,16 @@ type FSharpActivePatternCase(cenv, apinfo: ActivePatternInfo, ty, n, valOpt: Val
member _.Group = FSharpActivePatternGroup(cenv, apinfo, ty, valOpt)
- member _.XmlDoc =
+ member _.XmlDoc =
defaultArg (valOpt |> Option.map (fun vref -> vref.XmlDoc)) XmlDoc.Empty
|> makeXmlDoc
- member _.ElaboratedXmlDoc =
+ member _.ElaboratedXmlDoc =
defaultArg (valOpt |> Option.map (fun vref -> vref.XmlDoc)) XmlDoc.Empty
|> makeElaboratedXmlDoc
- member _.XmlDocSig =
- let xmlsig =
+ member _.XmlDocSig =
+ let xmlsig =
match valOpt with
| Some valref -> GetXmlDocSigOfValRef cenv.g valref
| None -> None
@@ -1329,17 +1329,17 @@ type FSharpActivePatternGroup(cenv, apinfo:ActivePatternInfo, ty, valOpt) =
member _.OverallType = FSharpType(cenv, ty)
- member _.DeclaringEntity =
- valOpt
- |> Option.bind (fun vref ->
- match vref.TryDeclaringEntity with
+ member _.DeclaringEntity =
+ valOpt
+ |> Option.bind (fun vref ->
+ match vref.TryDeclaringEntity with
| ParentNone -> None
| Parent tcref -> Some (FSharpEntity(cenv, tcref)))
-type FSharpGenericParameter(cenv, v:Typar) =
+type FSharpGenericParameter(cenv, v:Typar) =
- inherit FSharpSymbol (cenv,
- (fun () -> Item.TypeVar(v.Name, v)),
+ inherit FSharpSymbol (cenv,
+ (fun () -> Item.TypeVar(v.Name, v)),
(fun _ _ _ad -> true))
member _.Range = v.Range
@@ -1349,7 +1349,7 @@ type FSharpGenericParameter(cenv, v:Typar) =
member _.DeclarationLocation = v.Range
member _.IsCompilerGenerated = v.IsCompilerGenerated
-
+
member _.IsMeasure = (v.Kind = TyparKind.Measure)
member _.XmlDoc = v.XmlDoc |> makeXmlDoc
@@ -1358,13 +1358,13 @@ type FSharpGenericParameter(cenv, v:Typar) =
member _.IsSolveAtCompileTime = (v.StaticReq = TyparStaticReq.HeadType)
- override _.Attributes =
+ override _.Attributes =
// INCOMPLETENESS: If the type parameter comes from .NET then the .NET metadata for the type parameter
- // has been lost (it is not accessible via Typar). So we can't easily report the attributes in this
+ // has been lost (it is not accessible via Typar). So we can't easily report the attributes in this
// case.
v.Attribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a))) |> makeReadOnlyCollection
member _.Constraints = v.Constraints |> List.map (fun a -> FSharpGenericParameterConstraint(cenv, a)) |> makeReadOnlyCollection
-
+
member internal x.TypeParameter = v
override x.Equals(other: obj) =
@@ -1377,14 +1377,14 @@ type FSharpGenericParameter(cenv, v:Typar) =
override x.ToString() = "generic parameter " + x.Name
-type FSharpDelegateSignature(cenv, info: SlotSig) =
+type FSharpDelegateSignature(cenv, info: SlotSig) =
- member _.DelegateArguments =
+ member _.DelegateArguments =
info.FormalParams.Head
|> List.map (fun (TSlotParam(nm, ty, _, _, _, _)) -> nm, FSharpType(cenv, ty))
|> makeReadOnlyCollection
- member _.DelegateReturnType =
+ member _.DelegateReturnType =
match info.FormalReturnType with
| None -> FSharpType(cenv, cenv.g.unit_ty)
| Some ty -> FSharpType(cenv, ty)
@@ -1392,7 +1392,7 @@ type FSharpDelegateSignature(cenv, info: SlotSig) =
type FSharpAbstractParameter(cenv, info: SlotParam) =
- member _.Name =
+ member _.Name =
let (TSlotParam(name, _, _, _, _, _)) = info
name
@@ -1417,37 +1417,37 @@ type FSharpAbstractParameter(cenv, info: SlotParam) =
type FSharpAbstractSignature(cenv, info: SlotSig) =
- member _.AbstractArguments =
+ member _.AbstractArguments =
info.FormalParams
|> List.map (List.map (fun p -> FSharpAbstractParameter(cenv, p)) >> makeReadOnlyCollection)
|> makeReadOnlyCollection
- member _.AbstractReturnType =
+ member _.AbstractReturnType =
match info.FormalReturnType with
| None -> FSharpType(cenv, cenv.g.unit_ty)
| Some ty -> FSharpType(cenv, ty)
member _.DeclaringTypeGenericParameters =
- info.ClassTypars
+ info.ClassTypars
|> List.map (fun t -> FSharpGenericParameter(cenv, t))
|> makeReadOnlyCollection
-
+
member _.MethodGenericParameters =
- info.MethodTypars
+ info.MethodTypars
|> List.map (fun t -> FSharpGenericParameter(cenv, t))
|> makeReadOnlyCollection
- member _.Name = info.Name
-
+ member _.Name = info.Name
+
member _.DeclaringType = FSharpType(cenv, info.DeclaringType)
-type FSharpGenericParameterMemberConstraint(cenv, info: TraitConstraintInfo) =
- inherit FSharpSymbol (cenv,
- (fun () -> Item.Trait(info)),
+type FSharpGenericParameterMemberConstraint(cenv, info: TraitConstraintInfo) =
+ inherit FSharpSymbol (cenv,
+ (fun () -> Item.Trait(info)),
(fun _ _ _ad -> true))
- let (TTrait(tys, nm, flags, atys, retTy, _)) = info
- member _.MemberSources =
+ let (TTrait(tys, nm, flags, atys, retTy, _)) = info
+ member _.MemberSources =
tys |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection
member _.MemberName = nm
@@ -1457,126 +1457,126 @@ type FSharpGenericParameterMemberConstraint(cenv, info: TraitConstraintInfo) =
member _.MemberArgumentTypes = atys |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection
member _.MemberReturnType =
- match retTy with
- | None -> FSharpType(cenv, cenv.g.unit_ty)
- | Some ty -> FSharpType(cenv, ty)
+ match retTy with
+ | None -> FSharpType(cenv, cenv.g.unit_ty)
+ | Some ty -> FSharpType(cenv, ty)
override x.ToString() = ""
-type FSharpGenericParameterDelegateConstraint(cenv, tupledArgTy: TType, retTy: TType) =
+type FSharpGenericParameterDelegateConstraint(cenv, tupledArgTy: TType, retTy: TType) =
member _.DelegateTupledArgumentType = FSharpType(cenv, tupledArgTy)
member _.DelegateReturnType = FSharpType(cenv, retTy)
override x.ToString() = ""
-type FSharpGenericParameterDefaultsToConstraint(cenv, pri:int, ty:TType) =
- member _.DefaultsToPriority = pri
- member _.DefaultsToTarget = FSharpType(cenv, ty)
+type FSharpGenericParameterDefaultsToConstraint(cenv, pri:int, ty:TType) =
+ member _.DefaultsToPriority = pri
+ member _.DefaultsToTarget = FSharpType(cenv, ty)
override x.ToString() = ""
-type FSharpGenericParameterConstraint(cenv, cx: TyparConstraint) =
+type FSharpGenericParameterConstraint(cenv, cx: TyparConstraint) =
- member _.IsCoercesToConstraint =
- match cx with
- | TyparConstraint.CoercesTo _ -> true
+ member _.IsCoercesToConstraint =
+ match cx with
+ | TyparConstraint.CoercesTo _ -> true
| _ -> false
- member _.CoercesToTarget =
- match cx with
- | TyparConstraint.CoercesTo(ty, _) -> FSharpType(cenv, ty)
+ member _.CoercesToTarget =
+ match cx with
+ | TyparConstraint.CoercesTo(ty, _) -> FSharpType(cenv, ty)
| _ -> invalidOp "not a coerces-to constraint"
- member _.IsDefaultsToConstraint =
- match cx with
- | TyparConstraint.DefaultsTo _ -> true
+ member _.IsDefaultsToConstraint =
+ match cx with
+ | TyparConstraint.DefaultsTo _ -> true
| _ -> false
- member _.DefaultsToConstraintData =
- match cx with
- | TyparConstraint.DefaultsTo(pri, ty, _) -> FSharpGenericParameterDefaultsToConstraint(cenv, pri, ty)
+ member _.DefaultsToConstraintData =
+ match cx with
+ | TyparConstraint.DefaultsTo(pri, ty, _) -> FSharpGenericParameterDefaultsToConstraint(cenv, pri, ty)
| _ -> invalidOp "not a 'defaults-to' constraint"
member _.IsSupportsNullConstraint = match cx with TyparConstraint.SupportsNull _ -> true | _ -> false
- member _.IsMemberConstraint =
- match cx with
- | TyparConstraint.MayResolveMember _ -> true
+ member _.IsMemberConstraint =
+ match cx with
+ | TyparConstraint.MayResolveMember _ -> true
| _ -> false
- member _.MemberConstraintData =
- match cx with
- | TyparConstraint.MayResolveMember(info, _) -> FSharpGenericParameterMemberConstraint(cenv, info)
+ member _.MemberConstraintData =
+ match cx with
+ | TyparConstraint.MayResolveMember(info, _) -> FSharpGenericParameterMemberConstraint(cenv, info)
| _ -> invalidOp "not a member constraint"
- member _.IsNonNullableValueTypeConstraint =
- match cx with
- | TyparConstraint.IsNonNullableStruct _ -> true
+ member _.IsNonNullableValueTypeConstraint =
+ match cx with
+ | TyparConstraint.IsNonNullableStruct _ -> true
| _ -> false
-
- member _.IsReferenceTypeConstraint =
- match cx with
- | TyparConstraint.IsReferenceType _ -> true
+
+ member _.IsReferenceTypeConstraint =
+ match cx with
+ | TyparConstraint.IsReferenceType _ -> true
| _ -> false
- member _.IsSimpleChoiceConstraint =
- match cx with
- | TyparConstraint.SimpleChoice _ -> true
+ member _.IsSimpleChoiceConstraint =
+ match cx with
+ | TyparConstraint.SimpleChoice _ -> true
| _ -> false
- member _.SimpleChoices =
- match cx with
- | TyparConstraint.SimpleChoice (tys, _) ->
+ member _.SimpleChoices =
+ match cx with
+ | TyparConstraint.SimpleChoice (tys, _) ->
tys |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection
| _ -> invalidOp "incorrect constraint kind"
- member _.IsRequiresDefaultConstructorConstraint =
- match cx with
- | TyparConstraint.RequiresDefaultConstructor _ -> true
+ member _.IsRequiresDefaultConstructorConstraint =
+ match cx with
+ | TyparConstraint.RequiresDefaultConstructor _ -> true
| _ -> false
- member _.IsEnumConstraint =
- match cx with
- | TyparConstraint.IsEnum _ -> true
+ member _.IsEnumConstraint =
+ match cx with
+ | TyparConstraint.IsEnum _ -> true
| _ -> false
- member _.EnumConstraintTarget =
- match cx with
+ member _.EnumConstraintTarget =
+ match cx with
| TyparConstraint.IsEnum(ty, _) -> FSharpType(cenv, ty)
| _ -> invalidOp "incorrect constraint kind"
-
- member _.IsComparisonConstraint =
- match cx with
- | TyparConstraint.SupportsComparison _ -> true
+
+ member _.IsComparisonConstraint =
+ match cx with
+ | TyparConstraint.SupportsComparison _ -> true
| _ -> false
- member _.IsEqualityConstraint =
- match cx with
- | TyparConstraint.SupportsEquality _ -> true
+ member _.IsEqualityConstraint =
+ match cx with
+ | TyparConstraint.SupportsEquality _ -> true
| _ -> false
- member _.IsUnmanagedConstraint =
- match cx with
- | TyparConstraint.IsUnmanaged _ -> true
+ member _.IsUnmanagedConstraint =
+ match cx with
+ | TyparConstraint.IsUnmanaged _ -> true
| _ -> false
- member _.IsDelegateConstraint =
- match cx with
- | TyparConstraint.IsDelegate _ -> true
+ member _.IsDelegateConstraint =
+ match cx with
+ | TyparConstraint.IsDelegate _ -> true
| _ -> false
- member _.DelegateConstraintData =
- match cx with
- | TyparConstraint.IsDelegate(ty1, ty2, _) -> FSharpGenericParameterDelegateConstraint(cenv, ty1, ty2)
+ member _.DelegateConstraintData =
+ match cx with
+ | TyparConstraint.IsDelegate(ty1, ty2, _) -> FSharpGenericParameterDelegateConstraint(cenv, ty1, ty2)
| _ -> invalidOp "not a delegate constraint"
override x.ToString() = ""
-type FSharpInlineAnnotation =
- | AlwaysInline
- | OptionalInline
- | NeverInline
- | AggressiveInline
+type FSharpInlineAnnotation =
+ | AlwaysInline
+ | OptionalInline
+ | NeverInline
+ | AggressiveInline
-type FSharpMemberOrValData =
+type FSharpMemberOrValData =
| E of EventInfo
| P of PropInfo
| M of MethInfo
@@ -1587,17 +1587,17 @@ type FSharpMemberOrVal = FSharpMemberOrFunctionOrValue
type FSharpMemberFunctionOrValue = FSharpMemberOrFunctionOrValue
-type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
-
- inherit FSharpSymbol(cenv,
- (fun () -> item),
- (fun this thisCcu2 ad ->
- let this = this :?> FSharpMemberOrFunctionOrValue
- checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, this.Accessibility.Contents))
- //&&
- //match d with
- //| E e ->
- // match e with
+type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
+
+ inherit FSharpSymbol(cenv,
+ (fun () -> item),
+ (fun this thisCcu2 ad ->
+ let this = this :?> FSharpMemberOrFunctionOrValue
+ checkForCrossProjectAccessibility cenv.g.ilg (thisCcu2, ad) (cenv.thisCcu, this.Accessibility.Contents))
+ //&&
+ //match d with
+ //| E e ->
+ // match e with
// | EventInfo.ILEvent (_, e) -> AccessibilityLogic.IsILEventInfoAccessible g cenv.amap range0 ad e
// | EventInfo.FSEvent (_, _, vref, _) -> AccessibilityLogic.IsValAccessible ad vref
// | _ -> true
@@ -1606,20 +1606,20 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
//| V v -> AccessibilityLogic.IsValAccessible ad v
)
- let fsharpInfo() =
- match d with
- | M m | C m -> m.ArbitraryValRef
- | P p -> p.ArbitraryValRef
- | E e -> e.ArbitraryValRef
+ let fsharpInfo() =
+ match d with
+ | M m | C m -> m.ArbitraryValRef
+ | P p -> p.ArbitraryValRef
+ | E e -> e.ArbitraryValRef
| V v -> Some v
-
- let isUnresolved() =
- match fsharpInfo() with
+
+ let isUnresolved() =
+ match fsharpInfo() with
| None -> false
| Some v -> v.TryDeref.IsNone
- let checkIsResolved() =
- if isUnresolved() then
+ let checkIsResolved() =
+ if isUnresolved() then
let v = (fsharpInfo()).Value
let nm = (match v with VRefNonLocal n -> n.ItemKey.PartialKey.LogicalName | _ -> "")
invalidOp (sprintf "The value or member '%s' does not exist or is in an unresolved assembly." nm)
@@ -1635,14 +1635,14 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
else
FSharpMemberFunctionOrValue(cenv, M minfo, Item.MethodGroup(minfo.LogicalName, [minfo], None))
- member _.IsUnresolved =
+ member _.IsUnresolved =
isUnresolved()
- member _.DeclarationLocationOpt =
+ member _.DeclarationLocationOpt =
checkIsResolved()
- match fsharpInfo() with
+ match fsharpInfo() with
| Some v -> Some v.Range
- | None -> base.DeclarationLocation
+ | None -> base.DeclarationLocation
member x.GetOverloads matchParameterNumber =
checkIsResolved()
@@ -1668,53 +1668,53 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| _ -> None
| _ -> None
- member x.DeclarationLocation =
+ member x.DeclarationLocation =
checkIsResolved()
- match x.DeclarationLocationOpt with
+ match x.DeclarationLocationOpt with
| Some v -> v
| None -> failwith "DeclarationLocation property not available"
- member _.DeclaringEntity =
+ member _.DeclaringEntity =
checkIsResolved()
- match d with
+ match d with
| E e -> FSharpEntity(cenv, e.DeclaringTyconRef) |> Some
| P p -> FSharpEntity(cenv, p.DeclaringTyconRef) |> Some
| M m | C m -> FSharpEntity(cenv, m.DeclaringTyconRef) |> Some
- | V v ->
- match v.TryDeclaringEntity with
+ | V v ->
+ match v.TryDeclaringEntity with
| ParentNone -> None
| Parent p -> FSharpEntity(cenv, p) |> Some
- member _.ApparentEnclosingEntity =
+ member _.ApparentEnclosingEntity =
checkIsResolved()
- match d with
+ match d with
| E e -> FSharpEntity(cenv, e.ApparentEnclosingTyconRef)
| P p -> FSharpEntity(cenv, p.ApparentEnclosingTyconRef)
| M m | C m -> FSharpEntity(cenv, m.ApparentEnclosingTyconRef)
- | V v ->
- match v.ApparentEnclosingEntity with
- | ParentNone -> invalidOp "the value or member doesn't have a logical parent"
+ | V v ->
+ match v.ApparentEnclosingEntity with
+ | ParentNone -> invalidOp "the value or member doesn't have a logical parent"
| Parent p -> FSharpEntity(cenv, p)
- member _.GenericParameters =
+ member _.GenericParameters =
checkIsResolved()
- let tps =
- match d with
+ let tps =
+ match d with
| E _ -> []
| P _ -> []
| M m | C m -> m.FormalMethodTypars
- | V v -> v.Typars
+ | V v -> v.Typars
tps |> List.map (fun tp -> FSharpGenericParameter(cenv, tp)) |> makeReadOnlyCollection
- member _.FullType =
+ member _.FullType =
checkIsResolved()
- let ty =
- match d with
+ let ty =
+ match d with
| E e -> e.GetDelegateType(cenv.amap, range0)
| P p -> p.GetPropertyType(cenv.amap, range0)
- | M m | C m ->
+ | M m | C m ->
let retTy = m.GetFSharpReturnType(cenv.amap, range0, m.FormalMethodInst)
- let argTysl = m.GetParamTypes(cenv.amap, range0, m.FormalMethodInst)
+ let argTysl = m.GetParamTypes(cenv.amap, range0, m.FormalMethodInst)
mkIteratedFunTy cenv.g (List.map (mkRefTupledTy cenv.g) argTysl) retTy
| V v -> v.TauType
FSharpType(cenv, ty)
@@ -1722,7 +1722,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
member _.HasGetterMethod =
if isUnresolved() then false
else
- match d with
+ match d with
| P p -> p.HasGetter
| E _
| M _
@@ -1731,14 +1731,14 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
member _.GetterMethod =
checkIsResolved()
- match d with
+ match d with
| P p -> mkMethSym p.GetterMethod
- | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated getter method"
+ | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated getter method"
member _.HasSetterMethod =
if isUnresolved() then false
else
- match d with
+ match d with
| P p -> p.HasSetter
| E _
| M _
@@ -1747,74 +1747,74 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
member _.SetterMethod =
checkIsResolved()
- match d with
+ match d with
| P p -> mkMethSym p.SetterMethod
- | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated setter method"
+ | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated setter method"
member _.EventAddMethod =
checkIsResolved()
- match d with
+ match d with
| E e -> mkMethSym e.AddMethod
- | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated add method"
+ | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated add method"
member _.EventRemoveMethod =
checkIsResolved()
- match d with
+ match d with
| E e -> mkMethSym e.RemoveMethod
- | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated remove method"
+ | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated remove method"
member _.EventDelegateType =
checkIsResolved()
- match d with
+ match d with
| E e -> FSharpType(cenv, e.GetDelegateType(cenv.amap, range0))
- | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated event delegate type"
+ | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated event delegate type"
member _.EventIsStandard =
checkIsResolved()
- match d with
- | E e ->
+ match d with
+ | E e ->
let dty = e.GetDelegateType(cenv.amap, range0)
TryDestStandardDelegateType cenv.infoReader range0 AccessibleFromSomewhere dty |> Option.isSome
- | P _ | M _ | C _ | V _ -> invalidOp "the value or member is not an event"
+ | P _ | M _ | C _ | V _ -> invalidOp "the value or member is not an event"
- member _.IsCompilerGenerated =
- if isUnresolved() then false else
- match fsharpInfo() with
+ member _.IsCompilerGenerated =
+ if isUnresolved() then false else
+ match fsharpInfo() with
| None -> false
| Some v ->
v.IsCompilerGenerated
- member _.InlineAnnotation =
- if isUnresolved() then FSharpInlineAnnotation.OptionalInline else
- match fsharpInfo() with
+ member _.InlineAnnotation =
+ if isUnresolved() then FSharpInlineAnnotation.OptionalInline else
+ match fsharpInfo() with
| None -> FSharpInlineAnnotation.OptionalInline
- | Some v ->
- match v.InlineInfo with
+ | Some v ->
+ match v.InlineInfo with
| ValInline.Always -> FSharpInlineAnnotation.AlwaysInline
| ValInline.Optional -> FSharpInlineAnnotation.OptionalInline
| ValInline.Never -> FSharpInlineAnnotation.NeverInline
- member _.IsMutable =
- if isUnresolved() then false else
- match d with
+ member _.IsMutable =
+ if isUnresolved() then false else
+ match d with
| M _ | C _ | P _ | E _ -> false
| V v -> v.IsMutable
- member _.IsModuleValueOrMember =
- if isUnresolved() then false else
- match d with
+ member _.IsModuleValueOrMember =
+ if isUnresolved() then false else
+ match d with
| M _ | C _ | P _ | E _ -> true
| V v -> v.IsMember || v.IsModuleBinding
- member _.IsMember =
- if isUnresolved() then false else
- match d with
+ member _.IsMember =
+ if isUnresolved() then false else
+ match d with
| M _ | C _ | P _ | E _ -> true
- | V v -> v.IsMember
-
- member _.IsDispatchSlot =
- if isUnresolved() then false else
- match d with
+ | V v -> v.IsMember
+
+ member _.IsDispatchSlot =
+ if isUnresolved() then false else
+ match d with
| E e -> e.AddMethod.IsDispatchSlot
| P p -> p.IsDispatchSlot
| M m | C m -> m.IsDispatchSlot
@@ -1825,8 +1825,8 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| M _ -> true
| _ -> false
- member x.IsProperty =
- match d with
+ member x.IsProperty =
+ match d with
| P _ -> true
| _ -> false
@@ -1837,28 +1837,28 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
match vref.TryDeref with
| ValueNone -> false
| ValueSome v -> v.HasSignatureFile
-
- member _.IsEvent =
- match d with
+
+ member _.IsEvent =
+ match d with
| E _ -> true
| _ -> false
- member _.EventForFSharpProperty =
- match d with
+ member _.EventForFSharpProperty =
+ match d with
| P p when p.IsFSharpEventProperty ->
- let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.ApparentEnclosingType
+ let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.ApparentEnclosingType
let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.ApparentEnclosingType
- match minfos1, minfos2 with
- | [addMeth], [removeMeth] ->
- match addMeth.ArbitraryValRef, removeMeth.ArbitraryValRef with
+ match minfos1, minfos2 with
+ | [addMeth], [removeMeth] ->
+ match addMeth.ArbitraryValRef, removeMeth.ArbitraryValRef with
| Some addVal, Some removeVal -> Some (mkEventSym (FSEvent(cenv.g, p, addVal, removeVal)))
| _ -> None
| _ -> None
| _ -> None
- member _.IsEventAddMethod =
- if isUnresolved() then false else
- match d with
+ member _.IsEventAddMethod =
+ if isUnresolved() then false else
+ match d with
| M m ->
let logicalName = m.LogicalName
logicalName.Length > 4 && logicalName.StartsWithOrdinal("add_") &&
@@ -1867,15 +1867,15 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let entityTy = generalizedTyconRef cenv.g m.DeclaringTyconRef
not (isNil (cenv.infoReader.GetImmediateIntrinsicEventsOfType (Some eventName, AccessibleFromSomeFSharpCode, range0, entityTy))) ||
let declaringTy = generalizedTyconRef cenv.g m.DeclaringTyconRef
- match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with
+ match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with
| pinfo :: _ -> pinfo.IsFSharpEventProperty
| _ -> false
| _ -> false
- member _.IsEventRemoveMethod =
- if isUnresolved() then false else
- match d with
+ member _.IsEventRemoveMethod =
+ if isUnresolved() then false else
+ match d with
| M m ->
let logicalName = m.LogicalName
logicalName.Length > 4 && logicalName.StartsWithOrdinal("remove_") &&
@@ -1884,14 +1884,14 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let entityTy = generalizedTyconRef cenv.g m.DeclaringTyconRef
not (isNil (cenv.infoReader.GetImmediateIntrinsicEventsOfType (Some eventName, AccessibleFromSomeFSharpCode, range0, entityTy))) ||
let declaringTy = generalizedTyconRef cenv.g m.DeclaringTyconRef
- match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with
+ match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with
| pinfo :: _ -> pinfo.IsFSharpEventProperty
| _ -> false
| _ -> false
- member _.IsPropertyGetterMethod =
- if isUnresolved() then false else
- match d with
+ member _.IsPropertyGetterMethod =
+ if isUnresolved() then false else
+ match d with
| M m ->
let logicalName = m.LogicalName
logicalName.Length > 4 && logicalName.StartsWithOrdinal("get_") &&
@@ -1902,39 +1902,39 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| V v -> v.IsPropertyGetterMethod
| _ -> false
- member _.IsPropertySetterMethod =
- if isUnresolved() then false else
- match d with
+ member _.IsPropertySetterMethod =
+ if isUnresolved() then false else
+ match d with
| M m ->
let logicalName = m.LogicalName
logicalName.Length > 4 && logicalName.StartsWithOrdinal("set_") &&
- let propName = ChopPropertyName(logicalName)
+ let propName = ChopPropertyName(logicalName)
let declaringTy = generalizedTyconRef cenv.g m.DeclaringTyconRef
not (isNil (GetImmediateIntrinsicPropInfosOfType (Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy))
| V v -> v.IsPropertySetterMethod
| _ -> false
- member _.IsInstanceMember =
- if isUnresolved() then false else
- match d with
+ member _.IsInstanceMember =
+ if isUnresolved() then false else
+ match d with
| E e -> not e.IsStatic
| P p -> not p.IsStatic
| M m | C m -> m.IsInstance
| V v -> v.IsInstanceMember
- member x.IsInstanceMemberInCompiledCode =
- if isUnresolved() then false else
+ member x.IsInstanceMemberInCompiledCode =
+ if isUnresolved() then false else
x.IsInstanceMember &&
- match d with
+ match d with
| E e -> match e.ArbitraryValRef with Some vref -> ValRefIsCompiledAsInstanceMember cenv.g vref | None -> true
| P p -> match p.ArbitraryValRef with Some vref -> ValRefIsCompiledAsInstanceMember cenv.g vref | None -> true
| M m | C m -> match m.ArbitraryValRef with Some vref -> ValRefIsCompiledAsInstanceMember cenv.g vref | None -> true
- | V vref -> ValRefIsCompiledAsInstanceMember cenv.g vref
+ | V vref -> ValRefIsCompiledAsInstanceMember cenv.g vref
- member _.IsExtensionMember =
- if isUnresolved() then false else
- match d with
+ member _.IsExtensionMember =
+ if isUnresolved() then false else
+ match d with
| E e -> e.AddMethod.IsExtensionMember
| P p -> p.IsExtensionMember
| M m -> m.IsExtensionMember
@@ -1942,18 +1942,18 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| C _ -> false
member _.IsOverrideOrExplicitInterfaceImplementation =
- if isUnresolved() then false else
- match d with
+ if isUnresolved() then false else
+ match d with
| E e -> e.AddMethod.IsDefiniteFSharpOverride
| P p -> p.IsDefiniteFSharpOverride
| M m -> m.IsDefiniteFSharpOverride
- | V v ->
+ | V v ->
v.MemberInfo.IsSome && v.IsDefiniteFSharpOverrideMember
| C _ -> false
member _.IsExplicitInterfaceImplementation =
- if isUnresolved() then false else
- match d with
+ if isUnresolved() then false else
+ match d with
| E e -> e.AddMethod.IsFSharpExplicitInterfaceImplementation
| P p -> p.IsFSharpExplicitInterfaceImplementation
| M m -> m.IsFSharpExplicitInterfaceImplementation
@@ -1971,50 +1971,50 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
sigs |> List.map (fun s -> FSharpAbstractSignature (cenv, s))
|> makeReadOnlyCollection
- member _.IsImplicitConstructor =
- if isUnresolved() then false else
- match fsharpInfo() with
+ member _.IsImplicitConstructor =
+ if isUnresolved() then false else
+ match fsharpInfo() with
| None -> false
| Some v -> v.IsIncrClassConstructor
-
- member _.IsTypeFunction =
- if isUnresolved() then false else
- match fsharpInfo() with
+
+ member _.IsTypeFunction =
+ if isUnresolved() then false else
+ match fsharpInfo() with
| None -> false
| Some v -> v.IsTypeFunction
- member _.IsActivePattern =
- if isUnresolved() then false else
- match fsharpInfo() with
+ member _.IsActivePattern =
+ if isUnresolved() then false else
+ match fsharpInfo() with
| Some v -> ActivePatternInfoOfValName v.DisplayNameCoreMangled v.Range |> Option.isSome
| None -> false
- member x.CompiledName =
+ member x.CompiledName =
checkIsResolved()
- match fsharpInfo() with
+ match fsharpInfo() with
| Some v -> v.CompiledName cenv.g.CompilerGlobalState
| None -> x.LogicalName
- member _.LogicalName =
+ member _.LogicalName =
checkIsResolved()
- match d with
+ match d with
| E e -> e.EventName
| P p -> p.PropertyName
| M m | C m -> m.LogicalName
| V v -> v.LogicalName
- member _.DisplayName =
+ member _.DisplayName =
checkIsResolved()
- match d with
+ match d with
| E e -> e.EventName
| P p -> p.PropertyName
| M m | C m -> m.DisplayName
| V v -> v.DisplayName
- member sym.XmlDocSig =
+ member sym.XmlDocSig =
checkIsResolved()
-
- match d with
+
+ match d with
| E e ->
let range = defaultArg sym.DeclarationLocationOpt range0
match GetXmlDocSigOfEvent cenv.infoReader range e with
@@ -2025,40 +2025,40 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
match GetXmlDocSigOfProp cenv.infoReader range p with
| Some (_, docsig) -> docsig
| _ -> ""
- | M m | C m ->
+ | M m | C m ->
let range = defaultArg sym.DeclarationLocationOpt range0
match GetXmlDocSigOfMethInfo cenv.infoReader range m with
| Some (_, docsig) -> docsig
| _ -> ""
| V v ->
- match v.TryDeclaringEntity with
- | Parent entityRef ->
+ match v.TryDeclaringEntity with
+ | Parent entityRef ->
match GetXmlDocSigOfScopedValRef cenv.g entityRef v with
| Some (_, docsig) -> docsig
| _ -> ""
- | ParentNone -> ""
+ | ParentNone -> ""
- member _.XmlDoc =
+ member _.XmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeXmlDoc else
- match d with
+ match d with
| E e -> e.XmlDoc |> makeXmlDoc
| P p -> p.XmlDoc |> makeXmlDoc
| M m | C m -> m.XmlDoc |> makeXmlDoc
| V v -> v.XmlDoc |> makeXmlDoc
- member _.ElaboratedXmlDoc =
+ member _.ElaboratedXmlDoc =
if isUnresolved() then XmlDoc.Empty |> makeElaboratedXmlDoc else
- match d with
+ match d with
| E e -> e.XmlDoc |> makeElaboratedXmlDoc
| P p -> p.XmlDoc |> makeElaboratedXmlDoc
| M m | C m -> m.XmlDoc |> makeElaboratedXmlDoc
| V v -> v.XmlDoc |> makeElaboratedXmlDoc
- member x.CurriedParameterGroups =
+ member x.CurriedParameterGroups =
checkIsResolved()
- match d with
- | P p ->
- [ [ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty) in p.GetParamDatas(cenv.amap, range0) do
+ match d with
+ | P p ->
+ [ [ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty) in p.GetParamDatas(cenv.amap, range0) do
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
// either .NET or F# parameters
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs= [] }
@@ -2069,15 +2069,15 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
defaultArg x.DeclarationLocationOpt range0
- yield FSharpParameter(cenv, pty, argInfo, None, m, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional, false) ]
+ yield FSharpParameter(cenv, pty, argInfo, None, m, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional, false) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection
| E _ -> [] |> makeReadOnlyCollection
- | M m | C m ->
- [ for argTys in m.GetParamDatas(cenv.amap, range0, m.FormalMethodInst) do
+ | M m | C m ->
+ [ for argTys in m.GetParamDatas(cenv.amap, range0, m.FormalMethodInst) do
yield
- [ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty), attribs in argTys do
+ [ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty), attribs in argTys do
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=attribs }
let m =
match nmOpt with
@@ -2085,12 +2085,12 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| None ->
defaultArg x.DeclarationLocationOpt range0
- yield FSharpParameter(cenv, pty, argInfo, None, m, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional, false) ]
+ yield FSharpParameter(cenv, pty, argInfo, None, m, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional, false) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection
- | V v ->
- match v.ValReprInfo with
+ | V v ->
+ match v.ValReprInfo with
| None ->
let _, tau = v.GeneralizedType
if isFunTy cenv.g tau then
@@ -2107,13 +2107,13 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection
else makeReadOnlyCollection []
- | Some (ValReprInfo(_typars, curriedArgInfos, _retInfo)) ->
+ | Some (ValReprInfo(_typars, curriedArgInfos, _retInfo)) ->
let tau = v.TauType
let argTysl, _ = GetTopTauTypeInFSharpForm cenv.g curriedArgInfos tau range0
let argTysl = if v.IsInstanceMember then argTysl.Tail else argTysl
- [ for argTys in argTysl do
- yield
- [ for argTy, argInfo in argTys do
+ [ for argTys in argTysl do
+ yield
+ [ for argTy, argInfo in argTys do
let isParamArrayArg = HasFSharpAttribute cenv.g cenv.g.attrib_ParamArrayAttribute argInfo.Attribs
let isInArg = HasFSharpAttribute cenv.g cenv.g.attrib_InAttribute argInfo.Attribs && isByrefTy cenv.g argTy
let isOutArg = HasFSharpAttribute cenv.g cenv.g.attrib_OutAttribute argInfo.Attribs && isByrefTy cenv.g argTy
@@ -2122,63 +2122,63 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
match argInfo.Name with
| Some v -> v.idRange
| None -> defaultArg x.DeclarationLocationOpt range0
- yield FSharpParameter(cenv, argTy, argInfo, None, m, isParamArrayArg, isInArg, isOutArg, isOptionalArg, false) ]
+ yield FSharpParameter(cenv, argTy, argInfo, None, m, isParamArrayArg, isInArg, isOutArg, isOptionalArg, false) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection
- member x.ReturnParameter =
+ member x.ReturnParameter =
checkIsResolved()
- match d with
- | E einfo ->
+ match d with
+ | E einfo ->
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
let m = defaultArg x.DeclarationLocationOpt range0
- let retTy =
+ let retTy =
try PropTypeOfEventInfo cenv.infoReader m AccessibleFromSomewhere einfo
- with _ ->
+ with _ ->
// For non-standard events, just use the delegate type as the ReturnParameter type
einfo.GetDelegateType(cenv.amap, m)
- FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
+ FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
- | P pinfo ->
+ | P pinfo ->
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
let m = defaultArg x.DeclarationLocationOpt range0
let retTy = pinfo.GetPropertyType(cenv.amap, m)
- FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
+ FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
- | M minfo | C minfo ->
+ | M minfo | C minfo ->
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
let m = defaultArg x.DeclarationLocationOpt range0
let retTy = minfo.GetFSharpReturnType(cenv.amap, m, minfo.FormalMethodInst)
- FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
+ FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
- | V v ->
- match v.ValReprInfo with
+ | V v ->
+ match v.ValReprInfo with
| None ->
let _, tau = v.GeneralizedType
let _argTysl, retTy = stripFunTy cenv.g tau
let m = defaultArg x.DeclarationLocationOpt range0
FSharpParameter(cenv, retTy, ValReprInfo.unnamedRetVal, m)
- | Some (ValReprInfo(_typars, argInfos, retInfo)) ->
+ | Some (ValReprInfo(_typars, argInfos, retInfo)) ->
let tau = v.TauType
let m = defaultArg x.DeclarationLocationOpt range0
let _c, retTy = GetTopTauTypeInFSharpForm cenv.g argInfos tau m
- FSharpParameter(cenv, retTy, retInfo, m)
+ FSharpParameter(cenv, retTy, retInfo, m)
- override _.Attributes =
- if isUnresolved() then makeReadOnlyCollection [] else
+ override _.Attributes =
+ if isUnresolved() then makeReadOnlyCollection [] else
let m = range0
- match d with
- | E einfo ->
+ match d with
+ | E einfo ->
GetAttribInfosOfEvent cenv.amap m einfo |> List.map (fun a -> FSharpAttribute(cenv, a))
- | P pinfo ->
+ | P pinfo ->
GetAttribInfosOfProp cenv.amap m pinfo |> List.map (fun a -> FSharpAttribute(cenv, a))
- | M minfo | C minfo ->
+ | M minfo | C minfo ->
GetAttribInfosOfMethod cenv.amap m minfo |> List.map (fun a -> FSharpAttribute(cenv, a))
- | V v ->
- v.Attribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
+ | V v ->
+ v.Attribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
|> makeReadOnlyCollection
-
+
/// Is this "base" in "base.M(...)"
member _.IsBaseValue =
if isUnresolved() then false else
@@ -2207,43 +2207,43 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| M _ | C _ | P _ | E _ -> None
| V v -> getLiteralValue v.LiteralValue
- /// How visible is this?
- override this.Accessibility: FSharpAccessibility =
- if isUnresolved() then FSharpAccessibility taccessPublic else
- match fsharpInfo() with
+ /// How visible is this?
+ override this.Accessibility: FSharpAccessibility =
+ if isUnresolved() then FSharpAccessibility taccessPublic else
+ match fsharpInfo() with
| Some v -> FSharpAccessibility(v.Accessibility)
- | None ->
-
+ | None ->
+
// Note, returning "public" is wrong for IL members that are private
- match d with
- | E e ->
+ match d with
+ | E e ->
// For IL events, we get an approximate accessibility that at least reports "internal" as "internal" and "private" as "private"
- let access =
- match e with
- | ILEvent ileinfo ->
+ let access =
+ match e with
+ | ILEvent ileinfo ->
let ilAccess = GetILAccessOfILEventInfo ileinfo
getApproxFSharpAccessibilityOfMember this.DeclaringEntity.Value.Entity ilAccess
| _ -> taccessPublic
FSharpAccessibility access
- | P p ->
+ | P p ->
// For IL properties, we get an approximate accessibility that at least reports "internal" as "internal" and "private" as "private"
- let access =
- match p with
- | ILProp ilpinfo ->
+ let access =
+ match p with
+ | ILProp ilpinfo ->
let ilAccess = GetILAccessOfILPropInfo ilpinfo
getApproxFSharpAccessibilityOfMember this.DeclaringEntity.Value.Entity ilAccess
| _ -> taccessPublic
FSharpAccessibility access
- | M m | C m ->
+ | M m | C m ->
// For IL methods, we get an approximate accessibility that at least reports "internal" as "internal" and "private" as "private"
- let access =
- match m with
- | ILMeth (_, x, _) -> getApproxFSharpAccessibilityOfMember x.DeclaringTyconRef x.RawMetadata.Access
+ let access =
+ match m with
+ | ILMeth (_, x, _) -> getApproxFSharpAccessibilityOfMember x.DeclaringTyconRef x.RawMetadata.Access
| _ -> taccessPublic
FSharpAccessibility(access, isProtected=m.IsProtectedAccessibility)
@@ -2284,8 +2284,8 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
box x === other ||
match other with
| :? FSharpMemberOrFunctionOrValue as other ->
- match d, other.Data with
- | E evt1, E evt2 -> EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2
+ match d, other.Data with
+ | E evt1, E evt2 -> EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2
| P p1, P p2 -> PropInfo.PropInfosUseIdenticalDefinitions p1 p2
| M m1, M m2
| C m1, C m2 -> MethInfo.MethInfosUseIdenticalDefinitions m1 m2
@@ -2294,9 +2294,9 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| _ -> false
override x.GetHashCode() = hash (box x.LogicalName)
- override x.ToString() =
- try
- let prefix = (if x.IsEvent then "event " elif x.IsProperty then "property " elif x.IsMember then "member " else "val ")
+ override x.ToString() =
+ try
+ let prefix = (if x.IsEvent then "event " elif x.IsProperty then "property " elif x.IsMember then "member " else "val ")
prefix + x.LogicalName
with _ -> "??"
@@ -2307,13 +2307,13 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
|> LayoutRender.toArray
| _,_ ->
checkIsResolved()
- let ty =
- match d with
+ let ty =
+ match d with
| E e -> e.GetDelegateType(cenv.amap, range0)
| P p -> p.GetPropertyType(cenv.amap, range0)
- | M m | C m ->
+ | M m | C m ->
let retTy = m.GetFSharpReturnType(cenv.amap, range0, m.FormalMethodInst)
- let argTysl = m.GetParamTypes(cenv.amap, range0, m.FormalMethodInst)
+ let argTysl = m.GetParamTypes(cenv.amap, range0, m.FormalMethodInst)
mkIteratedFunTy cenv.g (List.map (mkRefTupledTy cenv.g) argTysl) retTy
| V v -> v.TauType
NicePrint.prettyLayoutOfTypeNoCx (displayContext.Contents cenv.g) ty
@@ -2325,7 +2325,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
None
| false, _ ->
checkIsResolved()
- match d with
+ match d with
| E _
| P _
| C _ -> None
@@ -2338,11 +2338,11 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
NicePrint.layoutOfValReturnType (displayContext.Contents cenv.g) v
|> LayoutRender.toArray
|> Some
-
- member x.GetWitnessPassingInfo() =
- let witnessInfos =
- match d with
- | M (FSMeth(_, _, vref, _)) ->
+
+ member x.GetWitnessPassingInfo() =
+ let witnessInfos =
+ match d with
+ | M (FSMeth(_, _, vref, _)) ->
let _tps, witnessInfos, _curriedArgInfos, _retTy, _ = GetTypeOfMemberInMemberForm cenv.g vref
witnessInfos
| V vref ->
@@ -2351,12 +2351,12 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let _tps, witnessInfos, _curriedArgInfos, _retTy, _ = GetValReprTypeInCompiledForm cenv.g arities numEnclosingTypars vref.Type vref.DefinitionRange
witnessInfos
| E _ | P _ | M _ | C _ -> []
- match witnessInfos with
+ match witnessInfos with
| [] -> None
| _ when not (cenv.g.langVersion.SupportsFeature(Features.LanguageFeature.WitnessPassing)) -> None
| _ ->
- let witnessParams =
- ((Set.empty, 0), witnessInfos) ||> List.mapFold (fun (used,i) witnessInfo ->
+ let witnessParams =
+ ((Set.empty, 0), witnessInfos) ||> List.mapFold (fun (used,i) witnessInfo ->
let paramTy = GenWitnessTy cenv.g witnessInfo
let nm = String.uncapitalize witnessInfo.MemberName
let nm = if used.Contains nm then nm + string i else nm
@@ -2368,7 +2368,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let witnessMethName = ExtraWitnessMethodName x.CompiledName
Some (witnessMethName, makeReadOnlyCollection witnessParams)
- // FullType may raise exceptions (see https://github.com/fsharp/fsharp/issues/307).
+ // FullType may raise exceptions (see https://github.com/fsharp/fsharp/issues/307).
member x.FullTypeSafe = Option.attempt (fun _ -> x.FullType)
member x.TryGetFullDisplayName() =
@@ -2387,65 +2387,72 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
if IsOperatorDisplayName x.DisplayName && x.DisplayName <> x.CompiledName then
x.DeclaringEntity
|> Option.bind (fun e -> e.TryGetFullName())
- |> Option.map (fun enclosingEntityFullName ->
+ |> Option.map (fun enclosingEntityFullName ->
Array.append (enclosingEntityFullName.Split '.') [| x.CompiledName |])
else None
type FSharpType(cenv, ty:TType) =
- let isUnresolved() =
- DiagnosticsLogger.protectAssemblyExploration true <| fun () ->
- match stripTyparEqns ty with
+ let isUnresolved() =
+ DiagnosticsLogger.protectAssemblyExploration true <| fun () ->
+ match stripTyparEqns ty with
| TType_app (tcref, _, _) -> FSharpEntity(cenv, tcref).IsUnresolved
| TType_measure (Measure.Const tcref) -> FSharpEntity(cenv, tcref).IsUnresolved
- | TType_measure (Measure.Prod _) -> FSharpEntity(cenv, cenv.g.measureproduct_tcr).IsUnresolved
- | TType_measure Measure.One -> FSharpEntity(cenv, cenv.g.measureone_tcr).IsUnresolved
- | TType_measure (Measure.Inv _) -> FSharpEntity(cenv, cenv.g.measureinverse_tcr).IsUnresolved
+ | TType_measure (Measure.Prod _) -> FSharpEntity(cenv, cenv.g.measureproduct_tcr).IsUnresolved
+ | TType_measure Measure.One -> FSharpEntity(cenv, cenv.g.measureone_tcr).IsUnresolved
+ | TType_measure (Measure.Inv _) -> FSharpEntity(cenv, cenv.g.measureinverse_tcr).IsUnresolved
| _ -> false
-
+
let isResolved() = not (isUnresolved())
new (g, thisCcu, thisCcuTyp, tcImports, ty) = FSharpType(SymbolEnv(g, thisCcu, Some thisCcuTyp, tcImports), ty)
member _.IsUnresolved = isUnresolved()
- member _.HasTypeDefinition =
+ member _.HasTypeDefinition =
isResolved() &&
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One) -> true
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_app _ | TType_measure (Measure.Const _ | Measure.Prod _ | Measure.Inv _ | Measure.One) -> true
| _ -> false
- member _.IsTupleType =
+ member _.IsMeasureType =
isResolved() &&
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_tuple _ -> true
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_measure _ -> true
| _ -> false
- member _.IsStructTupleType =
+ member _.IsTupleType =
isResolved() &&
- protect <| fun () ->
- match stripTyparEqns ty with
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_tuple _ -> true
+ | _ -> false
+
+ member _.IsStructTupleType =
+ isResolved() &&
+ protect <| fun () ->
+ match stripTyparEqns ty with
| TType_tuple (tupInfo, _) -> evalTupInfoIsStruct tupInfo
| _ -> false
- member _.TypeDefinition =
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_app (tcref, _, _) -> FSharpEntity(cenv, tcref)
- | TType_measure (Measure.Const tcref) -> FSharpEntity(cenv, tcref)
- | TType_measure (Measure.Prod _) -> FSharpEntity(cenv, cenv.g.measureproduct_tcr)
- | TType_measure Measure.One -> FSharpEntity(cenv, cenv.g.measureone_tcr)
- | TType_measure (Measure.Inv _) -> FSharpEntity(cenv, cenv.g.measureinverse_tcr)
+ member _.TypeDefinition =
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_app (tcref, _, _) -> FSharpEntity(cenv, tcref)
+ | TType_measure (Measure.Const tcref) -> FSharpEntity(cenv, tcref)
+ | TType_measure (Measure.Prod _) -> FSharpEntity(cenv, cenv.g.measureproduct_tcr)
+ | TType_measure Measure.One -> FSharpEntity(cenv, cenv.g.measureone_tcr)
+ | TType_measure (Measure.Inv _) -> FSharpEntity(cenv, cenv.g.measureinverse_tcr)
| _ -> invalidOp "not a named type"
- member _.GenericArguments =
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_anon (_, tyargs)
- | TType_app (_, tyargs, _)
- | TType_tuple (_, tyargs) -> (tyargs |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection)
+ member _.GenericArguments =
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_anon (_, tyargs)
+ | TType_app (_, tyargs, _)
+ | TType_tuple (_, tyargs) -> (tyargs |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection)
| TType_fun(domainTy, rangeTy, _) -> [| FSharpType(cenv, domainTy); FSharpType(cenv, rangeTy) |] |> makeReadOnlyCollection
| TType_measure (Measure.Const _) -> [| |] |> makeReadOnlyCollection
| TType_measure (Measure.Prod (t1, t2)) -> [| FSharpType(cenv, TType_measure t1); FSharpType(cenv, TType_measure t2) |] |> makeReadOnlyCollection
@@ -2454,64 +2461,64 @@ type FSharpType(cenv, ty:TType) =
| _ -> invalidOp "not a named type"
(*
- member _.ProvidedArguments =
- let typeName, argNamesAndValues =
- try
- PrettyNaming.DemangleProvidedTypeName typeLogicalName
- with PrettyNaming.InvalidMangledStaticArg piece ->
- error(Error(FSComp.SR.etProvidedTypeReferenceInvalidText(piece), range0))
+ member _.ProvidedArguments =
+ let typeName, argNamesAndValues =
+ try
+ PrettyNaming.DemangleProvidedTypeName typeLogicalName
+ with PrettyNaming.InvalidMangledStaticArg piece ->
+ error(Error(FSComp.SR.etProvidedTypeReferenceInvalidText(piece), range0))
*)
- member ty.IsAbbreviation =
+ member ty.IsAbbreviation =
isResolved() && ty.HasTypeDefinition && ty.TypeDefinition.IsFSharpAbbreviation
- member _.AbbreviatedType =
+ member _.AbbreviatedType =
protect <| fun () -> FSharpType(cenv, stripTyEqns cenv.g ty)
- member _.IsFunctionType =
+ member _.IsFunctionType =
isResolved() &&
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_fun _ -> true
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_fun _ -> true
| _ -> false
- member _.IsAnonRecordType =
+ member _.IsAnonRecordType =
isResolved() &&
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_anon _ -> true
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_anon _ -> true
| _ -> false
- member _.AnonRecordTypeDetails =
- protect <| fun () ->
- match stripTyparEqns ty with
+ member _.AnonRecordTypeDetails =
+ protect <| fun () ->
+ match stripTyparEqns ty with
| TType_anon (anonInfo, _) -> FSharpAnonRecordTypeDetails(cenv, anonInfo)
| _ -> invalidOp "not an anonymous record type"
- member _.IsGenericParameter =
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_var _ -> true
- | TType_measure (Measure.Var _) -> true
+ member _.IsGenericParameter =
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_var _ -> true
+ | TType_measure (Measure.Var _) -> true
| _ -> false
- member _.GenericParameter =
- protect <| fun () ->
- match stripTyparEqns ty with
- | TType_var (tp, _)
- | TType_measure (Measure.Var tp) ->
+ member _.GenericParameter =
+ protect <| fun () ->
+ match stripTyparEqns ty with
+ | TType_var (tp, _)
+ | TType_measure (Measure.Var tp) ->
FSharpGenericParameter (cenv, tp)
| _ -> invalidOp "not a generic parameter type"
- member _.AllInterfaces =
+ member _.AllInterfaces =
if isUnresolved() then makeReadOnlyCollection [] else
- [ for ty in AllInterfacesOfType cenv.g cenv.amap range0 AllowMultiIntfInstantiations.Yes ty do
+ [ for ty in AllInterfacesOfType cenv.g cenv.amap range0 AllowMultiIntfInstantiations.Yes ty do
yield FSharpType(cenv, ty) ]
|> makeReadOnlyCollection
- member _.BaseType =
+ member _.BaseType =
GetSuperTypeOfType cenv.g cenv.amap range0 ty
- |> Option.map (fun ty -> FSharpType(cenv, ty))
+ |> Option.map (fun ty -> FSharpType(cenv, ty))
member x.ErasedType=
FSharpType(cenv, stripTyEqnsWrtErasure EraseAll cenv.g ty)
@@ -2521,21 +2528,21 @@ type FSharpType(cenv, ty:TType) =
invalidOp $"the type '{x}' does not have a qualified name"
protect <| fun () ->
- match stripTyparEqns ty with
+ match stripTyparEqns ty with
| TType_app(tcref, _, _) ->
- match tcref.CompiledRepresentation with
+ match tcref.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref, _, _) -> tref.BasicQualifiedName
- | CompiledTypeRepr.ILAsmOpen _ -> fail ()
+ | CompiledTypeRepr.ILAsmOpen _ -> fail ()
| _ -> fail ()
- member _.Instantiate(instantiation:(FSharpGenericParameter * FSharpType) list) =
+ member _.Instantiate(instantiation:(FSharpGenericParameter * FSharpType) list) =
let resTy = instType (instantiation |> List.map (fun (tyv, ty) -> tyv.TypeParameter, ty.Type)) ty
FSharpType(cenv, resTy)
member _.Type = ty
member private x.cenv = cenv
- member private ty.AdjustType t =
+ member private ty.AdjustType t =
FSharpType(ty.cenv, t)
// Note: This equivalence relation is modulo type abbreviations
@@ -2546,8 +2553,8 @@ type FSharpType(cenv, ty:TType) =
| _ -> false
// Note: This equivalence relation is modulo type abbreviations. The hash is less than perfect.
- override _.GetHashCode() =
- let rec hashType ty =
+ override _.GetHashCode() =
+ let rec hashType ty =
let ty = stripTyEqnsWrtErasure EraseNone cenv.g ty
match ty with
| TType_forall _ -> 10000
@@ -2556,72 +2563,72 @@ type FSharpType(cenv, ty:TType) =
| TType_ucase _ -> 10300 // shouldn't occur in symbols
| TType_tuple (_, l1) -> 10400 + List.sumBy hashType l1
| TType_fun (domainTy, rangeTy, _) -> 10500 + hashType domainTy + hashType rangeTy
- | TType_measure _ -> 10600
+ | TType_measure _ -> 10600
| TType_anon (_,l1) -> 10800 + List.sumBy hashType l1
hashType ty
- member _.Format(context: FSharpDisplayContext) =
- protect <| fun () ->
- NicePrint.prettyStringOfTyNoCx (context.Contents cenv.g) ty
+ member _.Format(context: FSharpDisplayContext) =
+ protect <| fun () ->
+ NicePrint.prettyStringOfTyNoCx (context.Contents cenv.g) ty
- member _.FormatWithConstraints(context: FSharpDisplayContext) =
- protect <| fun () ->
- NicePrint.prettyStringOfTy (context.Contents cenv.g) ty
+ member _.FormatWithConstraints(context: FSharpDisplayContext) =
+ protect <| fun () ->
+ NicePrint.prettyStringOfTy (context.Contents cenv.g) ty
member _.FormatLayout(context: FSharpDisplayContext) =
- protect <| fun () ->
+ protect <| fun () ->
NicePrint.prettyLayoutOfTypeNoCx (context.Contents cenv.g) ty
|> LayoutRender.toArray
member _.FormatLayoutWithConstraints(context: FSharpDisplayContext) =
- protect <| fun () ->
+ protect <| fun () ->
NicePrint.prettyLayoutOfType (context.Contents cenv.g) ty
|> LayoutRender.toArray
- override _.ToString() =
- protect <| fun () ->
- "type " + NicePrint.prettyStringOfTyNoCx (DisplayEnv.Empty(cenv.g)) ty
+ override _.ToString() =
+ protect <| fun () ->
+ "type " + NicePrint.prettyStringOfTyNoCx (DisplayEnv.Empty(cenv.g)) ty
- static member Prettify(ty: FSharpType) =
+ static member Prettify(ty: FSharpType) =
let prettyTy = PrettyTypes.PrettifyType ty.cenv.g ty.Type |> fst
ty.AdjustType prettyTy
- static member Prettify(types: IList) =
+ static member Prettify(types: IList) =
let xs = types |> List.ofSeq
- match xs with
+ match xs with
| [] -> []
- | h :: _ ->
+ | h :: _ ->
let cenv = h.cenv
let prettyTys = PrettyTypes.PrettifyTypes cenv.g [ for t in xs -> t.Type ] |> fst
(xs, prettyTys) ||> List.map2 (fun p pty -> p.AdjustType pty)
|> makeReadOnlyCollection
- static member Prettify(parameter: FSharpParameter) =
+ static member Prettify(parameter: FSharpParameter) =
let prettyTy = parameter.V |> PrettyTypes.PrettifyType parameter.cenv.g |> fst
parameter.AdjustType prettyTy
- static member Prettify(parameters: IList) =
+ static member Prettify(parameters: IList) =
let parameters = parameters |> List.ofSeq
- match parameters with
+ match parameters with
| [] -> []
- | h :: _ ->
+ | h :: _ ->
let cenv = h.cenv
let prettyTys = parameters |> List.map (fun p -> p.V) |> PrettyTypes.PrettifyTypes cenv.g |> fst
(parameters, prettyTys) ||> List.map2 (fun p pty -> p.AdjustType pty)
|> makeReadOnlyCollection
- static member Prettify(parameters: IList>) =
+ static member Prettify(parameters: IList>) =
let xs = parameters |> List.ofSeq |> List.map List.ofSeq
- let hOpt = xs |> List.tryPick (function h :: _ -> Some h | _ -> None)
- match hOpt with
+ let hOpt = xs |> List.tryPick (function h :: _ -> Some h | _ -> None)
+ match hOpt with
| None -> xs
- | Some h ->
+ | Some h ->
let cenv = h.cenv
let prettyTys = xs |> List.mapSquared (fun p -> p.V) |> PrettyTypes.PrettifyCurriedTypes cenv.g |> fst
(xs, prettyTys) ||> List.map2 (List.map2 (fun p pty -> p.AdjustType pty))
|> List.map makeReadOnlyCollection |> makeReadOnlyCollection
- static member Prettify(parameters: IList>, returnParameter: FSharpParameter) =
+ static member Prettify(parameters: IList>, returnParameter: FSharpParameter) =
let xs = parameters |> List.ofSeq |> List.map List.ofSeq
let cenv = returnParameter.cenv
let prettyTys, prettyRetTy = xs |> List.mapSquared (fun p -> p.V) |> (fun tys -> PrettyTypes.PrettifyCurriedSigTypes cenv.g (tys, returnParameter.V) )|> fst
@@ -2633,42 +2640,42 @@ type FSharpType(cenv, ty:TType) =
x.AbbreviatedType.StripAbbreviations()
else x
-type FSharpAttribute(cenv: SymbolEnv, attrib: AttribInfo) =
+type FSharpAttribute(cenv: SymbolEnv, attrib: AttribInfo) =
let rec resolveArgObj (arg: obj) =
match arg with
- | :? TType as t -> box (FSharpType(cenv, t))
+ | :? TType as t -> box (FSharpType(cenv, t))
| :? (obj[]) as a -> a |> Array.map resolveArgObj |> box
| _ -> arg
- member _.AttributeType =
+ member _.AttributeType =
FSharpEntity(cenv, attrib.TyconRef)
member _.IsUnresolved = entityIsUnresolved(attrib.TyconRef)
- member _.ConstructorArguments =
- attrib.ConstructorArguments
+ member _.ConstructorArguments =
+ attrib.ConstructorArguments
|> List.map (fun (ty, obj) -> FSharpType(cenv, ty), resolveArgObj obj)
|> makeReadOnlyCollection
- member _.NamedArguments =
- attrib.NamedArguments
+ member _.NamedArguments =
+ attrib.NamedArguments
|> List.map (fun (ty, nm, isField, obj) -> FSharpType(cenv, ty), nm, isField, resolveArgObj obj)
|> makeReadOnlyCollection
- member _.Format(context: FSharpDisplayContext) =
- protect <| fun () ->
+ member _.Format(context: FSharpDisplayContext) =
+ protect <| fun () ->
match attrib with
| AttribInfo.FSAttribInfo(g, attrib) ->
NicePrint.stringOfFSAttrib (context.Contents g) attrib
- | AttribInfo.ILAttribInfo (g, _, _scoref, cattr, _) ->
- let parms, _args = decodeILAttribData cattr
+ | AttribInfo.ILAttribInfo (g, _, _scoref, cattr, _) ->
+ let parms, _args = decodeILAttribData cattr
NicePrint.stringOfILAttrib (context.Contents g) (cattr.Method.DeclaringType, parms)
member _.Range = attrib.Range
- override _.ToString() =
- if entityIsUnresolved attrib.TyconRef then "attribute ???" else "attribute " + attrib.TyconRef.CompiledName + "(...)"
+ override _.ToString() =
+ if entityIsUnresolved attrib.TyconRef then "attribute ???" else "attribute " + attrib.TyconRef.CompiledName + "(...)"
member attr.IsAttribute<'T> () =
// CompiledName throws exception on DataContractAttribute generated by SQLProvider
@@ -2678,53 +2685,53 @@ type FSharpAttribute(cenv: SymbolEnv, attrib: AttribInfo) =
try attr.AttributeType.CompiledName = typeof<'T>.Name with _ -> false
#endif
-#if !NO_TYPEPROVIDERS
-type FSharpStaticParameter(cenv, sp: Tainted< TypeProviders.ProvidedParameterInfo >, m) =
- inherit FSharpSymbol(cenv,
- (fun () ->
- protect <| fun () ->
+#if !NO_TYPEPROVIDERS
+type FSharpStaticParameter(cenv, sp: Tainted< TypeProviders.ProvidedParameterInfo >, m) =
+ inherit FSharpSymbol(cenv,
+ (fun () ->
+ protect <| fun () ->
let paramTy = Import.ImportProvidedType cenv.amap m (sp.PApply((fun x -> x.ParameterType), m))
let nm = sp.PUntaint((fun p -> p.Name), m)
let id = mkSynId m nm
- Item.ArgName(Some id, paramTy, None, m)),
+ Item.ArgName(Some id, paramTy, None, m)),
(fun _ _ _ -> true))
- member _.Name =
- protect <| fun () ->
+ member _.Name =
+ protect <| fun () ->
sp.PUntaint((fun p -> p.Name), m)
member _.DeclarationLocation = m
- member _.Kind =
- protect <| fun () ->
+ member _.Kind =
+ protect <| fun () ->
let ty = Import.ImportProvidedType cenv.amap m (sp.PApply((fun x -> x.ParameterType), m))
FSharpType(cenv, ty)
- member _.IsOptional =
+ member _.IsOptional =
protect <| fun () -> sp.PUntaint((fun x -> x.IsOptional), m)
- member _.HasDefaultValue =
+ member _.HasDefaultValue =
protect <| fun () -> sp.PUntaint((fun x -> x.HasDefaultValue), m)
- member _.DefaultValue =
+ member _.DefaultValue =
protect <| fun () -> sp.PUntaint((fun x -> x.RawDefaultValue), m)
member _.Range = m
override x.Equals(other: obj) =
- box x === other ||
+ box x === other ||
match other with
| :? FSharpStaticParameter as p -> x.Name = p.Name && equals x.DeclarationLocation p.DeclarationLocation
| _ -> false
override x.GetHashCode() = hash x.Name
- override x.ToString() =
- "static parameter " + x.Name
+ override x.ToString() =
+ "static parameter " + x.Name
#endif
-type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, m: range, isParamArrayArg, isInArg, isOutArg, isOptionalArg, isWitnessArg) =
- inherit FSharpSymbol(cenv,
- (fun () -> Item.ArgName(topArgInfo.Name, paramTy, ownerOpt, m)),
+type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, m: range, isParamArrayArg, isInArg, isOutArg, isOptionalArg, isWitnessArg) =
+ inherit FSharpSymbol(cenv,
+ (fun () -> Item.ArgName(topArgInfo.Name, paramTy, ownerOpt, m)),
(fun _ _ _ -> true))
new (cenv, idOpt, ty, ownerOpt, m) =
@@ -2751,7 +2758,7 @@ type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, m:
| Some (ArgumentContainer.Method minfo) -> Some (FSharpMemberOrFunctionOrValue (cenv, minfo) :> FSharpSymbol)
| _ -> None
- override _.Attributes =
+ override _.Attributes =
topArgInfo.Attribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a))) |> makeReadOnlyCollection
member _.IsParamArrayArg = isParamArrayArg
@@ -2761,76 +2768,76 @@ type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, m:
member _.IsOutArg = isOutArg
member _.IsOptionalArg = isOptionalArg
-
+
member _.IsWitnessArg = isWitnessArg
-
+
member private x.ValReprInfo = topArgInfo
override x.Equals(other: obj) =
- box x === other ||
+ box x === other ||
match other with
| :? FSharpParameter as p -> x.Name = p.Name && equals x.DeclarationLocation p.DeclarationLocation
| _ -> false
override x.GetHashCode() = hash (box topArgInfo)
- override x.ToString() =
+ override x.ToString() =
"parameter " + (match x.Name with None -> " s)
-type FSharpAssemblySignature (cenv, topAttribs: TopAttribs option, optViewedCcu: CcuThunk option, mtyp: ModuleOrNamespaceType) =
+type FSharpAssemblySignature (cenv, topAttribs: TopAttribs option, optViewedCcu: CcuThunk option, mtyp: ModuleOrNamespaceType) =
// Assembly signature for a referenced/linked assembly
- new (cenv: SymbolEnv, ccu: CcuThunk) =
+ new (cenv: SymbolEnv, ccu: CcuThunk) =
let cenv = if ccu.IsUnresolvedReference then cenv else SymbolEnv(cenv.g, ccu, None, cenv.tcImports)
FSharpAssemblySignature(cenv, None, Some ccu, ccu.Contents.ModuleOrNamespaceType)
-
+
// Assembly signature for an assembly produced via type-checking.
- new (tcGlobals, thisCcu, thisCcuTyp, tcImports, topAttribs, contents) =
+ new (tcGlobals, thisCcu, thisCcuTyp, tcImports, topAttribs, contents) =
FSharpAssemblySignature(SymbolEnv(tcGlobals, thisCcu, Some thisCcuTyp, tcImports), topAttribs, None, contents)
- member _.Entities =
+ member _.Entities =
- let rec loop (rmtyp: ModuleOrNamespaceType) =
+ let rec loop (rmtyp: ModuleOrNamespaceType) =
[| for entity in rmtyp.AllEntities do
- if entity.IsNamespace then
+ if entity.IsNamespace then
yield! loop entity.ModuleOrNamespaceType
- else
- let entityRef = rescopeEntity optViewedCcu entity
+ else
+ let entityRef = rescopeEntity optViewedCcu entity
yield FSharpEntity(cenv, entityRef) |]
-
+
loop mtyp |> makeReadOnlyCollection
member _.Attributes =
- [ match optViewedCcu with
- | Some ccu ->
- match ccu.TryGetILModuleDef() with
- | Some ilModule ->
- match ilModule.Manifest with
+ [ match optViewedCcu with
+ | Some ccu ->
+ match ccu.TryGetILModuleDef() with
+ | Some ilModule ->
+ match ilModule.Manifest with
| None -> ()
- | Some manifest ->
+ | Some manifest ->
for a in AttribInfosOfIL cenv.g cenv.amap cenv.thisCcu.ILScopeRef range0 manifest.CustomAttrs do
yield FSharpAttribute(cenv, a)
- | None ->
- // If no module is available, then look in the CCU contents.
+ | None ->
+ // If no module is available, then look in the CCU contents.
if ccu.IsFSharp then
- for a in ccu.Contents.Attribs do
+ for a in ccu.Contents.Attribs do
yield FSharpAttribute(cenv, FSAttribInfo (cenv.g, a))
- | None ->
+ | None ->
match topAttribs with
| None -> ()
| Some tA -> for a in tA.assemblyAttrs do yield FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)) ]
|> makeReadOnlyCollection
member _.FindEntityByPath path =
- let findNested name entity =
+ let findNested name entity =
match entity with
| Some (e: Entity) ->e.ModuleOrNamespaceType.AllEntitiesByCompiledAndLogicalMangledNames.TryFind name
| _ -> None
match path with
| hd :: tl ->
- (mtyp.AllEntitiesByCompiledAndLogicalMangledNames.TryFind hd, tl)
- ||> List.fold (fun a x -> findNested x a)
+ (mtyp.AllEntitiesByCompiledAndLogicalMangledNames.TryFind hd, tl)
+ ||> List.fold (fun a x -> findNested x a)
|> Option.map (fun e -> FSharpEntity(cenv, rescopeEntity optViewedCcu e))
| _ -> None
@@ -2838,9 +2845,9 @@ type FSharpAssemblySignature (cenv, topAttribs: TopAttribs option, optViewedCcu:
override x.ToString() = ""
-type FSharpAssembly internal (cenv, ccu: CcuThunk) =
+type FSharpAssembly internal (cenv, ccu: CcuThunk) =
- new (tcGlobals, tcImports, ccu: CcuThunk) =
+ new (tcGlobals, tcImports, ccu: CcuThunk) =
FSharpAssembly(SymbolEnv(tcGlobals, ccu, None, tcImports), ccu)
member _.RawCcuThunk = ccu
@@ -2849,15 +2856,15 @@ type FSharpAssembly internal (cenv, ccu: CcuThunk) =
member _.FileName = ccu.FileName
- member _.SimpleName = ccu.AssemblyName
+ member _.SimpleName = ccu.AssemblyName
#if !NO_TYPEPROVIDERS
member _.IsProviderGenerated = ccu.IsProviderGenerated
#endif
member _.Contents : FSharpAssemblySignature = FSharpAssemblySignature(cenv, ccu)
-
- override x.ToString() =
+
+ override x.ToString() =
match ccu.ILScopeRef with
| ILScopeRef.PrimaryAssembly ->
cenv.g.ilg.primaryAssemblyRef.QualifiedName
@@ -2870,12 +2877,12 @@ type FSharpOpenDeclaration(target: SynOpenDeclTarget, range: range option, modul
member _.Target = target
- member _.LongId =
- match target with
+ member _.LongId =
+ match target with
| SynOpenDeclTarget.ModuleOrNamespace(longId, _) -> longId.LongIdent
| SynOpenDeclTarget.Type(synType, _) ->
- let rec get ty =
- match ty with
+ let rec get ty =
+ match ty with
| SynType.LongIdent (SynLongIdent(lid, _, _)) -> lid
| SynType.App (ty2, _, _, _, _, _, _) -> get ty2
| SynType.LongIdentApp (ty2, _, _, _, _, _, _) -> get ty2
@@ -2892,4 +2899,3 @@ type FSharpOpenDeclaration(target: SynOpenDeclTarget, range: range option, modul
member _.AppliedScope = appliedScope
member _.IsOwnNamespace = isOwnNamespace
-
diff --git a/src/fcs-fable/src/Compiler/Symbols/Symbols.fsi b/src/fcs-fable/src/Compiler/Symbols/Symbols.fsi
index e9ce9d8b11..68344ade4e 100644
--- a/src/fcs-fable/src/Compiler/Symbols/Symbols.fsi
+++ b/src/fcs-fable/src/Compiler/Symbols/Symbols.fsi
@@ -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
+ /// 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
diff --git a/tests/Js/Main/MiscTests.fs b/tests/Js/Main/MiscTests.fs
index fe430e7d56..bf6b5381ce 100644
--- a/tests/Js/Main/MiscTests.fs
+++ b/tests/Js/Main/MiscTests.fs
@@ -6,7 +6,7 @@ open Fable.Core
open Util.Testing
open Util2.Extensions
-let mutable private fn = id
+let mutable private fn: int -> int = id
let [] LITERAL_JSON = """{
"widget": {
@@ -263,10 +263,14 @@ module NestedModule =
type INum = abstract member Num: int
let inline makeNum f = { new INum with member _.Num = f() }
+// TODO: This test is actually wrong in JS too
+// We need to capture this when an inlined function is creating an object expression
+#if !FABLE_COMPILER_TYPESCRIPT
type TestClass(n) =
let addOne x = x + 4
let inner = makeNum (fun () -> addOne n)
member _.GetNum() = inner.Num
+#endif
type RecursiveType(subscribe) as self =
let foo = 3
@@ -305,10 +309,16 @@ module Extensions =
type NestedModule.AnotherClass with
member x.Value2 = x.Value * 4
+// TODO: Abstract classes in TypeScript
+// - Add abstract modifier to class
+// - Declare abstract methods
+// - Skip reflection helper and constructor wrapper
+#if !FABLE_COMPILER_TYPESCRIPT
[]
type ObjectExprBase (x: int ref) as this =
do x := this.dup x.contents
abstract member dup: int -> int
+#endif
open Extensions
@@ -430,7 +440,10 @@ type Shape =
| Rectangle of int * int
type StaticClass =
+// TODO: Print the default value as we do with Dart
+#if !FABLE_COMPILER_TYPESCRIPT
static member DefaultParam([] value: bool) = value
+#endif
static member DefaultNullParam([] x: obj) = x
static member inline Add(x: int, ?y: int) =
x + (defaultArg y 2)
@@ -444,7 +457,10 @@ type MutableFoo =
{ mutable x: int }
let incByRef (a: int) (b: byref) = b <- a + b
+// TODO: inref types in TypeScript (compile as FSharpRef)
+#if !FABLE_COMPILER_TYPESCRIPT
let addInRef (a: int) (b: inref) = a + b
+#endif
let setOutRef (a: int) (b: outref) = b <- a
let mutable mutX = 3
@@ -516,7 +532,13 @@ let tests =
equal true canAccessOpts
testCase "Can access extension for generated files" <| fun _ ->
- Compiler.extension.EndsWith(".js") |> equal true
+ let ext =
+#if FABLE_COMPILER_TYPESCRIPT
+ ".ts"
+#else
+ ".js"
+#endif
+ Compiler.extension.EndsWith(ext) |> equal true
#endif
testCase "Values of autogenerated functions are not replaced by optimizations" <| fun () -> // See #1583
@@ -821,6 +843,7 @@ let tests =
o.Bar <- 10
o.Bar |> equal 10
+#if !FABLE_COMPILER_TYPESCRIPT
testCase "Object expression from class works" <| fun () ->
let o = { new SomeClass("World") with member x.ToString() = sprintf "Hello %s" x.Name }
// TODO: Type testing for object expressions?
@@ -1258,4 +1281,5 @@ let tests =
let times2 x = x * 2
fn <- fn >> times2
fn 5 |> equal 10
+#endif
]
diff --git a/tests/TypeScript/Fable.Tests.TypeScript.fsproj b/tests/TypeScript/Fable.Tests.TypeScript.fsproj
index 967a866c00..0eb292cec0 100644
--- a/tests/TypeScript/Fable.Tests.TypeScript.fsproj
+++ b/tests/TypeScript/Fable.Tests.TypeScript.fsproj
@@ -3,14 +3,27 @@
net6.0
FABLE_COMPILER;FABLE_COMPILER_TYPESCRIPT;$(DefineConstants)
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -33,8 +46,8 @@
-->
-
+
+
diff --git a/tests/TypeScript/Main.fs b/tests/TypeScript/Main.fs
index 9a4716dc08..8f2c5ed61d 100644
--- a/tests/TypeScript/Main.fs
+++ b/tests/TypeScript/Main.fs
@@ -29,7 +29,7 @@ let allTests =
// JsInterop.tests
Lists.tests
Maps.tests
- // Misc.tests
+ Misc.tests
Observable.tests
Option.tests
Queue.tests