Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Abstract class - Calling extern methods of a child class #291

Open
shamanas opened this Issue · 1 comment

1 participant

@shamanas
Collaborator

Here is an example of a code that works

Foo: abstract class {
    getX: abstract func -> Int
    getY: abstract func -> Int

    getPos: func -> (Int,Int) {
        (getX(),getY())
    }
}

Bar: class extends Foo {
    getX: func -> Int { 42 }
    getY: func -> Int { 42 }
}

baz := Bar new()
(x,y) := baz getPos()
x toString() println()
y toString() println()

And one that should but doesnt

Foo: abstract class {
    getX: abstract func -> Int
    getY: abstract func -> Int

    getPos: func -> (Int,Int) {
        (getX(),getY())
    }
}

Bar: class extends Foo {
    getX: extern func -> Int
    getY: extern func -> Int
}

baz := Bar new()
(x,y) := baz getPos()
x toString() println()
y toString() println()

This is caused because in the rock-generated C code, extern functions are just #define-s while Foo__getPos() tries to find the methods in the class structure of Bar

@shamanas
Collaborator

Opening #293, a more genral problem that causes this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.