@@ -8303,6 +8303,31 @@ and delayRest rest mPrior delayed =
83038303 let mPriorAndLongId = unionRanges mPrior (rangeOfLid longId)
83048304 DelayedDotLookup (rest,mPriorAndLongId) :: delayed
83058305
8306+ //-------------------------------------------------------------------------
8307+ // TcNameOfExpr: Typecheck "nameof" expressions
8308+ //-------------------------------------------------------------------------
8309+ and TcNameOfExpr cenv env tpenv expr =
8310+ match expr with
8311+ | SynExpr.Ident _
8312+ | SynExpr.LongIdent(_, LongIdentWithDots _, _, _) as expr ->
8313+ ignore (TcExprOfUnknownType cenv env tpenv expr)
8314+ | SynExpr.TypeApp (expr, _, types, _, _, _, m) as fullExpr ->
8315+ let idents =
8316+ match expr with
8317+ | SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) -> idents
8318+ | SynExpr.Ident ident -> [ident]
8319+ | _ -> []
8320+ match idents with
8321+ | [] -> ()
8322+ | idents ->
8323+ // try to type check it as type application, like A.B.C<D<G>>
8324+ match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInType OpenQualified env.eNameResEnv env.eAccessRights idents (TypeNameResolutionStaticArgsInfo.FromTyArgs types.Length) PermitDirectReferenceToGeneratedType.No with
8325+ | ResultOrException.Result tcref ->
8326+ ignore (TcTypeApp cenv NewTyparsOK NoCheckCxs ItemOccurence.UseInType env tpenv m tcref [] types)
8327+ | _ ->
8328+ // now try to check it as generic function, like func<D<G>>
8329+ ignore (TcExprOfUnknownType cenv env tpenv fullExpr)
8330+ | _ -> ()
83068331
83078332//-------------------------------------------------------------------------
83088333// TcFunctionApplicationThen: Typecheck "expr x" + projections
@@ -8328,28 +8353,6 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83288353 | _ -> None
83298354 findIdents expr
83308355
8331- let tcExpr = function
8332- | SynExpr.Ident _
8333- | SynExpr.LongIdent(_, LongIdentWithDots _, _, _) as expr ->
8334- ignore (TcExprOfUnknownType cenv env tpenv expr)
8335- | SynExpr.TypeApp (expr, _, types, _, _, _, m) as fullExpr ->
8336- let idents =
8337- match expr with
8338- | SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) -> idents
8339- | SynExpr.Ident ident -> [ident]
8340- | _ -> []
8341- match idents with
8342- | [] -> ()
8343- | idents ->
8344- // try to type check it as type application, like A.B.C<D<G>>
8345- match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInType OpenQualified env.eNameResEnv env.eAccessRights idents (TypeNameResolutionStaticArgsInfo.FromTyArgs types.Length) PermitDirectReferenceToGeneratedType.No with
8346- | ResultOrException.Result tcref ->
8347- ignore (TcTypeApp cenv NewTyparsOK NoCheckCxs ItemOccurence.UseInType env tpenv m tcref [] types)
8348- | _ ->
8349- // now try to check it as generic function, like func<D<G>>
8350- ignore (TcExprOfUnknownType cenv env tpenv fullExpr)
8351- | _ -> ()
8352-
83538356 let rec stripParens expr =
83548357 match expr with
83558358 | SynExpr.Paren(expr, _, _, _) -> stripParens expr
@@ -8364,7 +8367,7 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83648367 let cleanSynArg = stripParens synArg
83658368 match cleanSynArg with
83668369 | LastPartOfLongIdentStripParens lastIdent ->
8367- tcExpr cleanSynArg
8370+ TcNameOfExpr cenv env tpenv cleanSynArg
83688371 let r = expr.Range
83698372 // generate fake `range` for the constant the `nameof(..)` we are substituting
83708373 let constRange = mkRange r.FileName r.Start (mkPos r.StartLine (r.StartColumn + lastIdent.idText.Length + 2)) // `2` are for quotes