Skip to content

Commit

Permalink
Closes #782
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Aug 15, 2014
1 parent 023394f commit 9a12d6b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
16 changes: 10 additions & 6 deletions source/rock/middle/PropertyDecl.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ PropertyDecl: class extends VariableDecl {
}
cls = node as ClassDecl

// setup getter
if(getter != null) {
// are we a cover? if yes, use func@
if(cls instanceOf?(CoverDecl)) {
if(cls as CoverDecl fromType == null || !cls as CoverDecl fromType isPointer()) {
getter isThisRef = true
}
}
}

{
response := super(trail, res)
if (!response ok()) {
Expand Down Expand Up @@ -128,12 +138,6 @@ PropertyDecl: class extends VariableDecl {
getter setName(getGetterName()) .setReturnType(type)
cls addFunction(getter)

// are we a cover? if yes, use func@
if(cls instanceOf?(CoverDecl)) {
if(cls as CoverDecl fromType == null || !cls as CoverDecl fromType isPointer()) {
getter isThisRef = true
}
}
// static property -> static getter
if(isStatic()) {
getter setStatic(true)
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions test/compiler/properties/pdfe-cover.ooc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import math

// Does not build
Point: cover {
x, y: Float
norm ::= (this x pow(2.0f) + this y pow(2.0f)) sqrt()
normToo : Float { get { (this x pow(2.0f) + this y pow(2.0f)) sqrt() } }
}

main: func {
p := (2, 2) as Point
n1 := p norm
n2 := p normToo
if (n1 != n2) {
"Fail: expected n1 == n2, but got %f != %f" printfln(n1, n2)
exit(1)
}

"Pass" println()
}

0 comments on commit 9a12d6b

Please sign in to comment.