Skip to content

Commit f4083d1

Browse files
dsymebaronfel
authored andcommitted
alternative fix for 9565 (#9629)
* fix 9565 * add comment
1 parent d842170 commit f4083d1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/fsharp/MethodCalls.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,15 @@ let AdjustCallerArgForOptional tcFieldInit eCallerMemberName (infoReader: InfoRe
11731173
if isOptCallerArg then errorR(Error(FSComp.SR.tcFormalArgumentIsNotOptional(), m))
11741174
assignedArg
11751175

1176+
// For non-nullable, non-optional arguments no conversion is needed.
1177+
// We return precisely the assignedArg. This also covers the case where there
1178+
// can be a lingering permitted type mismatch between caller argument and called argument,
1179+
// specifically caller can by `byref` and called `outref`. No coercion is inserted in the
1180+
// expression tree in this case.
1181+
| NotOptional when not (isNullableTy g calledArgTy) ->
1182+
if isOptCallerArg then errorR(Error(FSComp.SR.tcFormalArgumentIsNotOptional(), m))
1183+
assignedArg
1184+
11761185
| _ ->
11771186

11781187
let callerArgExpr2 =
@@ -1183,7 +1192,7 @@ let AdjustCallerArgForOptional tcFieldInit eCallerMemberName (infoReader: InfoRe
11831192
if isNullableTy g calledArgTy then
11841193
MakeNullableExprIfNeeded infoReader calledArgTy callerArgTy callerArgExpr m
11851194
else
1186-
callerArgExpr
1195+
failwith "unreachable" // see case above
11871196

11881197
| CallerSide dfltVal ->
11891198
let calledArgTy = calledArg.CalledArgumentType

0 commit comments

Comments
 (0)