Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two bugs related to tasks #12195

Merged
merged 14 commits into from
Sep 29, 2021
11 changes: 9 additions & 2 deletions src/fsharp/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5876,6 +5876,14 @@ let TypeCheckOneImplFile

let extraAttribs = topAttrs.mainMethodAttrs@topAttrs.netModuleAttrs@topAttrs.assemblyAttrs

// Run any additional checks registered to be run before applying defaults
do
for check in cenv.css.GetPostInferenceChecksPreDefaults() do
try
check()
with e ->
errorRecovery e m

conditionallySuppressErrorReporting (checkForErrors()) (fun () ->
ApplyDefaults cenv g denvAtEnd m mexpr extraAttribs)

Expand All @@ -5899,10 +5907,9 @@ let TypeCheckOneImplFile
conditionallySuppressErrorReporting (checkForErrors()) (fun () ->
CheckModuleSignature g cenv m denvAtEnd rootSigOpt implFileTypePriorToSig implFileSpecPriorToSig mexpr)

// Run any additional checks registered for post-type-inference
do
conditionallySuppressErrorReporting (checkForErrors()) (fun () ->
for check in cenv.postInferenceChecks do
for check in cenv.css.GetPostInferenceChecksFinal() do
try
check()
with e ->
Expand Down
8 changes: 2 additions & 6 deletions src/fsharp/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@ type TcFileState =
/// we infer type parameters
mutable recUses: ValMultiMap<Expr ref * range * bool>

/// Checks to run after all inference is complete.
mutable postInferenceChecks: ResizeArray<unit -> unit>

/// Set to true if this file causes the creation of generated provided types.
mutable createsGeneratedProvidedTypes: bool

Expand Down Expand Up @@ -425,7 +422,6 @@ type TcFileState =
{ g = g
amap = amap
recUses = ValMultiMap<_>.Empty
postInferenceChecks = ResizeArray()
createsGeneratedProvidedTypes = false
topCcu = topCcu
isScript = isScript
Expand Down Expand Up @@ -2624,7 +2620,7 @@ let TcValEarlyGeneralizationConsistencyCheck cenv (env: TcEnv) (v: Val, vrec, ti
match vrec with
| ValInRecScope isComplete when isComplete && not (isNil tinst) ->
//printfn "pushing post-inference check for '%s', vty = '%s'" v.DisplayName (DebugPrint.showType vty)
cenv.postInferenceChecks.Add (fun () ->
cenv.css.PushPostInferenceCheck (preDefaults=false, check=fun () ->
//printfn "running post-inference check for '%s'" v.DisplayName
//printfn "tau = '%s'" (DebugPrint.showType tau)
//printfn "vty = '%s'" (DebugPrint.showType vty)
Expand Down Expand Up @@ -9184,7 +9180,7 @@ and TcMethodApplication
CanonicalizePartialInferenceProblem cenv.css denv mItem
(unnamedCurriedCallerArgs |> List.collectSquared (fun callerArg -> freeInTypeLeftToRight cenv.g false callerArg.CallerArgumentType))

let result, errors = ResolveOverloadingForCall denv cenv.css mMethExpr methodName 0 None callerArgs ad postArgumentTypeCheckingCalledMethGroup true (Some returnTy)
let result, errors = ResolveOverloadingForCall denv cenv.css mMethExpr methodName callerArgs ad postArgumentTypeCheckingCalledMethGroup true returnTy

match afterResolution, result with
| AfterResolution.DoNothing, _ -> ()
Expand Down
3 changes: 0 additions & 3 deletions src/fsharp/CheckExpressions.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ type TcFileState =
/// we infer type parameters
mutable recUses: ValMultiMap<Expr ref * range * bool>

/// Checks to run after all inference is complete.
mutable postInferenceChecks: ResizeArray<unit -> unit>

/// Set to true if this file causes the creation of generated provided types.
mutable createsGeneratedProvidedTypes: bool

Expand Down
11 changes: 1 addition & 10 deletions src/fsharp/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ let GetRangeOfDiagnostic(err: PhasedDiagnostic) =
| ConstraintSolverTypesNotInEqualityRelation(_, _, _, m, _, _)
| ConstraintSolverError(_, m, _)
| ConstraintSolverTypesNotInSubsumptionRelation(_, _, _, m, _)
| ConstraintSolverRelatedInformation(_, m, _)
| SelfRefObjCtor(_, m) ->
Some m

Expand Down Expand Up @@ -373,6 +372,7 @@ let IsWarningOrInfoEnabled (err, severity) n level specificWarnOn =
match n with
| 1182 -> false // chkUnusedValue - off by default
| 3180 -> false // abImplicitHeapAllocation - off by default
| 3186 -> false // pickleMissingDefinition - off by default
| 3366 -> false //tcIndexNotationDeprecated - currently off by default
| 3517 -> false // optFailedToInlineSuggestedValue - off by default
| 3388 -> false // tcSubsumptionImplicitConversionUsed - off by default
Expand All @@ -385,9 +385,6 @@ let IsWarningOrInfoEnabled (err, severity) n level specificWarnOn =
let SplitRelatedDiagnostics(err: PhasedDiagnostic) : PhasedDiagnostic * PhasedDiagnostic list =
let ToPhased e = {Exception=e; Phase = err.Phase}
let rec SplitRelatedException = function
| ConstraintSolverRelatedInformation(fopt, m2, e) ->
let e, related = SplitRelatedException e
ConstraintSolverRelatedInformation(fopt, m2, e.Exception)|>ToPhased, related
| ErrorFromAddingTypeEquation(g, denv, t1, t2, e, m) ->
let e, related = SplitRelatedException e
ErrorFromAddingTypeEquation(g, denv, t1, t2, e.Exception, m)|>ToPhased, related
Expand Down Expand Up @@ -664,12 +661,6 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (canSuggestNa
if m.StartLine <> m2.StartLine then
os.Append(SeeAlsoE().Format (stringOfRange m2)) |> ignore

| ConstraintSolverRelatedInformation(fopt, _, e) ->
match e with
| ConstraintSolverError _ -> OutputExceptionR os e
| _ -> ()
fopt |> Option.iter (Printf.bprintf os " %s")

| ErrorFromAddingTypeEquation(g, denv, t1, t2, ConstraintSolverTypesNotInEqualityRelation(_, t1', t2', m, _, contextInfo), _)
when typeEquiv g t1 t1'
&& typeEquiv g t2 t2' ->
Expand Down
Loading