fixes #2590; methods now require a .base annotation

This commit is contained in:
Araq 2015-09-06 02:29:30 +02:00
commit dc047931bb
17 changed files with 69 additions and 32 deletions

View file

@ -3,7 +3,7 @@ type
var myObj* : ref TObj
method test123(a : ref TObj) =
method test123(a : ref TObj) {.base.} =
echo("Hi base!")
proc testMyObj*() =

View file

@ -2,7 +2,7 @@
type MyClass = ref object of RootObj
method HelloWorld*(obj: MyClass) =
method HelloWorld*(obj: MyClass) {.base.} =
when defined(myPragma):
echo("Hello World")
# discard # with this line enabled it works

View file

@ -2,7 +2,7 @@ discard """
output: "do nothing"
"""
method somethin(obj: TObject) =
method somethin(obj: RootObj) {.base.} =
echo "do nothing"
type
@ -14,9 +14,9 @@ type
TSomethingElse = object
PSomethingElse = ref TSomethingElse
method foo(a: PNode, b: PSomethingElse) = discard
method foo(a: PNode, b: PSomethingElse) {.base.} = discard
method foo(a: PNodeFoo, b: PSomethingElse) = discard
var o: TObject
var o: RootObj
o.somethin()

View file

@ -2,7 +2,7 @@ type
Obj1 = ref object {.inheritable.}
Obj2 = ref object of Obj1
method beta(x: Obj1): int
method beta(x: Obj1): int {.base.}
proc delta(x: Obj2): int =
beta(x)

View file

@ -11,7 +11,7 @@ type
PlusExpr = ref object of Expression
a, b: Expression
method eval(e: Expression): int = quit "to override!"
method eval(e: Expression): int {.base.} = quit "to override!"
method eval(e: Literal): int = return e.x
method eval(e: PlusExpr): int = return eval(e.a) + eval(e.b)

View file

@ -14,7 +14,7 @@ type
TParticle = object of TThing
a, b: int
method collide(a, b: TThing) {.inline.} =
method collide(a, b: TThing) {.base, inline.} =
echo "collide: thing, thing"
method collide(a: TThing, b: TUnit) {.inline.} =

View file

@ -5,7 +5,7 @@ discard """
type
Test = object of TObject
method doMethod(a: ref TObject) {.raises: [EIO].} =
method doMethod(a: ref TObject) {.base, raises: [EIO].} =
quit "override"
method doMethod(a: ref Test) =

View file

@ -10,7 +10,7 @@ type
TParticle = object of TThing
a, b: int
method collide(a, b: TThing) {.inline.} =
method collide(a, b: TThing) {.base, inline.} =
quit "to override!"
method collide[T](a: TThing, b: TUnit[T]) {.inline.} =

View file

@ -2,12 +2,12 @@
# for recursive methods works, no code is being executed
type
Obj = ref object of TObject
Obj = ref object of RootObj
# Mutual recursion
method alpha(x: Obj)
method beta(x: Obj)
method alpha(x: Obj) {.base.}
method beta(x: Obj) {.base.}
method alpha(x: Obj) =
beta(x)
@ -17,6 +17,6 @@ method beta(x: Obj) =
# Simple recursion
method gamma(x: Obj) =
method gamma(x: Obj) {.base.} =
gamma(x)