uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

WKOs that inherit from a class can't use inherited attributes in its code #603

Closed mmatos closed 8 years ago

mmatos commented 8 years ago

Unlike subclasses, methods in a WKO that inherit from a class that defines an attribute cannot use that attribute directly. The code doesn't compile and the error "Couldn't resolve reference to Referenciable " appears.

javierfernandes commented 8 years ago

Ok. So the issue here is not in the runtime part of wollok (the interpreter), but in the static part. This check is not coded by us, but an out-of-the-box check that xtext provides for references (the linker). This linker bases the reference resolution and the scoping of your language. The scope can be customized, and it is in Wollok.

I don't remember the exact name of the class, there are a couple of "WollokScope" classes. Some of them are for resolving imports and more hardcore stuff. But there's one that is coded in a declarative way following xtext convention that should have definitions of scopes for, for example a Method (WMethodDeclaration), and Class (WClass), and so on.

I guess that you should customize there the scoping for WNamedObject (WKO's) probably following what is already there for WClass'es

Let me know if this sounds reasonable

mmatos commented 8 years ago

Thanks a lot for the help! It would seem that this is the cause, in WollokDslScopeProvider def dispatch IScope scope(WNamedObject namedObject) { namedObject.declaredVariables.asScope } The parent is not taken into consideration, unlike the definition for WClass

javierfernandes commented 8 years ago

Solved right ?