equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 6418666 6423973 6453386 |
26 * @bug 6418666 6423973 6453386 7025809 |
27 * @summary Test the NoTypes: VOID, PACKAGE, NONE |
27 * @summary Test the NoTypes: VOID, PACKAGE, NONE |
28 * @author Scott Seligman |
28 * @author Scott Seligman |
29 * @library ../../../lib |
29 * @library ../../../lib |
30 * @build JavacTestingAbstractProcessor |
30 * @build JavacTestingAbstractProcessor |
31 * @compile -g NoTypes.java |
31 * @compile -g NoTypes.java |
73 |
73 |
74 verifyKind(VOID, types.getNoType(VOID)); |
74 verifyKind(VOID, types.getNoType(VOID)); |
75 verifyKind(NONE, types.getNoType(NONE)); |
75 verifyKind(NONE, types.getNoType(NONE)); |
76 |
76 |
77 // The return type of a constructor or void method is VOID. |
77 // The return type of a constructor or void method is VOID. |
78 class Scanner extends ElementScanner7<Void, Void> { |
78 class Scanner extends ElementScanner<Void, Void> { |
79 @Override |
79 @Override |
80 public Void visitExecutable(ExecutableElement e, Void p) { |
80 public Void visitExecutable(ExecutableElement e, Void p) { |
81 verifyKind(VOID, e.getReturnType()); |
81 verifyKind(VOID, e.getReturnType()); |
82 ExecutableType t = (ExecutableType) e.asType(); |
82 ExecutableType t = (ExecutableType) e.asType(); |
83 verifyKind(VOID, t.getReturnType()); |
83 verifyKind(VOID, t.getReturnType()); |
87 TypeElement c = elements.getTypeElement("NoTypes.C"); |
87 TypeElement c = elements.getTypeElement("NoTypes.C"); |
88 new Scanner().scan(c); |
88 new Scanner().scan(c); |
89 } |
89 } |
90 |
90 |
91 /** |
91 /** |
92 * Verify that a NoType instance is of a particular kind, |
92 * Verify that a NoType instance is of a particular kind, and that |
93 * and that TypeKindVisitor7 properly dispatches on it. |
93 * the latest TypeKindVisitor properly dispatches on it. |
94 */ |
94 */ |
95 private void verifyKind(TypeKind kind, TypeMirror type) { |
95 private void verifyKind(TypeKind kind, TypeMirror type) { |
96 class Vis extends TypeKindVisitor7<TypeKind, Void> { |
96 class Vis extends TypeKindVisitor<TypeKind, Void> { |
97 @Override |
97 @Override |
98 public TypeKind visitNoTypeAsVoid(NoType t, Void p) { |
98 public TypeKind visitNoTypeAsVoid(NoType t, Void p) { |
99 return VOID; |
99 return VOID; |
100 } |
100 } |
101 @Override |
101 @Override |
109 } |
109 } |
110 if (kind != type.getKind() || kind != new Vis().visit(type)) |
110 if (kind != type.getKind() || kind != new Vis().visit(type)) |
111 throw new AssertionError(); |
111 throw new AssertionError(); |
112 } |
112 } |
113 |
113 |
114 |
|
115 // Fodder for the tests |
114 // Fodder for the tests |
116 |
|
117 interface I { |
115 interface I { |
118 } |
116 } |
119 |
117 |
120 class C { |
118 class C { |
121 C() {} |
119 C() {} |