1 /* |
1 /* |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2014, 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. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
2776 validateValue(t.tsym, s, pos); |
2776 validateValue(t.tsym, s, pos); |
2777 validateRetention(t.tsym, s, pos); |
2777 validateRetention(t.tsym, s, pos); |
2778 validateDocumented(t.tsym, s, pos); |
2778 validateDocumented(t.tsym, s, pos); |
2779 validateInherited(t.tsym, s, pos); |
2779 validateInherited(t.tsym, s, pos); |
2780 validateTarget(t.tsym, s, pos); |
2780 validateTarget(t.tsym, s, pos); |
2781 validateDefault(t.tsym, s, pos); |
2781 validateDefault(t.tsym, pos); |
2782 } |
2782 } |
2783 |
2783 |
2784 private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { |
2784 private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { |
2785 Scope.Entry e = container.members().lookup(names.value); |
2785 Scope.Entry e = container.members().lookup(names.value); |
2786 if (e.scope != null && e.sym.kind == MTH) { |
2786 if (e.scope != null && e.sym.kind == MTH) { |
2895 } |
2895 } |
2896 private Set<Name> defaultTargets; |
2896 private Set<Name> defaultTargets; |
2897 |
2897 |
2898 |
2898 |
2899 /** Checks that s is a subset of t, with respect to ElementType |
2899 /** Checks that s is a subset of t, with respect to ElementType |
2900 * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE} |
2900 * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}, |
|
2901 * and {TYPE_USE} covers the set {ANNOTATION_TYPE, TYPE, TYPE_USE, |
|
2902 * TYPE_PARAMETER}. |
2901 */ |
2903 */ |
2902 private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) { |
2904 private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) { |
2903 // Check that all elements in s are present in t |
2905 // Check that all elements in s are present in t |
2904 for (Name n2 : s) { |
2906 for (Name n2 : s) { |
2905 boolean currentElementOk = false; |
2907 boolean currentElementOk = false; |
2908 currentElementOk = true; |
2910 currentElementOk = true; |
2909 break; |
2911 break; |
2910 } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) { |
2912 } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) { |
2911 currentElementOk = true; |
2913 currentElementOk = true; |
2912 break; |
2914 break; |
|
2915 } else if (n1 == names.TYPE_USE && |
|
2916 (n2 == names.TYPE || |
|
2917 n2 == names.ANNOTATION_TYPE || |
|
2918 n2 == names.TYPE_PARAMETER)) { |
|
2919 currentElementOk = true; |
|
2920 break; |
2913 } |
2921 } |
2914 } |
2922 } |
2915 if (!currentElementOk) |
2923 if (!currentElementOk) |
2916 return false; |
2924 return false; |
2917 } |
2925 } |
2918 return true; |
2926 return true; |
2919 } |
2927 } |
2920 |
2928 |
2921 private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) { |
2929 private void validateDefault(Symbol container, DiagnosticPosition pos) { |
2922 // validate that all other elements of containing type has defaults |
2930 // validate that all other elements of containing type has defaults |
2923 Scope scope = container.members(); |
2931 Scope scope = container.members(); |
2924 for(Symbol elm : scope.getElements()) { |
2932 for(Symbol elm : scope.getElements()) { |
2925 if (elm.name != names.value && |
2933 if (elm.name != names.value && |
2926 elm.kind == Kinds.MTH && |
2934 elm.kind == Kinds.MTH && |