Could this suffice ?

1
2
3
4
5
6
7
type foo() =
  let mutable orderID = 0
  member x.OrderID with get() = orderID and set(v) = orderID <- v
  
type bar() = 
  inherit foo()
  member x.OrderID with get() = 100 and set(v) = failwith "oops!"
By on 11/15/2009 5:22 AM ()

No, the original declaration isn't virtual, so it can't be overridden. Try by changing member in the subclass to override:

1
2
3
 type bar() = 
  inherit foo()
  override x.OrderID with get() = 100 and set(v) = failwith "oops!" 

Error: No abstract property was found that corresponds to this override

Looks like the only way to get the virtual definition into the IL is to have an explicit abstract declaration, no type inference :(. Well that's not entirely true. If you declare the abstract member as ^a and then ignore the warning, that'll work.

By on 11/15/2009 9:13 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper