Skip to content

Instantly share code, notes, and snippets.

@ShadowBelmolve
Forked from anonymous/Main.hx
Last active January 2, 2016 10:19
Show Gist options
  • Save ShadowBelmolve/8289232 to your computer and use it in GitHub Desktop.
Save ShadowBelmolve/8289232 to your computer and use it in GitHub Desktop.
haxe-traits break with this. Seems that if you import an "interface A"(IEntity) that has a variable of type "class B"(EntityData) that has a function with return type "class C"(Entity) and "class C" implements the "interface A", then variables from "interface A" simply aren't copied to "class C" or something like this. The same if you import "Cl…
package;
//works
//import world.Entity;
//works
//import world.IEntity;
//import world.Entity;
//not work
//import world.Entity;
//import world.IEntity;
//not work
import world.IEntity;
/**
* @author Joshua Granick
*/
class Main
{
// Entry point
static public function main():Void
{
}
}
➜ haxe -main Main -lib traits
world/Entity.hx:3: lines 3-4 : Field entityData needed by world.IEntity is missing
world/Entity.hx:3: lines 3-4 : Field x needed by world.IEntity is missing
world/Entity.hx:3: lines 3-4 : Field y needed by world.IEntity is missing
world/Entity.hx:3: lines 3-4 : Field z needed by world.IEntity is missing
package world;
class Entity implements IEntity
{}
package world;
class EntityData
{
//Entity here is important
public function breakAll() : Entity
{
return null;
}
}
package world;
interface IEntity extends traits.ITrait
{
public var x:Float = 0.0;
public var z:Float = 0.0;
public var y:Float = 0.0;
//EntityData here is important
public var entityData:EntityData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment