-
-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(template): relax template parameter constraint (#1535)
* test CtTypeReference as Template parameter * fix: TemplateParemeter proxy can be used for CtTypeReference
- Loading branch information
1 parent
494ba6f
commit 770e484
Showing
3 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/spoon/test/template/testclasses/TypeReferenceClassAccessTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package spoon.test.template.testclasses; | ||
|
||
import spoon.reflect.reference.CtTypeReference; | ||
import spoon.template.ExtensionTemplate; | ||
import spoon.template.Local; | ||
import spoon.template.Parameter; | ||
|
||
public class TypeReferenceClassAccessTemplate extends ExtensionTemplate { | ||
Object o; | ||
|
||
$Type$ someMethod($Type$ param) { | ||
o = $Type$.out; | ||
$Type$ ret = new $Type$(); | ||
return ret; | ||
} | ||
|
||
@Local | ||
public TypeReferenceClassAccessTemplate(CtTypeReference<?> typeRef) { | ||
this.typeRef = typeRef; | ||
} | ||
|
||
@Parameter("$Type$") | ||
CtTypeReference<?> typeRef; | ||
|
||
@Local | ||
static class $Type$ { | ||
static final String out = ""; | ||
static long currentTimeMillis(){ | ||
return 0; | ||
} | ||
} | ||
|
||
public static class Example<T> { | ||
static final String out = ""; | ||
static long currentTimeMillis(){ | ||
return 0; | ||
} | ||
} | ||
} |