methods/bug791283.vala \
methods/argument-array-initilizer.vala \
methods/generics.vala \
+ methods/print-attribute.vala \
+ methods/print-attribute-invalid.test \
methods/printf-invalid.test \
methods/printf-constructor.vala \
methods/printf-constructor-invalid.test \
--- /dev/null
+errordomain FooError {
+ FAIL
+}
+
+class Foo {
+ [Print]
+ public void foo (string s) {
+ assert (this != null);
+ assert (s == "4711Footrue");
+ }
+}
+
+[Print]
+void foo (string s) {
+ assert (s == "232.7182footrue");
+}
+
+[Print]
+void bar (string s) throws Error {
+ assert (s == "423.1415barfalse");
+ throw new FooError.FAIL ("bar");
+}
+
+void main () {
+ {
+ foo (23, 2.7182f, "foo", true);
+ }
+
+ bool reached = false;
+ try {
+ bar (42, 3.1415f, "bar", false);
+ } catch (FooError.FAIL e) {
+ reached = true;
+ } catch {
+ assert_not_reached ();
+ }
+ assert (reached);
+
+ {
+ var f = new Foo ();
+ f.foo (4711, "Foo", true);
+ }
+}
Report.error (parameters[0].source_reference, "Named parameter required before `...'");
}
+ if (get_attribute ("Print") != null && (parameters.size != 1 || parameters[0].variable_type.type_symbol != context.analyzer.string_type.type_symbol)) {
+ error = true;
+ Report.error (source_reference, "[Print] methods must have exactly one parameter of type `string'");
+ }
+
var optional_param = false;
foreach (Parameter param in parameters) {
param.check (context);