COMMUNITY

Haxe 4.0.0-rc.3 Class Generic with Constructible and Other Type

I’ve been wracking my brain with trying to get a generic with Constructible type with another class working in the examples i’ve found it work but for some reason when trying it with rc-3 not matter how i modify the statement it doesn’t seem it work. Each part works by themselves but they won’t work together.

I could manually instantiate with the base Type class but i want a more elegant solution that would be caught at compile time.

Below is the stub of the class I’m trying to create.

package com.bnns.starling.core;

import haxe.Constraints.Constructible;

import starling.display.Sprite;

import starling.display.DisplayObject;

@:generic
//Error I'm getting at the below line is "Can only create structures"
class GameObject<T:(Constructible<Void->Void> & Sprite)>{

This seems to be a minor bug, because it works if you remove the parens from the type parameter constraint:

class GameObject<T:Constructible<Void->Void> & Sprite>{