Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,27 @@
import morfa.type.traits;
template < T >
alias IsEdible = HasMember< T, "eat" >;
template < T >
if (IsEdible< T >)
struct FoodBox
{
var food: T[];
}
struct Carrot
{
func eat(): void {}
}
struct Car {}
func main(): void
{
var carrotBox: FoodBox< Carrot >; // OK
carrotBox.food ~= Carrot(); // Adds a carrot
// var carBox: FoodBox< Car >; // Not allowed
static assert( not trait(compiles, func() { var carBox: FoodBox< Car >; } ));
}

View file

@ -0,0 +1,26 @@
interface IEdible
{
public func eat(): void;
}
template < T >
if (IsDerivedOf< T, IEdible >)
struct FoodBox
{
var food: T[];
}
class Carrot: IEdible
{
public override func eat(): void {}
}
class Car {}
func main(): void
{
var carrotBox: FoodBox< Carrot >; // OK
// var carBox: FoodBox< Car >; // Not allowed
static assert( not trait(compiles, func() { var carBox: FoodBox< Car >; } ));
}