< prev index next > src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java
Print this page
import com.sun.tools.javac.util.Log.DiscardDiagnosticHandler;
import com.sun.tools.javac.util.Log.WriterKind;
import static com.sun.tools.javac.code.Kinds.Kind.*;
- import com.sun.tools.javac.code.Lint;
- import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
import com.sun.tools.javac.resources.CompilerProperties.Errors;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.resources.CompilerProperties.Notes;
*/
class ScanNested extends TreeScanner {
Set<Env<AttrContext>> dependencies = new LinkedHashSet<>();
protected boolean hasLambdas;
protected boolean hasPatterns;
+ protected boolean hasValueClasses;
+ protected boolean hasStrictFields;
@Override
public void visitClassDef(JCClassDecl node) {
Type st = types.supertype(node.sym.type);
boolean envForSuperTypeFound = false;
while (!envForSuperTypeFound && st.hasTag(CLASS)) {
Env<AttrContext> stEnv = enter.getEnv(c);
if (stEnv != null && env != stEnv) {
if (dependencies.add(stEnv)) {
boolean prevHasLambdas = hasLambdas;
boolean prevHasPatterns = hasPatterns;
+ boolean prevHasStrictFields = hasStrictFields;
try {
scan(stEnv.tree);
} finally {
/*
* ignore any updates to hasLambdas and hasPatterns
* available only to those classes that contain
* lambdas or patterns, respectivelly
*/
hasLambdas = prevHasLambdas;
hasPatterns = prevHasPatterns;
+ hasStrictFields = prevHasStrictFields;
}
}
envForSuperTypeFound = true;
}
st = types.supertype(st);
}
+ hasValueClasses = node.sym.isValueClass();
super.visitClassDef(node);
}
@Override
public void visitLambda(JCLambda tree) {
hasLambdas = true;
@Override
public void visitSwitchExpression(JCSwitchExpression tree) {
hasPatterns |= tree.patternSwitch;
super.visitSwitchExpression(tree);
}
+
+ @Override
+ public void visitVarDef(JCVariableDecl tree) {
+ hasStrictFields |= tree.sym.isStrict();
+ super.visitVarDef(tree);
+ }
}
ScanNested scanner = new ScanNested();
scanner.scan(env.tree);
for (Env<AttrContext> dep: scanner.dependencies) {
- if (!compileStates.isDone(dep, CompileState.WARN))
- desugaredEnvs.put(dep, desugar(warn(flow(attribute(dep)))));
+ if (!compileStates.isDone(dep, CompileState.WARN))
+ desugaredEnvs.put(dep, desugar(warn(flow(attribute(dep)))));
}
//We need to check for error another time as more classes might
//have been attributed and analyzed at this stage
if (shouldStop(CompileState.TRANSTYPES))
for (JCTree def : cdefs) {
LambdaToMethod.instance(context).translateTopLevelClass(env, def, localMake);
}
compileStates.put(env, CompileState.UNLAMBDA);
}
+
+ if (scanner.hasValueClasses || scanner.hasStrictFields) {
+ if (shouldStop(CompileState.STRICT_FIELDS_PROXIES))
+ return;
+ for (JCTree def : cdefs) {
+ LocalProxyVarsGen.instance(context).translateTopLevelClass(def, localMake);
+ }
+ compileStates.put(env, CompileState.STRICT_FIELDS_PROXIES);
+ }
//generate code for each class
for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
JCClassDecl cdef = (JCClassDecl)l.head;
results.add(new Pair<>(env, cdef));
< prev index next >