@@ -8301,14 +8301,29 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83018301 let mArg = synArg.Range
83028302 let mFunExpr = expr.Range
83038303
8304+ /// Finds last ident of LongIdent in SynExpr.Ident, LongIdent or TypeApp.
8305+ /// Type checkes the whole thing as it goes in order to:
8306+ ///
8307+ /// * ensure we pass well typed things to `nameof`
8308+ ///
8309+ /// * not to loose `FSharpSymbolUse` for `nameof` argument, because we erase it with `Expr.Const(Const.String ...)` further in this function.
83048310 let (|LastPartOfLongIdentStripParens|_|) expr =
8305- let rec findIdents expr =
8311+ let rec findIdents expr(isTypeApp : bool) =
83068312 match expr with
8307- | SynExpr.Ident ident -> Some ([ident], ident)
8308- | SynExpr.TypeApp (expr = expr) -> findIdents expr
8309- | SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) when not (List.isEmpty idents) -> Some (idents, List.last idents)
8313+ | SynExpr.Ident ident ->
8314+ if not isTypeApp then
8315+ TcExprOfUnknownType cenv env tpenv expr |> ignore
8316+ Some ident
8317+ | SynExpr.TypeApp (expr, _, typeNames, _, _, _, m) ->
8318+ TcExprOfUnknownType cenv env tpenv expr |> ignore
8319+ TcTypesOrMeasures None cenv ImplictlyBoundTyparsAllowed.NewTyparsOK CheckConstraints.NoCheckCxs ItemOccurence.Use env tpenv typeNames m |> ignore
8320+ findIdents expr true
8321+ | SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) when not (List.isEmpty idents) ->
8322+ if not isTypeApp then
8323+ TcExprOfUnknownType cenv env tpenv expr |> ignore
8324+ List.tryLast idents
83108325 | _ -> None
8311- findIdents expr
8326+ findIdents expr false
83128327
83138328 let rec stripParens expr =
83148329 match expr with
@@ -8323,12 +8338,7 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83238338 | ApplicableExpr(_, NameOfExpr cenv.g _, _) ->
83248339 let cleanSynArg = stripParens synArg
83258340 match cleanSynArg with
8326- | LastPartOfLongIdentStripParens (idents, lastIdent) ->
8327- // Try to resolve the `nameof` operator argument to prevent passing anything to it.
8328- let item, _ = ResolveExprLongIdent cenv.tcSink cenv.nameResolver mArg env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default idents
8329- // Notify name resolution sink about the resolved argument in order to not loose symbol use, which is used in IDE.
8330- CallNameResolutionSink cenv.tcSink (cleanSynArg.Range, env.eNameResEnv, item, item, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights)
8331-
8341+ | LastPartOfLongIdentStripParens lastIdent ->
83328342 let r = expr.Range
83338343 // generate fake `range` for the constant the `nameof(..)` we are substituting
83348344 let constRange = mkRange r.FileName r.Start (mkPos r.StartLine (r.StartColumn + lastIdent.idText.Length + 2)) // `2` are for quotes