242 protected final void setOuterClass(ClassDefinition outerClass) {
243 if (this.outerClass != null) throw new CompilerError("setOuterClass");
244 this.outerClass = outerClass;
245 }
246
247 /**
248 * Set the class' enclosing current instance pointer.
249 * Must be done at most once.
250 */
251 protected final void setOuterMember(MemberDefinition outerMember) {
252
253 if (isStatic() || !isInnerClass()) throw new CompilerError("setOuterField");
254 if (this.outerMember != null) throw new CompilerError("setOuterField");
255 this.outerMember = outerMember;
256 }
257
258 /**
259 * Tell if the class is inner.
260 * This predicate also returns true for top-level nested types.
261 * To test for a true inner class as seen by the programmer,
262 * use <tt>!isTopLevel()</tt>.
263 */
264 public final boolean isInnerClass() {
265 return outerClass != null;
266 }
267
268 /**
269 * Tell if the class is a member of another class.
270 * This is false for package members and for block-local classes.
271 */
272 public final boolean isMember() {
273 return outerClass != null && !isLocal();
274 }
275
276 /**
277 * Tell if the class is "top-level", which is either a package member,
278 * or a static member of another top-level class.
279 */
280 public final boolean isTopLevel() {
281 return outerClass == null || isStatic() || isInterface();
282 }
894 source.canAccess(env, field) &&
895 field2 != field) {
896
897 throw new AmbiguousMember(field2, field);
898 }
899 field = field2;
900 }
901 }
902 return field;
903 }
904
905 /**
906 * Tells whether to report a deprecation error for this class.
907 */
908 public boolean reportDeprecated(Environment env) {
909 return (isDeprecated()
910 || (outerClass != null && outerClass.reportDeprecated(env)));
911 }
912
913 /**
914 * Note that this class is being used somehow by <tt>ref</tt>.
915 * Report deprecation errors, etc.
916 */
917 public void noteUsedBy(ClassDefinition ref, long where, Environment env) {
918 // (Have this deal with canAccess() checks, too?)
919 if (reportDeprecated(env)) {
920 env.error(where, "warn.class.is.deprecated", this);
921 }
922 }
923
924 /**
925 * Get an inner class.
926 * Look in supers but not outers.
927 * (This is used directly to resolve expressions like "site.K", and
928 * inside a loop to resolve lone names like "K" or the "K" in "K.L".)
929 *
930 * Called from 'Context' and 'FieldExpression' as well as this class.
931 *
932 * @see FieldExpression.checkCommon
933 * @see resolveName
934 */
|
242 protected final void setOuterClass(ClassDefinition outerClass) {
243 if (this.outerClass != null) throw new CompilerError("setOuterClass");
244 this.outerClass = outerClass;
245 }
246
247 /**
248 * Set the class' enclosing current instance pointer.
249 * Must be done at most once.
250 */
251 protected final void setOuterMember(MemberDefinition outerMember) {
252
253 if (isStatic() || !isInnerClass()) throw new CompilerError("setOuterField");
254 if (this.outerMember != null) throw new CompilerError("setOuterField");
255 this.outerMember = outerMember;
256 }
257
258 /**
259 * Tell if the class is inner.
260 * This predicate also returns true for top-level nested types.
261 * To test for a true inner class as seen by the programmer,
262 * use {@code !isTopLevel()}.
263 */
264 public final boolean isInnerClass() {
265 return outerClass != null;
266 }
267
268 /**
269 * Tell if the class is a member of another class.
270 * This is false for package members and for block-local classes.
271 */
272 public final boolean isMember() {
273 return outerClass != null && !isLocal();
274 }
275
276 /**
277 * Tell if the class is "top-level", which is either a package member,
278 * or a static member of another top-level class.
279 */
280 public final boolean isTopLevel() {
281 return outerClass == null || isStatic() || isInterface();
282 }
894 source.canAccess(env, field) &&
895 field2 != field) {
896
897 throw new AmbiguousMember(field2, field);
898 }
899 field = field2;
900 }
901 }
902 return field;
903 }
904
905 /**
906 * Tells whether to report a deprecation error for this class.
907 */
908 public boolean reportDeprecated(Environment env) {
909 return (isDeprecated()
910 || (outerClass != null && outerClass.reportDeprecated(env)));
911 }
912
913 /**
914 * Note that this class is being used somehow by {@code ref}.
915 * Report deprecation errors, etc.
916 */
917 public void noteUsedBy(ClassDefinition ref, long where, Environment env) {
918 // (Have this deal with canAccess() checks, too?)
919 if (reportDeprecated(env)) {
920 env.error(where, "warn.class.is.deprecated", this);
921 }
922 }
923
924 /**
925 * Get an inner class.
926 * Look in supers but not outers.
927 * (This is used directly to resolve expressions like "site.K", and
928 * inside a loop to resolve lone names like "K" or the "K" in "K.L".)
929 *
930 * Called from 'Context' and 'FieldExpression' as well as this class.
931 *
932 * @see FieldExpression.checkCommon
933 * @see resolveName
934 */
|