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
9 changes: 8 additions & 1 deletion src/fsharp/Optimizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,14 @@ and OptimizeLambdas (vspec: Val option) cenv env topValInfo e ety =
let valu =
match baseValOpt with
| None -> CurriedLambdaValue (lambdaId,arities,bsize,expr',ety)
| _ -> UnknownValue
| Some baseVal ->
let fvs = freeInExpr CollectLocals body'
if fvs.UsesMethodLocalConstructs || fvs.FreeLocals.Contains baseVal then
UnknownValue
else
let expr2 = mkMemberLambdas m tps ctorThisValOpt None vsl (body',bodyty)
CurriedLambdaValue (lambdaId,arities,bsize,expr2,ety)


expr', { TotalSize=bsize + (if isTopLevel then methodDefnTotalSize else closureTotalSize); (* estimate size of new syntactic closure - expensive, in contrast to a method *)
FunctionSize=1;
Expand Down
24 changes: 21 additions & 3 deletions tests/fsharp/core/subtype/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@ module TestTwoConversionsOK =
// asserted to be equal.
//
//This rule is a deliberate artificial limitation to reduce the complexity
// of type inference in the common case, at the cost of making inline code
// of type inference in the common case, at the cost of making “inline” code
// less generic. However, the rule should not apply to op_Explicit and op_Implicit constraints. These are special constraint names, known to the language, and we already have special rules around these operators to ensure that the return type
// is effectively considered to be part of the name of the constraint
// is effectively considered to be part of the “name” of the constraint
// (i.t. op_Explicit --> int64 is effectively a different constraint to op_Explicit --> int32).
//
//So the solution is thus to not apply the rule for these constraints.
Expand Down Expand Up @@ -1696,6 +1696,24 @@ module RecordPropertyConstraintTests =
check "ckjwnewk" (f8()) (System.TimeSpan.FromSeconds 2.0) // after mutation
check "ckjwnewk" (f10()) "Gary"

// See https://github.com/Microsoft/visualfsharp/issues/740 - inlining on subtypes was not allowed
module InliningOnSubTypes1 =
type A() =
static member inline dosomething() = ()

type B() =
inherit A()
member inline this.SomethingElse a = a + 10
member inline this.SomethingElse2 a b = a + b + 10

let f () =
let b = B()
let x1 = b.SomethingElse 3
let x2 = b.SomethingElse2 3 4
(x1, x2)
do check "clkewlijwlkw" (f()) (13, 17)



// See https://github.com/Microsoft/visualfsharp/issues/238
module GenericPropertyConstraintSolvedByRecord =
Expand All @@ -1711,4 +1729,4 @@ let aa =

do (stdout.WriteLine "Test Passed";
System.IO.File.WriteAllText("test.ok","ok");
exit 0)
exit 0)