Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type inference of local variables vs. DSLD contributions #605

Closed
eric-milles opened this issue Jun 12, 2018 · 1 comment
Closed

Fix type inference of local variables vs. DSLD contributions #605

eric-milles opened this issue Jun 12, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@eric-milles
Copy link
Member

Consider the following:

some.dsld

contribute(enclosingMethod('foo')) {
  property name: 'bar', type: BigInteger
}

Script.groovy

def foo(Integer bar) {
  bar // should inference as Integer, not BigInteger
}

At present, DSLD contributions (from method and property) are overriding local parameter/variable declarations.

@eric-milles eric-milles self-assigned this Jun 12, 2018
@eric-milles eric-milles added this to the v3.0.0 milestone Jun 12, 2018
@eric-milles
Copy link
Member Author

eric-milles commented Jun 12, 2018

This comes up in DSLD scripts as well. method and params are easily used as variable names.

import org.codehaus.groovy.ast.*
contribute(methods: enclosingMethod()) {
  MethodNode mn = null
  for (MethodNode method : methods) {
    Parameter[] params = method.parameters
    // ... if (...) {
    mn = method
    // }
  }
  method(name:'other', params: params(mn))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant