About adapting type parameter of generic method, using actual invocation in AST.
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
Hi,
I'm looking for the way to extract type adapting rule from AST. For generic class, there is [ClassTypingContext](https://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/support/visitor/ClassTypingContext.html). Is there any equivalent concept in `CtExecutable`? I've tried `MethodTypingContext` but I'm not sure it can be used for my purpose.
## Example:
```java
// A.java
public class A {
public static void genericMethod(E e) {
System.out.println("genericMethod" + e.toString());
}
}
// TestA.java
public class TestA {
public void test() {
// here!
A.genericMethod("e");
}
}
```
I want to extract the information from the AST of `TestA` above, which tells me that the type parameter `E` is actually in `java.lang.String`.
Below is what I've tried roughly and it cause errors. Also, note that I'm not sure about the actual usage of `MethodTypingContext`
```java
// let's say method is `TestA.test()`
CtTypeParameter e = method.getFormalCtTypeParameters().get(0);
// let's say A.genericMethod("e") is `invocation`
new MethodTypingContext().setExecutableReference(invocation.getExecutable()).adaptType(e)
```
Contributor guide
Assessment
This issue has not been assessed yet.