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 () {
+}
}
foreach (TypeParameter p in type_parameters) {
- p.check (context);
+ if (!p.check (context)) {
+ error = true;
+ }
}
return_type.check (context);
* @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 TraverseStatus.CONTINUE;
});
+ foreach (TypeParameter p in type_parameters) {
+ if (!p.check (context)) {
+ error = true;
+ }
+ }
+
return_type.accept (traverse);
var optional_param = false;
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");
}
+ foreach (TypeParameter p in type_parameters) {
+ if (!p.check (context)) {
+ error = true;
+ }
+ }
+
return !error;
}
}
}
foreach (TypeParameter p in type_parameters) {
- p.check (context);
+ if (!p.check (context)) {
+ error = true;
+ }
}
foreach (Field f in fields) {
return name == param2.name && parent_symbol == param2.parent_symbol;
}
- public bool check_constraint () {
+ public override bool check (CodeContext context) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
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;
+ Report.error (source_reference, "a type parameter may only be constrained by a single class type");
+ error = true;
+ break;
}
class_constraint = true;
}
}
- return true;
+
+ return !error;
}
}