GDSL closure host/delegate method clash

Answered

Hi,

I have the following use case in my library, where some classes are transformed by groovy AST transformation and `action` method is created at compilation time:

class Instrumented {
Instrumented create() {
action {
create()
}
}

class Delegate {
void create() {
}
}
}

Action method sets closure's resolveStrategy to DELEGATE_FIRST and delegate to an instance of `Delegate` class.

A GDSL script I created looks like this:

contributor(context(ctype: 'Instrumented')) {
method(name: 'action', type: 'Instrumented', params: [body: {}])
}

contributor(context(scope: closureScope())) {
if (enclosingCall('action')) {
delegatesTo(findClass('Instrumented.Delegate'))
}
}

 

Due to clash between methods signatures IDEA prefers `Instrumented#create() ` instead of `Delegate#create`, which ruins the point of groovy delegation.

Am I doing anything wrong? Can I force IDEA to add delegate's method on top of owner's ones?

Side question: any chance IntelliJ will finally create good documentation on GDSL scripts? :)

 

 

This is how it looks like (IDEA IntelliJ IDEA 2019.3.3 (Ultimate Edition) Build #IU-193.6494.35)

0
2 comments
Avatar
Permanently deleted user

Thanks, created an issue here: https://youtrack.jetbrains.com/issue/IDEA-233150

0

Please sign in to leave a comment.