Skip to content

Commit

Permalink
Detecting implicit This for static functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpiuva committed Mar 22, 2016
1 parent 4ff6c37 commit 098a7e6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/rock/middle/TypeDecl.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -1383,10 +1383,13 @@ TypeDecl: abstract class extends Declaration {
if (fDecl) {
if (call debugCondition()) " \\o/ Found fDecl for %s, it's %s" format(call name, fDecl toString()) println()
if (call suggest(fDecl, res, trail)) {
if (fDecl hasThis() && !call getExpr()) {
call setExpr(VariableAccess new("this", call token))
if (!call getExpr()) {
if (fDecl hasThis()) {
call setExpr(VariableAccess new("this", call token))
}
if (res params explicitThis && fDecl name != "init" && fDecl name != "__defaults__") {
call token printMessage("Implicit this detected for call to " + fDecl name + "!")
name := fDecl hasThis() ? "this" : "This"
call token printMessage("Implicit " + name + " detected for call to " + fDecl name + "!")
}
}
return 0
Expand Down Expand Up @@ -1418,7 +1421,7 @@ TypeDecl: abstract class extends Declaration {
name := vDecl isStatic() ? "This" : "this"
call setExpr(VariableAccess new(name, call token))
if (res params explicitThis) {
call token printMessage("Implicit this detected for unresolved call to " + vDecl name + "!")
call token printMessage("Implicit " + name + " detected for unresolved call to " + vDecl name + "!")
}
}
}
Expand Down

0 comments on commit 098a7e6

Please sign in to comment.