提交 7be4e72d 编写于 作者: J jjg

8026791: wrong type_path encoded for method_return on an inner class constructor

Reviewed-by: jjg
Contributed-by: wdietl@gmail.com
上级 56280f0e
......@@ -323,7 +323,16 @@ public class TypeAnnotations {
if (type == null) {
// When type is null, put the type annotations to the symbol.
// This is used for constructor return annotations, for which
// no appropriate type exists.
// we use the type of the enclosing class.
type = sym.getEnclosingElement().asType();
// Declaration annotations are always allowed on constructor returns.
// Therefore, use typeAnnotations instead of onlyTypeAnnos.
type = typeWithAnnotations(typetree, type, typeAnnotations, typeAnnotations);
// Note that we don't use the result, the call to
// typeWithAnnotations side-effects the type annotation positions.
// This is important for constructors of nested classes.
sym.appendUniqueTypeAttributes(typeAnnotations);
return;
}
......
......@@ -21,14 +21,16 @@
* questions.
*/
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
/*
* @test
* @bug 8026791
* @summary Test population of reference info for constructor results
* @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
* @run main Driver Constructors
*/
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
public class Constructors {
@TADescriptions({
......@@ -42,8 +44,8 @@ public class Constructors {
}
@TADescriptions({
@TADescription(annotation = "TA", type = METHOD_RETURN),
@TADescription(annotation = "TB", type = METHOD_RETURN),
@TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
})
@TestClass("Test$Inner")
......@@ -56,9 +58,9 @@ public class Constructors {
@TADescriptions({
@TADescription(annotation = "TA", type = METHOD_RECEIVER),
@TADescription(annotation = "TB", type = METHOD_RETURN),
@TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TC", type = METHOD_RECEIVER),
@TADescription(annotation = "TD", type = METHOD_RETURN),
@TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}),
@TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
})
@TestClass("Test$Inner")
......@@ -72,9 +74,9 @@ public class Constructors {
@TADescriptions({
@TADescription(annotation = "TA", type = METHOD_RECEIVER),
@TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
@TADescription(annotation = "TC", type = METHOD_RETURN),
@TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
@TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
@TADescription(annotation = "TE", type = METHOD_RETURN),
@TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
@TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
})
@TestClass("Outer$Middle$Inner")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册