From 5f8d5fc1732d3bb1a708cc54475c41c3e2a3bf13 Mon Sep 17 00:00:00 2001 From: Nino Floris Date: Thu, 11 Aug 2022 19:36:19 +0200 Subject: [PATCH] Simplify type checks for nullable This was a hold over from earlier code when this arm was not protected by isMethodArg, causing it to need this solving complexity supported by op_Implicit conversions --- src/Compiler/Checking/MethodCalls.fs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index c2b8f6cc420..520d309293c 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -290,21 +290,8 @@ let rec AdjustRequiredTypeForTypeDirectedConversions (infoReader: InfoReader) ad g.int32_ty, TypeDirectedConversionUsed.Yes(warn TypeDirectedConversion.BuiltIn), None elif g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop && isMethodArg && isNullableTy g reqdTy && not (isNullableTy g actualTy) then - let reqdTy2 = - if isTyparTy g reqdTy then - let tp = destTyparTy g reqdTy - match tp.Constraints |> List.choose (function TyparConstraint.CoercesTo (c, _) -> Some c | _ -> None) with - | [reqdTy2] when tp.Rigidity = TyparRigidity.Flexible -> reqdTy2 - | _ -> reqdTy - else reqdTy - - if not (isTyparTy g reqdTy2) && - (not (TypeFeasiblySubsumesType 0 g infoReader.amap m reqdTy2 CanCoerce actualTy) || - isTyparTy g actualTy && (let ftyvs = freeInType CollectAll reqdTy2 in ftyvs.FreeTypars.Contains(destTyparTy g actualTy))) then + actualTy, TypeDirectedConversionUsed.Yes(warn TypeDirectedConversion.BuiltIn), None - actualTy, TypeDirectedConversionUsed.Yes(warn TypeDirectedConversion.BuiltIn), Some (reqdTy, reqdTy2, ignore) - else - reqdTy, TypeDirectedConversionUsed.No, None // Adhoc based on op_Implicit, perhaps returing a new equational type constraint to // eliminate articifical constrained type variables. elif g.langVersion.SupportsFeature LanguageFeature.AdditionalTypeDirectedConversions then