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