[vala/staging: 5/5] vala: Stricter check of type-arguments for non-external method and parameter
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 5/5] vala: Stricter check of type-arguments for non-external method and parameter
- Date: Fri, 15 Oct 2021 10:03:14 +0000 (UTC)
commit d3e50131b496aa981ea56b90145226716363c622
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Oct 15 12:02:21 2021 +0200
vala: Stricter check of type-arguments for non-external method and parameter
Make sure types in API declarations are completely defined.
tests/Makefile.am | 2 ++
tests/semantic/method-return-missing-type-argument.test | 10 ++++++++++
tests/semantic/parameter-missing-type-argument.test | 10 ++++++++++
vala/valamethod.vala | 8 +++++---
vala/valaparameter.vala | 3 ++-
5 files changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7cd0168b7..d7c16f3fb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1082,6 +1082,7 @@ TESTS = \
semantic/method-private-virtual.test \
semantic/method-protected.test \
semantic/method-return-accessibility.test \
+ semantic/method-return-missing-type-argument.test \
semantic/method-return-too-few-type-arguments.test \
semantic/method-return-too-many-type-arguments.test \
semantic/method-return-valist.test \
@@ -1101,6 +1102,7 @@ TESTS = \
semantic/parameter-accessibility.test \
semantic/parameter-default-invalid.test \
semantic/parameter-default-type.test \
+ semantic/parameter-missing-type-argument.test \
semantic/parameter-out-default.test \
semantic/parameter-params.test \
semantic/parameter-ref-default.test \
diff --git a/tests/semantic/method-return-missing-type-argument.test
b/tests/semantic/method-return-missing-type-argument.test
new file mode 100644
index 000000000..c61dbafb4
--- /dev/null
+++ b/tests/semantic/method-return-missing-type-argument.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo<G> {
+}
+
+Foo bar () {
+}
+
+void main () {
+}
diff --git a/tests/semantic/parameter-missing-type-argument.test
b/tests/semantic/parameter-missing-type-argument.test
new file mode 100644
index 000000000..b9173da02
--- /dev/null
+++ b/tests/semantic/parameter-missing-type-argument.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo<G> {
+}
+
+void bar (Foo foo) {
+}
+
+void main () {
+}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 9769efff9..2fd80b5c2 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -816,9 +816,11 @@ public class Vala.Method : Subroutine, Callable {
context.analyzer.current_symbol = this;
return_type.floating_reference = returns_floating_reference;
- return_type.check (context);
- if (!external_package) {
- context.analyzer.check_type (return_type);
+ if (return_type.check (context)) {
+ if (!external_package) {
+ context.analyzer.check_type (return_type);
+ return_type.check_type_arguments (context);
+ }
}
if (return_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala
index 7bbb2cedb..53740f778 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -206,8 +206,9 @@ public class Vala.Parameter : Variable {
}
if (!ellipsis) {
- if (!external_package) {
+ if (!external_package && !variable_type.error) {
context.analyzer.check_type (variable_type);
+ variable_type.check_type_arguments (context);
// check symbol availability
if ((parent_symbol == null || !parent_symbol.external_package) &&
variable_type.type_symbol != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]