langtools/src/share/classes/com/sun/tools/javac/comp/Env.java
changeset 10950 e87b50888909
parent 5847 1908176fd6e3
child 14541 36f9d11fc9aa
equal deleted inserted replaced
10949:42f7cc0468dd 10950:e87b50888909
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 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.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   114         return dup(tree, this.info);
   114         return dup(tree, this.info);
   115     }
   115     }
   116 
   116 
   117     /** Return closest enclosing environment which points to a tree with given tag.
   117     /** Return closest enclosing environment which points to a tree with given tag.
   118      */
   118      */
   119     public Env<A> enclosing(int tag) {
   119     public Env<A> enclosing(JCTree.Tag tag) {
   120         Env<A> env1 = this;
   120         Env<A> env1 = this;
   121         while (env1 != null && env1.tree.getTag() != tag) env1 = env1.next;
   121         while (env1 != null && !env1.tree.hasTag(tag)) env1 = env1.next;
   122         return env1;
   122         return env1;
   123     }
   123     }
   124 
   124 
   125     public String toString() {
   125     public String toString() {
   126         return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]";
   126         return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]";