src/share/classes/com/sun/tools/javac/comp/AttrContext.java

Mon, 24 Nov 2014 14:55:38 -0800

author
vromero
date
Mon, 24 Nov 2014 14:55:38 -0800
changeset 2610
f4df97bf5392
parent 2390
b06c2db45ddb
child 2525
2eb010b6cb22
child 3005
0353cf89ea96
permissions
-rw-r--r--

8059921: Missing compile error in Java 8 mode for Interface.super.field access
Reviewed-by: mcimadamore, jlahoda

duke@1 1 /*
vromero@2390 2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.javac.comp;
duke@1 27
duke@1 28 import com.sun.tools.javac.util.*;
duke@1 29 import com.sun.tools.javac.code.*;
duke@1 30
duke@1 31 /** Contains information specific to the attribute and enter
duke@1 32 * passes, to be used in place of the generic field in environments.
duke@1 33 *
jjg@581 34 * <p><b>This is NOT part of any supported API.
jjg@581 35 * If you write code that depends on this, you do so at your own risk.
duke@1 36 * This code and its internal interfaces are subject to change or
duke@1 37 * deletion without notice.</b>
duke@1 38 */
duke@1 39 public class AttrContext {
duke@1 40
duke@1 41 /** The scope of local symbols.
duke@1 42 */
duke@1 43 Scope scope = null;
duke@1 44
duke@1 45 /** The number of enclosing `static' modifiers.
duke@1 46 */
duke@1 47 int staticLevel = 0;
duke@1 48
duke@1 49 /** Is this an environment for a this(...) or super(...) call?
duke@1 50 */
duke@1 51 boolean isSelfCall = false;
duke@1 52
duke@1 53 /** Are we evaluating the selector of a `super' or type name?
duke@1 54 */
duke@1 55 boolean selectSuper = false;
duke@1 56
vromero@2390 57 /** Is the current target of lambda expression or method reference serializable?
vromero@2390 58 */
vromero@2390 59 boolean isSerializable = false;
vromero@2390 60
duke@1 61 /** Are arguments to current function applications boxed into an array for varargs?
duke@1 62 */
mcimadamore@1347 63 Resolve.MethodResolutionPhase pendingResolutionPhase = null;
duke@1 64
duke@1 65 /** A record of the lint/SuppressWarnings currently in effect
duke@1 66 */
duke@1 67 Lint lint;
duke@1 68
mcimadamore@94 69 /** The variable whose initializer is being attributed
mcimadamore@94 70 * useful for detecting self-references in variable initializers
mcimadamore@94 71 */
mcimadamore@94 72 Symbol enclVar = null;
mcimadamore@94 73
mcimadamore@1347 74 /** ResultInfo to be used for attributing 'return' statement expressions
mcimadamore@1347 75 * (set by Attr.visitMethod and Attr.visitLambda)
mcimadamore@1347 76 */
mcimadamore@1347 77 Attr.ResultInfo returnResult = null;
mcimadamore@1347 78
mcimadamore@1393 79 /** Symbol corresponding to the site of a qualified default super call
mcimadamore@1393 80 */
mcimadamore@1393 81 Type defaultSuperCallSite = null;
mcimadamore@1393 82
duke@1 83 /** Duplicate this context, replacing scope field and copying all others.
duke@1 84 */
duke@1 85 AttrContext dup(Scope scope) {
duke@1 86 AttrContext info = new AttrContext();
duke@1 87 info.scope = scope;
duke@1 88 info.staticLevel = staticLevel;
duke@1 89 info.isSelfCall = isSelfCall;
duke@1 90 info.selectSuper = selectSuper;
mcimadamore@1347 91 info.pendingResolutionPhase = pendingResolutionPhase;
duke@1 92 info.lint = lint;
mcimadamore@94 93 info.enclVar = enclVar;
mcimadamore@1347 94 info.returnResult = returnResult;
mcimadamore@1393 95 info.defaultSuperCallSite = defaultSuperCallSite;
vromero@2390 96 info.isSerializable = isSerializable;
duke@1 97 return info;
duke@1 98 }
duke@1 99
duke@1 100 /** Duplicate this context, copying all fields.
duke@1 101 */
duke@1 102 AttrContext dup() {
duke@1 103 return dup(scope);
duke@1 104 }
duke@1 105
duke@1 106 public Iterable<Symbol> getLocalElements() {
duke@1 107 if (scope == null)
duke@1 108 return List.nil();
duke@1 109 return scope.getElements();
duke@1 110 }
duke@1 111
mcimadamore@1347 112 boolean lastResolveVarargs() {
mcimadamore@1347 113 return pendingResolutionPhase != null &&
mcimadamore@1347 114 pendingResolutionPhase.isVarargsRequired();
mcimadamore@1347 115 }
mcimadamore@1347 116
jjg@1409 117 @Override
duke@1 118 public String toString() {
duke@1 119 return "AttrContext[" + scope.toString() + "]";
duke@1 120 }
duke@1 121 }

mercurial