Created
September 14, 2014 02:13
-
-
Save gfx/5fd30a5c496faf290f1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base { | |
init() { | |
println("Base") | |
} | |
} | |
class Derived: Base { | |
override init() { | |
super.init() | |
println("Derived") | |
} | |
final func f() { | |
println("Derived#f()") | |
} | |
func d() { | |
println("Derived#d()") | |
} | |
} | |
func make<T: Base>(t: T.Type) -> T { | |
return t() | |
} | |
make(Base.self) // Base | |
make(Derived.self) // Base | |
var obj = make(Derived.self) // OK but type mismatch | |
obj.f() // OK, static dispatch | |
obj.d() // EXC_BAD_ACCESS, dynamic dispatch | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was suffering from this also - great find in marking as final, but it certainly does seem like a bug!