@@ -3702,6 +3702,9 @@ type DelayedItem =
3702
3702
/// Represents the long identifiers in "item.Ident1", or "item.Ident1.Ident2" etc.
3703
3703
| DelayedDotLookup of Ast.Ident list * range
3704
3704
3705
+ /// Represents an incomplete "item."
3706
+ | DelayedDot
3707
+
3705
3708
/// Represents the valueExpr in "item <- valueExpr", also "item.[indexerArgs] <- valueExpr" etc.
3706
3709
| DelayedSet of Ast.SynExpr * range
3707
3710
@@ -5099,6 +5102,20 @@ and TcExprNoRecover cenv ty (env: TcEnv) tpenv (expr: SynExpr) =
5099
5102
5100
5103
tm,tpenv
5101
5104
5105
+ // This recursive entry is only used from one callsite (DiscardAfterMissingQualificationAfterDot)
5106
+ // and has been added relatively late in F# 4.0 to preserve the structure of previous code. It pushes a 'delayed' parameter
5107
+ // through TcExprOfUnknownType, TcExpr and TcExprNoRecover
5108
+ and TcExprOfUnknownTypeThen cenv env tpenv expr delayed =
5109
+ let exprty = NewInferenceType ()
5110
+ let expr',tpenv =
5111
+ try
5112
+ TcExprThen cenv exprty env tpenv expr delayed
5113
+ with e ->
5114
+ let m = expr.Range
5115
+ errorRecovery e m
5116
+ solveTypAsError cenv env.DisplayEnv m exprty
5117
+ mkThrow m exprty (mkOne cenv.g m), tpenv
5118
+ expr',exprty,tpenv
5102
5119
5103
5120
/// This is used to typecheck legitimate 'main body of constructor' expressions
5104
5121
and TcExprThatIsCtorBody safeInitInfo cenv overallTy env tpenv expr =
@@ -5454,10 +5471,9 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
5454
5471
//solveTypAsError cenv env.DisplayEnv m overallTy
5455
5472
mkDefault(m,overallTy), tpenv
5456
5473
5474
+ // expr. (already reported as an error)
5457
5475
| SynExpr.DiscardAfterMissingQualificationAfterDot (e1,m) ->
5458
- // For some reason we use "UnknownType" for this one, it's not clear we need to.
5459
- let _,_,tpenv = suppressErrorReporting (fun () -> TcExprOfUnknownType cenv env tpenv e1)
5460
- //solveTypAsError cenv env.DisplayEnv m overallTy
5476
+ let _,_,tpenv = suppressErrorReporting (fun () -> TcExprOfUnknownTypeThen cenv env tpenv e1 [DelayedDot])
5461
5477
mkDefault(m,overallTy),tpenv
5462
5478
5463
5479
| SynExpr.FromParseError (e1,m) ->
@@ -7732,6 +7748,7 @@ and PropagateThenTcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFla
7732
7748
// Avoid unifying twice: we're about to unify in TcDelayed
7733
7749
if nonNil delayed then
7734
7750
UnifyTypes cenv env mExpr overallTy exprty
7751
+ | DelayedDot :: _
7735
7752
| DelayedSet _ :: _
7736
7753
| DelayedDotLookup _ :: _ -> ()
7737
7754
| DelayedTypeApp (_, _mTypeArgs, mExprAndTypeArgs) :: delayedList' ->
@@ -7766,7 +7783,9 @@ and TcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFlag:ExprAtomicF
7766
7783
CallExprHasTypeSink cenv.tcSink (mExpr,env.NameEnv,exprty, env.DisplayEnv,env.eAccessRights)
7767
7784
7768
7785
match delayed with
7769
- | [] -> UnifyTypes cenv env mExpr overallTy exprty; expr.Expr,tpenv
7786
+ | []
7787
+ | DelayedDot :: _ ->
7788
+ UnifyTypes cenv env mExpr overallTy exprty; expr.Expr,tpenv
7770
7789
// expr.M(args) where x.M is a .NET method or index property
7771
7790
// expr.M<tyargs>(args) where x.M is a .NET method or index property
7772
7791
// expr.M where x.M is a .NET method or index property
@@ -7844,7 +7863,7 @@ and TcLongIdentThen cenv overallTy env tpenv (LongIdentWithDots(longId,_)) delay
7844
7863
// resolve type name lookup of 'MyOverloadedType'
7845
7864
// Also determine if type names should resolve to Item.Types or Item.CtorGroup
7846
7865
match delayed with
7847
- | DelayedTypeApp (tyargs, _, _) :: DelayedDotLookup _ :: _ ->
7866
+ | DelayedTypeApp (tyargs, _, _) :: (DelayedDot | DelayedDotLookup _) :: _ ->
7848
7867
// cases like 'MyType<int>.Sth'
7849
7868
TypeNameResolutionInfo(ResolveTypeNamesToTypeRefs, TypeNameResolutionStaticArgsInfo.FromTyArgs tyargs.Length)
7850
7869
0 commit comments