--- /dev/null
+Invalid Code
+
+class Foo {}
+class Fuu {}
+
+class Bar<G> where G : Foo, Fuu {
+}
+
+void main () {}
\ No newline at end of file
* @return index of a type parameter, or -1
*/
public abstract int get_type_parameter_index (string name);
+
+ public bool check_constraints () {
+ bool error = false;
+ foreach (var parameter in this.get_type_parameters ()) {
+ if (!parameter.check_constraint ()) {
+ error = true;
+ }
+ }
+ return !error;
+ }
}
return !error;
}
+ if (!this.check_constraints ()) {
+ error = true;
+ }
+
if (!external_package && has_attribute ("DBus") && !context.has_package ("gio-2.0")) {
error = true;
Report.error (source_reference, "gio-2.0 package required for DBus support");
return name == param2.name && parent_symbol == param2.parent_symbol;
}
+ public bool check_constraint () {
+ bool class_constraint = false;
+ foreach (var type in get_type_constraints ()) {
+ if (type.symbol is Class) {
+ if (class_constraint) {
+ Report.error (source_reference, "a type parameter can only be constrained with one class type");
+ return false;
+ }
+ class_constraint = true;
+ }
+ }
+ return true;
+ }
+
public override bool check (CodeContext context) {
if (checked) {
return !error;