Skip to content

Instantly share code, notes, and snippets.

@fal-works
Created April 14, 2020 17:19
Show Gist options
  • Save fal-works/1e6dfa8ca1aad17ef98244a29fec7670 to your computer and use it in GitHub Desktop.
Save fal-works/1e6dfa8ca1aad17ef98244a29fec7670 to your computer and use it in GitHub Desktop.
Haxe: abstract with @:generic type (doesn't compile)
@: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