Skip to content

Draft: Support generics constraints

Rico Tzschichholz requested to merge wip/generics-constraints into main

This allows the following syntax. The constraint can be an existing type-symbol or type-parameter.

class Bar {
}

interface IFoo<G> where G : Bar {
}

class Foo<T> : Object, IFoo<T> where T : Bar {
}

struct FooStruct<T> where T : Bar {
	public T t;
}

delegate T FooFunc<T> (T t) where T : Bar;

T foo<T> (T t) where T : Bar {
	return null;
}

See #271

Edited by Rico Tzschichholz

Merge request reports