@@ -455,10 +455,9 @@ and SolveTypStaticReq (csenv:ConstraintSolverEnv) trace req ty =
455455 IterateD( fun (( tpr : Typar ), _ ) -> SolveTypStaticReqTypar csenv trace req tpr) vs
456456
457457| _ ->
458- if isAnyParTy csenv.g tythen
459- let tpr = destAnyParTy csenv.g ty
460- SolveTypStaticReqTypar csenv trace req tpr
461- else CompleteD
458+ match tryAnyParTy csenv.g tywith
459+ | Some tpr-> SolveTypStaticReqTypar csenv trace req tpr
460+ | None-> CompleteD
462461
463462let rec TransactDynamicReq ( trace : OptionalTrace ) ( tpr : Typar ) req =
464463let orig = tpr.DynamicReq
@@ -469,10 +468,10 @@ and SolveTypDynamicReq (csenv:ConstraintSolverEnv) trace req ty =
469468match reqwith
470469| TyparDynamicReq.No-> CompleteD
471470| TyparDynamicReq.Yes->
472- if isAnyParTy csenv.g tythen
473- let tpr = destAnyParTy csenv.g ty
474- if tpr.DynamicReq <> TyparDynamicReq.Yes then TransactDynamicReq trace tpr TyparDynamicReq.Yeselse CompleteD
475- else CompleteD
471+ match tryAnyParTy csenv.g tywith
472+ | Some tpr when tpr.DynamicReq <> TyparDynamicReq.Yes ->
473+ TransactDynamicReq trace tpr TyparDynamicReq.Yes
474+ | _ -> CompleteD
476475
477476let SubstMeasureWarnIfRigid ( csenv : ConstraintSolverEnv ) trace ( v : Typar ) ms =
478477if v.Rigidity.WarnIfUnified&& not ( isAnyParTy csenv.g( TType_ measure ms)) then
@@ -651,14 +650,17 @@ let freshMeasure () = Measure.Var (NewInferenceMeasurePar ())
651650let CheckWarnIfRigid ( csenv : ConstraintSolverEnv ) ty1 ( r : Typar ) ty =
652651let g = csenv.g
653652let denv = csenv.DisplayEnv
654- if r.Rigidity.WarnIfUnified&&
655- ( not ( isAnyParTy g ty) ||
656- ( let tp2 = destAnyParTy g ty
657- not tp2.IsCompilerGenerated&&
658- ( r.IsCompilerGenerated||
659- // exclude this warning for two identically named user-specified type parameters, e.g. from different mutually recursive functions or types
660- r.DisplayName<> tp2.DisplayName)))
661- then
653+ if not r.Rigidity.WarnIfUnifiedthen CompleteDelse
654+ let needsWarning =
655+ match tryAnyParTy g tywith
656+ | None-> true
657+ | Some tp2->
658+ not tp2.IsCompilerGenerated&&
659+ ( r.IsCompilerGenerated||
660+ // exclude this warning for two identically named user-specified type parameters, e.g. from different mutually recursive functions or types
661+ r.DisplayName<> tp2.DisplayName)
662+
663+ if needsWarningthen
662664// NOTE: we grab the name eagerly to make sure the type variable prints as a type variable
663665let tpnmOpt = if r.IsCompilerGeneratedthen Noneelse Some r.Name
664666 WarnD( NonRigidTypar( denv, tpnmOpt, r.Range, ty1, ty, csenv.m))
@@ -1403,11 +1405,11 @@ and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution
14031405
14041406/// The nominal support of the member constraint
14051407and GetSupportOfMemberConstraint ( csenv : ConstraintSolverEnv ) ( TTrait ( tys , _ , _ , _ , _ , _ )) =
1406- tys|> List.choose( fun ty -> if isAnyParTy csenv.g ty then Some ( destAnyParTy csenv.g ty ) else None )
1408+ tys|> List.choose( tryAnyParTy csenv.g)
14071409
14081410/// All the typars relevant to the member constraint *)
14091411and GetFreeTyparsOfMemberConstraint ( csenv : ConstraintSolverEnv ) ( TTrait ( tys , _ , _ , argtys , rty , _ )) =
1410- ( freeInTypesLeftToRightSkippingConstraints csenv.g( tys@ argtys@ Option.toList rty) )
1412+ freeInTypesLeftToRightSkippingConstraints csenv.g( tys@ argtys@ Option.toList rty)
14111413
14121414/// Re-solve the global constraints involving any of the given type variables.
14131415/// Trait constraints can't always be solved using the pessimistic rules. We only canonicalize
@@ -1418,10 +1420,10 @@ and SolveRelevantMemberConstraints (csenv:ConstraintSolverEnv) ndeep permitWeakR
14181420 tps|> AtLeastOneD( fun tp ->
14191421/// Normalize the typar
14201422let ty = mkTyparTy tp
1421- if isAnyParTy csenv.g tythen
1422- let tp = destAnyParTy csenv.g ty
1423+ match tryAnyParTy csenv.g tywith
1424+ | Some tp->
14231425 SolveRelevantMemberConstraintsForTypar csenv ndeep permitWeakResolution trace tp
1424- else
1426+ | None ->
14251427 ResultDfalse ))
14261428
14271429and SolveRelevantMemberConstraintsForTypar ( csenv : ConstraintSolverEnv ) ndeep permitWeakResolution ( trace : OptionalTrace ) tp =