Skip to content

Commit 5447cd2

Browse files
dsymelatkin
authored andcommitted
Fix for #8 - intellisense does not appear off of generic type
fixes #8 closes #354 commit 17764038f1c036a2e46e48309163744e8e7c5b5e Author: Don Syme <donsyme@fastmail.fm> Date: Thu Apr 9 22:53:45 2015 +0200 potential fix for #8 (2) commit 67d4d7f37d8353b4868a6621a2b480e38a443a5a Author: Don Syme <donsyme@fastmail.fm> Date: Thu Apr 9 22:51:57 2015 +0200 potential fix for #8
1 parent c6ffdb6 commit 5447cd2

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/fsharp/tc.fs

+24-5
Original file line numberDiff line numberDiff line change
@@ -3702,6 +3702,9 @@ type DelayedItem =
37023702
/// Represents the long identifiers in "item.Ident1", or "item.Ident1.Ident2" etc.
37033703
| DelayedDotLookup of Ast.Ident list * range
37043704

3705+
/// Represents an incomplete "item."
3706+
| DelayedDot
3707+
37053708
/// Represents the valueExpr in "item <- valueExpr", also "item.[indexerArgs] <- valueExpr" etc.
37063709
| DelayedSet of Ast.SynExpr * range
37073710

@@ -5099,6 +5102,20 @@ and TcExprNoRecover cenv ty (env: TcEnv) tpenv (expr: SynExpr) =
50995102

51005103
tm,tpenv
51015104

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
51025119

51035120
/// This is used to typecheck legitimate 'main body of constructor' expressions
51045121
and TcExprThatIsCtorBody safeInitInfo cenv overallTy env tpenv expr =
@@ -5454,10 +5471,9 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
54545471
//solveTypAsError cenv env.DisplayEnv m overallTy
54555472
mkDefault(m,overallTy), tpenv
54565473

5474+
// expr. (already reported as an error)
54575475
| 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])
54615477
mkDefault(m,overallTy),tpenv
54625478

54635479
| SynExpr.FromParseError (e1,m) ->
@@ -7732,6 +7748,7 @@ and PropagateThenTcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFla
77327748
// Avoid unifying twice: we're about to unify in TcDelayed
77337749
if nonNil delayed then
77347750
UnifyTypes cenv env mExpr overallTy exprty
7751+
| DelayedDot :: _
77357752
| DelayedSet _ :: _
77367753
| DelayedDotLookup _ :: _ -> ()
77377754
| DelayedTypeApp (_, _mTypeArgs, mExprAndTypeArgs) :: delayedList' ->
@@ -7766,7 +7783,9 @@ and TcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFlag:ExprAtomicF
77667783
CallExprHasTypeSink cenv.tcSink (mExpr,env.NameEnv,exprty, env.DisplayEnv,env.eAccessRights)
77677784

77687785
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
77707789
// expr.M(args) where x.M is a .NET method or index property
77717790
// expr.M<tyargs>(args) where x.M is a .NET method or index property
77727791
// 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
78447863
// resolve type name lookup of 'MyOverloadedType'
78457864
// Also determine if type names should resolve to Item.Types or Item.CtorGroup
78467865
match delayed with
7847-
| DelayedTypeApp (tyargs, _, _) :: DelayedDotLookup _ :: _ ->
7866+
| DelayedTypeApp (tyargs, _, _) :: (DelayedDot | DelayedDotLookup _) :: _ ->
78487867
// cases like 'MyType<int>.Sth'
78497868
TypeNameResolutionInfo(ResolveTypeNamesToTypeRefs, TypeNameResolutionStaticArgsInfo.FromTyArgs tyargs.Length)
78507869

0 commit comments

Comments
 (0)