summaryrefslogtreecommitdiff
path: root/vala/valasymbolresolver.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-07-15 17:46:58 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2020-07-15 18:58:43 +0200
commit244b69cc5386b6707d603ea5a437ae3f02952c58 (patch)
tree046e854bba11f207aee66ce314ec86dca1745f72 /vala/valasymbolresolver.vala
parent866258f688d781f3536892b8f93abdd3112198ec (diff)
downloadvala-244b69cc5386b6707d603ea5a437ae3f02952c58.tar.gz
vala: Use inheritted scopes of base-types/prerequisites to resolve symbols
Fixes https://gitlab.gnome.org/GNOME/vala/issues/54
Diffstat (limited to 'vala/valasymbolresolver.vala')
-rw-r--r--vala/valasymbolresolver.vala43
1 files changed, 43 insertions, 0 deletions
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index 28365127a..3f9bc6de0 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -286,6 +286,49 @@ public class Vala.SymbolResolver : CodeVisitor {
scope = scope.parent_scope;
}
+ // Look for matches in inner types of base-types/prerequisites
+ ObjectTypeSymbol? current_symbol = null;
+ if (sym == null) {
+ scope = current_scope;
+ while (scope != null) {
+ if (scope.owner is ObjectTypeSymbol) {
+ current_symbol = (ObjectTypeSymbol) scope.owner;
+ break;
+ }
+ scope = scope.parent_scope;
+ }
+ }
+ if (current_symbol != null) {
+ unowned List<DataType> types;
+ if (current_symbol is Class) {
+ types = ((Class) current_symbol).get_base_types ();
+ } else if (current_symbol is Interface) {
+ types = ((Interface) current_symbol).get_prerequisites ();
+ } else {
+ assert_not_reached ();
+ }
+ foreach (DataType type in types) {
+ if (type.type_symbol == null) {
+ continue;
+ }
+
+ var local_sym = SemanticAnalyzer.symbol_lookup_inherited (type.type_symbol, unresolved_symbol.name);
+
+ // only look for types and type containers
+ if (!(local_sym is Namespace || local_sym is TypeSymbol)) {
+ local_sym = null;
+ }
+
+ if (local_sym != null && local_sym.access == SymbolAccessibility.PUBLIC) {
+ if (sym != null && sym != local_sym) {
+ unresolved_symbol.error = true;
+ Report.error (unresolved_symbol.source_reference, "`%s' is an ambiguous reference between `%s' and `%s'".printf (unresolved_symbol.name, sym.get_full_name (), local_sym.get_full_name ()));
+ return null;
+ }
+ sym = local_sym;
+ }
+ }
+ }
if (sym == null && unresolved_symbol.source_reference != null) {
foreach (UsingDirective ns in unresolved_symbol.source_reference.using_directives) {
if (ns.error || ns.namespace_symbol is UnresolvedSymbol) {