Created
April 14, 2020 17:19
-
-
Save fal-works/1e6dfa8ca1aad17ef98244a29fec7670 to your computer and use it in GitHub Desktop.
Haxe: abstract with @:generic type (doesn't compile)
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
@:generic // Without this it compiles fine | |
class GenericObject<T> { | |
final value: T; | |
public function new(v: T) | |
this.value = v; | |
} | |
abstract GenericAbstract<T>(GenericObject<T>) from GenericObject<T> { | |
public inline function new(data: GenericObject<T>) | |
this = data; | |
} | |
class Main { | |
static function main() { | |
final data = new GenericObject(42); | |
new GenericAbstract(data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment