groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jamie Echlin <jamie.ech...@gmail.com>
Subject replace a property in a static type checking script
Date Wed, 02 Sep 2015 07:24:24 GMT
Struggling a bit here with my STC script.

The binding variables has a Map<String, Object>

But, based on the key, the STC script can provide a more specific type. So
the input script might be something like:

map["duck"].quack()

This is failing at the moment because Object has no quack() method.

In the unresolvedProperty closure I am trying to replace map["duck"] with
an expression with a Duck return type:

def bexp = new BinaryExpression(objectExpression.leftExpression,
objectExpression.operation, objectExpression.rightExpression)
bexp.setType(ClassHelper.make(Duck))
def replacementPexp = new PropertyExpression(bexp, pexp.property)
makeDynamic(replacementPexp, ClassHelper.VOID_TYPE)
setHandled(false);

I don't want to set this as handled, because I want quack() to be checked.

Is there a way to tell the STC script to "reparse" this expression as I am
trying to do, or do I need another AST transform in an earlier compile
phase?

Any help appreciated, please LMK if not clear.

cheers, jamie

Mime
View raw message