On an accessibility compilation error when a public type implements an internal interface in F# -
i wrote code like
type internal imyinterface = abstract member method1 : unit -> unit type class1() = member this.y() = (this :> imyinterface).method1() interface imyinterface member this.method1() = ()
note public type class1 implements internal interface imyinterface, compiles fine. in generated msil, "method1" shown private. similar explicit interfaces in c#.
however, when change code bit to
type internal foo() = member x.value = "foo" type internal imyinterface = abstract member method1 : foo -> unit type class1() = member this.y() = let v = foo() (this :> imyinterface).method1(v) interface imyinterface member this.method1(v : foo) = ()
this type interface method "method1" takes internal type "foo" parameter. time, not compile error
the type 'foo' less accessible value, member or type 'override class1.method1 : v:foo -> unit' used in
i have trouble decipher error message , find fix it. in c#, can write following code compiles fine
internal class foo { string value { get; set; } } internal interface imyinterface { void method1(foo v); } public class class1 : imyinterface { public void y() { var v = new foo(); (this imyinterface).method1(v); } void imyinterface.method1(foo v) { throw new notimplementedexception(); } }
any idea f# compiler error , how work around it?
btw: may not right way/pattern use interface anyway, i'm curious on language syntax
as pointed out @ patrick's comment, issue logged a bug of visual f#. it's included in f# 4.0 update 3 milestone.
Comments
Post a Comment