@@ -8308,22 +8308,35 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83088308 ///
83098309 /// * not to loose `FSharpSymbolUse` for `nameof` argument, because we erase it with `Expr.Const(Const.String ...)` further in this function.
83108310 let (|LastPartOfLongIdentStripParens|_|) expr =
8311- let rec findIdents expr(isTypeApp : bool) =
8311+ let rec findIdents expr =
83128312 match expr with
8313- | SynExpr.Ident ident ->
8314- if not isTypeApp then
8315- TcExprOfUnknownType cenv env tpenv expr |> ignore
8316- Some ident
8317- | SynExpr.TypeApp (expr, _, typeArgs, _, _, mTypeArgs, m) ->
8318- TcExprOfUnknownTypeThen cenv env tpenv expr [ DelayedTypeApp (typeArgs, mTypeArgs, m) ] |> 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
8313+ | SynExpr.Ident ident -> Some ident
8314+ | SynExpr.TypeApp (expr = expr) -> findIdents expr
8315+ | SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) -> List.tryLast idents
83258316 | _ -> None
8326- findIdents expr false
8317+ findIdents expr
8318+
8319+ let tcExpr = function
8320+ | SynExpr.Ident _
8321+ | SynExpr.LongIdent(_, LongIdentWithDots _, _, _) as expr ->
8322+ ignore (TcExprOfUnknownType cenv env tpenv expr)
8323+ | SynExpr.TypeApp (expr, _, types, _, _, _, m) as fullExpr ->
8324+ let idents =
8325+ match expr with
8326+ | SynExpr.LongIdent(_, LongIdentWithDots(idents, _), _, _) -> idents
8327+ | SynExpr.Ident ident -> [ident]
8328+ | _ -> []
8329+ match idents with
8330+ | [] -> ()
8331+ | idents ->
8332+ // try to type check it as type application, like A.B.C<D<G>>
8333+ match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInType OpenQualified env.eNameResEnv env.eAccessRights idents (TypeNameResolutionStaticArgsInfo.FromTyArgs types.Length) PermitDirectReferenceToGeneratedType.No with
8334+ | ResultOrException.Result tcref ->
8335+ ignore (TcTypeApp cenv NewTyparsOK NoCheckCxs ItemOccurence.UseInType env tpenv m tcref [] types)
8336+ | _ ->
8337+ // now try to check it as generic function, like func<D<G>>
8338+ ignore (TcExprOfUnknownType cenv env tpenv fullExpr)
8339+ | _ -> ()
83278340
83288341 let rec stripParens expr =
83298342 match expr with
@@ -8339,6 +8352,7 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83398352 let cleanSynArg = stripParens synArg
83408353 match cleanSynArg with
83418354 | LastPartOfLongIdentStripParens lastIdent ->
8355+ tcExpr cleanSynArg
83428356 let r = expr.Range
83438357 // generate fake `range` for the constant the `nameof(..)` we are substituting
83448358 let constRange = mkRange r.FileName r.Start (mkPos r.StartLine (r.StartColumn + lastIdent.idText.Length + 2)) // `2` are for quotes