// =========================================================
// ダウンキャストのサンプル
// =========================================================

// 基底クラス
type Base () = class
    abstract member Function: unit -> unit
    default x.Function () = printfn "default: Base.Function()"
end

// 派生クラス
type Derived () = class
    inherit Base ()
    override x.Function () = printfn "Derived.Function()"
end

// 基底クラスをインスタンス化
let base1:Base = new Base ()

// Derivedクラスへダウンキャスト(1)
let d1 = base1 :?> Derived

// Derivedクラスへダウンキャスト(2)
let d2:Derived = downcast base1