Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/fsharp/MethodCalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,8 @@ let AdjustCallerArgForOptional tcVal tcFieldInit eCallerMemberName (infoReader:
else
let calledNonOptTy = destNullableTy g calledArgTy
let _, callerArgExpr2 = AdjustCallerArgExpr tcVal g amap infoReader ad isOutArg calledNonOptTy reflArgInfo callerArgTy m callerArgExpr
MakeNullableExprIfNeeded infoReader calledArgTy callerArgTy callerArgExpr2 m
let callerArgTy2 = tyOfExpr g callerArgExpr2
MakeNullableExprIfNeeded infoReader calledArgTy callerArgTy2 callerArgExpr2 m
else
failwith "unreachable" // see case above

Expand Down Expand Up @@ -1493,7 +1494,8 @@ let AdjustCallerArgForOptional tcVal tcFieldInit eCallerMemberName (infoReader:
// CSharpMethod(x=b) when 'x' has nullable type and 'b' does not --> CSharpMethod(x=Nullable(b))
let calledNonOptTy = destNullableTy g calledArgTy
let _, callerArgExpr2 = AdjustCallerArgExpr tcVal g amap infoReader ad isOutArg calledNonOptTy reflArgInfo callerArgTy m callerArgExpr
MakeNullableExprIfNeeded infoReader calledArgTy callerArgTy callerArgExpr2 m
let callerArgTy2 = tyOfExpr g callerArgExpr2
MakeNullableExprIfNeeded infoReader calledArgTy callerArgTy2 callerArgExpr2 m
else
// CSharpMethod(x=b) --> CSharpMethod(?x=b)
let _, callerArgExpr2 = AdjustCallerArgExpr tcVal g amap infoReader ad isOutArg calledArgTy reflArgInfo callerArgTy m callerArgExpr
Expand Down
72 changes: 42 additions & 30 deletions tests/fsharp/core/fsfromfsviacs/compilation.errors.output.bsl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,286 @@ is not compatible with type
'Nullable<float>'


test.fsx(267,15): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'U2 (_, U1 (_, "a"))' may indicate a case not covered by the pattern(s).
test.fsx(152,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(152,79): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(153,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(154,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(155,89): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(156,88): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(158,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(158,81): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(159,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(160,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(161,91): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(162,90): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(164,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(164,83): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(165,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(166,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(167,93): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(168,92): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(170,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(170,83): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(171,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(172,66): error FS0001: This expression was expected to have type
'Nullable<int>'
but here has type
'int'

test.fsx(173,93): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(174,92): error FS0001: This expression was expected to have type
'Nullable<float>'
but here has type
'float'

test.fsx(190,34): error FS0041: No overloads match for method 'OverloadedMethodTakingOptionals'.

Known type of argument: d: float option

Available overloads:
- SomeClass.OverloadedMethodTakingOptionals(?x: int, ?y: string, ?d: float) : int // Argument 'd' doesn't match
- SomeClass.OverloadedMethodTakingOptionals(?x: int, ?y: string, ?d: float32) : int // Argument 'd' doesn't match

test.fsx(192,34): error FS0041: No overloads match for method 'OverloadedMethodTakingNullableOptionalsWithDefaults'.

Known type of argument: x: int

Available overloads:
- SomeClass.OverloadedMethodTakingNullableOptionalsWithDefaults(?x: Nullable<int64>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullableOptionalsWithDefaults(?x: Nullable<int>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match

test.fsx(197,35): error FS0041: No overloads match for method 'OverloadedMethodTakingNullableOptionalsWithDefaults'.

Known type of argument: x: int

Available overloads:
- SomeClass.OverloadedMethodTakingNullableOptionalsWithDefaults(?x: Nullable<int64>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullableOptionalsWithDefaults(?x: Nullable<int>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match

test.fsx(200,35): error FS0041: No overloads match for method 'OverloadedMethodTakingNullableOptionalsWithDefaults'.

Known type of argument: x: int option

Available overloads:
- SomeClass.OverloadedMethodTakingNullableOptionalsWithDefaults(?x: Nullable<int64>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullableOptionalsWithDefaults(?x: Nullable<int>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match

test.fsx(284,15): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'U2 (_, U1 (_, "a"))' may indicate a case not covered by the pattern(s).
test.fsx(202,34): error FS0041: No overloads match for method 'OverloadedMethodTakingNullableOptionals'.

test.fsx(418,29): error FS0041: A unique overload for method 'SimpleOverload' could not be determined based on type information prior to this program point. A type annotation may be needed.
Known type of argument: x: int

Available overloads:
- SomeClass.OverloadedMethodTakingNullableOptionals(?x: Nullable<int64>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullableOptionals(?x: Nullable<int>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match

test.fsx(207,35): error FS0041: No overloads match for method 'OverloadedMethodTakingNullableOptionals'.

Known type of argument: x: int

Available overloads:
- SomeClass.OverloadedMethodTakingNullableOptionals(?x: Nullable<int64>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullableOptionals(?x: Nullable<int>, ?y: string, ?d: Nullable<float>) : int // Argument 'x' doesn't match

test.fsx(209,35): error FS0041: No overloads match for method 'OverloadedMethodTakingNullables'.

Known types of arguments: int * string * float

Available overloads:
- SomeClass.OverloadedMethodTakingNullables(x: Nullable<int64>, y: string, d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullables(x: Nullable<int>, y: string, d: Nullable<float>) : int // Argument 'x' doesn't match

test.fsx(210,35): error FS0041: No overloads match for method 'OverloadedMethodTakingNullables'.

Known types of arguments: Nullable<int> * string * float

Available overloads:
- SomeClass.OverloadedMethodTakingNullables(x: Nullable<int64>, y: string, d: Nullable<float>) : int // Argument 'x' doesn't match
- SomeClass.OverloadedMethodTakingNullables(x: Nullable<int>, y: string, d: Nullable<float>) : int // Argument 'd' doesn't match

test.fsx(266,15): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'U2 (_, U1 (_, "a"))' may indicate a case not covered by the pattern(s).

test.fsx(283,15): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'U2 (_, U1 (_, "a"))' may indicate a case not covered by the pattern(s).

test.fsx(417,29): error FS0041: A unique overload for method 'SimpleOverload' could not be determined based on type information prior to this program point. A type annotation may be needed.
Candidates:
- SomeClass.SimpleOverload(?x: Nullable<int>) : int
- SomeClass.SimpleOverload(?x: int) : int

test.fsx(431,74): error FS0001: This expression was expected to have type
'int64'
but here has type
'int'

test.fsx(432,75): error FS0193: Type constraint mismatch. The type
'int option'
is not compatible with type
'int64'


test.fsx(434,75): error FS0193: Type constraint mismatch. The type
'int64 option'
is not compatible with type
'int64'


test.fsx(438,94): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int'

test.fsx(439,95): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int'

test.fsx(440,96): error FS0193: Type constraint mismatch. The type
'int option'
is not compatible with type
'Nullable<int64>'


test.fsx(441,94): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int64'

test.fsx(443,95): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int64'

test.fsx(444,96): error FS0193: Type constraint mismatch. The type
'int64 option'
is not compatible with type
'Nullable<int64>'


test.fsx(447,82): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int'

test.fsx(448,83): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int'

test.fsx(449,84): error FS0193: Type constraint mismatch. The type
'int option'
is not compatible with type
'Nullable<int64>'


test.fsx(450,82): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int64'

test.fsx(452,83): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int64'

test.fsx(453,84): error FS0193: Type constraint mismatch. The type
'int64 option'
is not compatible with type
'Nullable<int64>'


test.fsx(467,24): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int'

test.fsx(471,24): error FS0001: This expression was expected to have type
'Nullable<int64>'
but here has type
'int'
26 changes: 26 additions & 0 deletions tests/fsharp/core/fsfromfsviacs/lib3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ public static int MethodTakingOptionals(int x = 3, string y = "abc", double d =
{
return x + y.Length + (int) d;
}
public static long MethodTakingOptionalsInt64(long x = 3, string y = "abc", double d = 5.0)
{
return x + y.Length + (int) d;
}
public static int MethodTakingNullableOptionalsWithDefaults(int? x = 3, string y = "abc", double? d = 5.0)
{
return (x.HasValue ? x.Value : -100) + y.Length + (int) (d.HasValue ? d.Value : 0.0);
}
public static long MethodTakingNullableOptionalsWithDefaultsInt64(long? x = 3, string y = "abc", double? d = 5.0)
{
return (x.HasValue ? x.Value : -100) + y.Length + (int) (d.HasValue ? d.Value : 0.0);
}
public static int MethodTakingNullableOptionals(int? x = null, string y = null, double? d = null)
{
int length;
Expand All @@ -47,6 +55,15 @@ public static int MethodTakingNullableOptionals(int? x = null, string y = null,
length = y.Length;
return (x.HasValue ? x.Value : -1) + length + (int) (d.HasValue ? d.Value : -1.0);
}
public static long MethodTakingNullableOptionalsInt64(long? x = null, string y = null, double? d = null)
{
int length;
if (y == null)
length = -1;
else
length = y.Length;
return (x.HasValue ? x.Value : -1) + length + (int) (d.HasValue ? d.Value : -1.0);
}
public static int OverloadedMethodTakingOptionals(int x = 3, string y = "abc", double d = 5.0)
{
return x + y.Length + (int) d;
Expand Down Expand Up @@ -91,6 +108,15 @@ public static int MethodTakingNullables(int? x, string y, double? d)
return (x.HasValue ? x.Value : -1) + length + (int) (d.HasValue ? d.Value : -1.0);
}

public static long MethodTakingNullablesInt64(long? x, string y, double? d)
{
int length;
if (y == null)
length = -1;
else
length = y.Length;
return (x.HasValue ? x.Value : -1) + length + (int) (d.HasValue ? d.Value : -1.0);
}
public static int OverloadedMethodTakingNullables(int? x, string y, double? d)
{
int length;
Expand Down
Loading