Created
August 2, 2013 08:32
-
-
Save Simn/6138349 to your computer and use it in GitHub Desktop.
Haxe generic type parameter construction
This file contains hidden or 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
typedef Constructible = { | |
public function new():Void; | |
} | |
@:generic | |
class Gen<T:(Constructible, Main)> { | |
public function new() { } | |
public function make() { | |
return new T(); | |
} | |
} | |
class Main { | |
static public function main() { | |
new Gen<Main>().make(); | |
new Gen<Mainer>().make(); | |
new Gen<Mainest>().make(); | |
} | |
public function new() { | |
trace("new Main"); | |
} | |
} | |
class Mainer extends Main { | |
public function new() { | |
trace("new Mainer"); | |
super(); | |
} | |
} | |
class Mainest extends Mainer { | |
public function new() { | |
trace("new Mainest"); | |
super(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment