Skip to content

Commit f2ecb10

Browse files
committed
SONARJAVA-7236 Keep the type arguments of a declared variable
1 parent edd2cc0 commit f2ecb10

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎java-frontend/src/main/java/org/sonar/java/model/SemsitterTranslator.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,10 @@ private VariableTreeImpl declarator(Node node, ModifiersTreeImpl modifiers, Type
693693
tree.completeTypeAndInitializer(tree.type(), token(required(node, "=")), initializer);
694694
}
695695
bindDeclaration(tree, nameNode(node) == null ? node : nameNode(node), name);
696-
if (tree.symbol().type() != null && !tree.symbol().type().isUnknown()) {
696+
Type declared = tree.type().symbolType();
697+
if (declared.isParameterized() && tree.symbol() instanceof JSymbol symbol) {
698+
symbol.type(declared);
699+
} else if (tree.symbol().type() != null && !tree.symbol().type().isUnknown()) {
697700
ascribe(tree.type(), tree.symbol().type());
698701
}
699702
return tree;

0 commit comments

Comments
 (0)