uqbar-project / wollok

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

Classes and objects can't override methods to Object class by default #511

Closed PalumboN closed 8 years ago

PalumboN commented 8 years ago

For example

class Foo {
    override method == (other) {
        return true
    }
}

doesn't compile because Method does not override anything.

However if I write the inherits

class Foo inherits Object {
    override method == (other) {
        return true
    }
}

it's ok.

javierfernandes commented 8 years ago

Currently to express the relation that any class inherits from wollok.lang.Object, we are kind of hacking the model, forcing the object into the WClass parent attribute. This is being done in the interpreter, so when the validator executes the WClass doesn't have this relation, therefore fails to find the super method.

Ideally we would like to customize some xtext core part to default the WClass.parent attribute. So a single place in code will apply to the interpreter, the validator etc.. Actually to the parsing / linking.

That is it, I believe this should be a custom linking strategy !

npasserini commented 8 years ago

Fixed in https://github.com/uqbar-project/wollok/pull/557

javierfernandes commented 8 years ago

Just a side-note. The static check failed. So if you just wrote "method" without the override it compiled fine and you were able to execute with the actual override semantic :) I mean, it worked ! Another workaround would be to disabled the "override keyword check".

Just a "color note" ? ;)