diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index edc3212bcfa..bb4a5055e2d 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -2822,10 +2822,7 @@ let TcVal checkAttributes (cenv: cenv) env (tpenv: UnscopedTyparEnv) (vref: ValR let exprForVal = Expr.Val (vref, vrefFlags, m) let exprForVal = mkTyAppExpr m (exprForVal, vTy) tinst let isSpecial = - (match vrefFlags with NormalValUse | PossibleConstrainedCall _ -> false | _ -> true) || - valRefEq g vref g.splice_expr_vref || - valRefEq g vref g.splice_raw_expr_vref - + (match vrefFlags with NormalValUse | PossibleConstrainedCall _ -> false | _ -> true) || g.isSpliceOperator vref let exprForVal = RecordUseOfRecValue cenv valRecInfo vref exprForVal m tpsorig, exprForVal, isSpecial, tau, tinst, tpenv diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 878a70939d0..c57eefdc329 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -703,10 +703,6 @@ let CheckNoReraise cenv freesOpt (body: Expr) = if fvs.UsesUnboundRethrow then errorR(Error(FSComp.SR.chkErrorContainsCallToRethrow(), body.Range)) -/// Check if a function is a quotation splice operator -let isSpliceOperator g v = valRefEq g v g.splice_expr_vref || valRefEq g v g.splice_raw_expr_vref - - /// Examples: /// I & I => ExactlyEqual. /// I & I => NotEqual. @@ -776,8 +772,8 @@ let rec CheckExprNoByrefs cenv env expr = and CheckValRef (cenv: cenv) (env: env) v m (ctxt: PermitByRefExpr) = if cenv.reportErrors then - if isSpliceOperator cenv.g v && not env.quote then errorR(Error(FSComp.SR.chkSplicingOnlyInQuotations(), m)) - if isSpliceOperator cenv.g v then errorR(Error(FSComp.SR.chkNoFirstClassSplicing(), m)) + if cenv.g.isSpliceOperator v && not env.quote then errorR(Error(FSComp.SR.chkSplicingOnlyInQuotations(), m)) + if cenv.g.isSpliceOperator v then errorR(Error(FSComp.SR.chkNoFirstClassSplicing(), m)) if valRefEq cenv.g v cenv.g.addrof_vref then errorR(Error(FSComp.SR.chkNoFirstClassAddressOf(), m)) if valRefEq cenv.g v cenv.g.reraise_vref then errorR(Error(FSComp.SR.chkNoFirstClassRethrow(), m)) if valRefEq cenv.g v cenv.g.nameof_vref then errorR(Error(FSComp.SR.chkNoFirstClassNameOf(), m)) @@ -1192,7 +1188,7 @@ and CheckExpr (cenv: cenv) (env: env) origExpr (ctxt: PermitByRefExpr) : Limit = NoLimit // Allow '%expr' in quotations - | Expr.App (Expr.Val (vref, _, _), _, tinst, [arg], m) when isSpliceOperator g vref && env.quote -> + | Expr.App (Expr.Val (vref, _, _), _, tinst, [arg], m) when g.isSpliceOperator vref && env.quote -> CheckSpliceApplication cenv env (tinst, arg, m) // Check an application diff --git a/src/Compiler/Checking/QuotationTranslator.fs b/src/Compiler/Checking/QuotationTranslator.fs index 1ee9fb9fbd3..d5daa377540 100644 --- a/src/Compiler/Checking/QuotationTranslator.fs +++ b/src/Compiler/Checking/QuotationTranslator.fs @@ -214,8 +214,6 @@ let (|ObjectInitializationCheck|_|) g expr = isUnitTy g resultTy -> ValueSome() | _ -> ValueNone -let isSplice g vref = valRefEq g vref g.splice_expr_vref || valRefEq g vref g.splice_raw_expr_vref - let rec EmitDebugInfoIfNecessary cenv env m astExpr : ExprData = // do not emit debug info if emitDebugInfoInQuotations = false or it was already written for the given expression if cenv.emitDebugInfoInQuotations && not (QP.isAttributedExpression astExpr) then @@ -298,7 +296,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. match expr with // Detect expression tree exprSplices | Expr.App (InnerExprPat(Expr.Val (vref, _, _)), _, _, x0 :: rest, m) - when isSplice g vref -> + when g.isSpliceOperator vref -> let idx = cenv.exprSplices.Count let ty = tyOfExpr g expr @@ -311,7 +309,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. (hole, rest) ||> List.fold (fun fR arg -> QP.mkApp (fR, ConvExpr cenv env arg)) | ModuleValueOrMemberUse g (vref, vFlags, _f, _fTy, tyargs, curriedArgs) - when not (isSplice g vref) -> + when not (g.isSpliceOperator vref) -> let m = expr.Range let numEnclTypeArgs, _, isNewObj, valUseFlags, isSelfInit, takesInstanceArg, isPropGet, isPropSet = diff --git a/src/Compiler/Checking/QuotationTranslator.fsi b/src/Compiler/Checking/QuotationTranslator.fsi index 25567f51a63..1958dde4dc3 100644 --- a/src/Compiler/Checking/QuotationTranslator.fsi +++ b/src/Compiler/Checking/QuotationTranslator.fsi @@ -53,5 +53,3 @@ val (|SimpleArrayLoopBody|_|): TcGlobals -> Expr -> (Expr * TType * Expr) voptio [] val (|ObjectInitializationCheck|_|): TcGlobals -> Expr -> unit voption - -val isSplice: TcGlobals -> ValRef -> bool diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index d9d2270bcb4..ef46e6efcb6 100644 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -15,7 +15,6 @@ open System.Diagnostics open Internal.Utilities.Library open Internal.Utilities.Library.Extras open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.AbstractIL.ILX open FSharp.Compiler.CompilerGlobalState open FSharp.Compiler.Features open FSharp.Compiler.IO @@ -24,9 +23,7 @@ open FSharp.Compiler.Text.FileIndex open FSharp.Compiler.Text.Range open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics - open Internal.Utilities -open System.Reflection let internal DummyFileNameForRangesWithoutASpecificLocation = startupFileName let private envRange = rangeN DummyFileNameForRangesWithoutASpecificLocation 0 @@ -65,7 +62,6 @@ module FSharpLib = let LanguagePrimitivesName = Root + ".Core.LanguagePrimitives" let CompilerServicesName = Root + ".Core.CompilerServices" let LinqRuntimeHelpersName = Root + ".Linq.RuntimeHelpers" - let RuntimeHelpersName = Root + ".Core.CompilerServices.RuntimeHelpers" let ExtraTopLevelOperatorsName = Root + ".Core.ExtraTopLevelOperators" let NativeInteropName = Root + ".NativeInterop" @@ -77,7 +73,6 @@ module FSharpLib = let NativeInteropPath = splitNamespace NativeInteropName |> Array.ofList let CompilerServicesPath = splitNamespace CompilerServicesName |> Array.ofList let LinqRuntimeHelpersPath = splitNamespace LinqRuntimeHelpersName |> Array.ofList - let RuntimeHelpersPath = splitNamespace RuntimeHelpersName |> Array.ofList let QuotationsPath = splitNamespace QuotationsName |> Array.ofList let RootPathArray = RootPath |> Array.ofList @@ -218,7 +213,6 @@ type TcGlobals( let mk_MFLinq_tcref ccu n = mkNonLocalTyconRef2 ccu LinqPathArray n let mk_MFCollections_tcref ccu n = mkNonLocalTyconRef2 ccu CollectionsPathArray n let mk_MFCompilerServices_tcref ccu n = mkNonLocalTyconRef2 ccu CompilerServicesPath n - let mk_MFRuntimeHelpers_tcref ccu n = mkNonLocalTyconRef2 ccu RuntimeHelpersPath n let mk_MFControl_tcref ccu n = mkNonLocalTyconRef2 ccu ControlPathArray n let tryFindSysTypeCcu path nm = @@ -1893,6 +1887,10 @@ type TcGlobals( /// Indicates if we can use System.Array.Empty when emitting IL for empty array literals member val isArrayEmptyAvailable = v_Array_tcref.ILTyconRawMetadata.Methods.FindByName "Empty" |> List.isEmpty |> not + member g.isSpliceOperator v = + primValRefEq g.compilingFSharpCore g.fslibCcu v g.splice_expr_vref || + primValRefEq g.compilingFSharpCore g.fslibCcu v g.splice_raw_expr_vref + member _.FindSysTyconRef path nm = findSysTyconRef path nm member _.TryFindSysTyconRef path nm = tryFindSysTyconRef path nm