generics/method-to-delegate-incompatible.test \
generics/method-to-delegate-incompatible-2.test \
generics/method-to-delegate-incompatible-3.test \
+ generics/multiple-classes-constraints.test \
generics/null-type.vala \
generics/property-gobject-set.vala \
generics/property-int-cast.vala \
Invalid Code
-class Foo {}
-class Fuu {}
+class Foo {
+}
+
+class Faz {
+}
-class Bar<G> where G : Foo, Fuu {
+class Bar<G> where G : Foo, Faz {
}
-void main () {}
\ No newline at end of file
+void main () {
+}
* @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;
return false;
}
+ 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 may only be constrained by a single class type");
+ error = true;
+ break;
+ }
+ class_constraint = true;
+ }
+ }
+
return !error;
}
}