Skip to content

Commit

Permalink
More unused code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcimadamore committed Jun 13, 2024
1 parent 1f07957 commit ea0943d
Showing 1 changed file with 6 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,6 @@ public void visitLambda(JCLambda tree) {
syntheticInits.append(captured_local);
}
}
// add captured outer this instances (used only when `this' capture itself is illegal)
for (Symbol fv : localContext.getSymbolMap(CAPTURED_OUTER_THIS).keySet()) {
JCExpression captured_local = make.QualThis(fv.type);
syntheticInits.append(captured_local);
}

//then, determine the arguments to the indy call
List<JCExpression> indy_args = translate(syntheticInits.toList(), localContext.prev);
Expand Down Expand Up @@ -1462,11 +1457,6 @@ class LambdaTranslationContext extends TranslationContext<JCLambda> {

List<JCVariableDecl> syntheticParams;

/**
* to prevent recursion, track local classes processed
*/
final Set<Symbol> freeVarProcessedLocalClasses;

/**
* For method references converted to lambdas. The method
* reference receiver expression. Must be treated like a captured
Expand Down Expand Up @@ -1504,13 +1494,10 @@ public MethodSymbol originalEnclosingMethod() {
}
translatedSymbols = new EnumMap<>(LambdaSymbolKind.class);

translatedSymbols.put(PARAM, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<Symbol, Symbol>());
translatedSymbols.put(CAPTURED_OUTER_THIS, new LinkedHashMap<Symbol, Symbol>());

freeVarProcessedLocalClasses = new HashSet<>();
translatedSymbols.put(PARAM, new LinkedHashMap<>());
translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<>());
translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<>());
translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<>());
}

/**
Expand Down Expand Up @@ -1610,16 +1597,6 @@ public Symbol baseSymbol() {
}
};
break;
case CAPTURED_OUTER_THIS:
Name name = names.fromString(sym.flatName().toString().replace('.', '$') + names.dollarThis);
ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) {
@Override
public Symbol baseSymbol() {
//keep mapping with original captured symbol
return sym;
}
};
break;
case LOCAL_VAR:
ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym) {
@Override
Expand Down Expand Up @@ -1681,20 +1658,6 @@ JCTree translate(JCIdent lambdaIdent) {
return t;
}
break;
case CAPTURED_OUTER_THIS:
Optional<Symbol> proxy = m.keySet().stream()
.filter(out -> lambdaIdent.sym.isMemberOf(out.type.tsym, types))
.reduce((a, b) -> a.isEnclosedBy((ClassSymbol)b) ? a : b);
if (proxy.isPresent()) {
// Transform outer instance variable references anchoring them to the captured synthetic.
Symbol tSym = m.get(proxy.get());
JCExpression t = make.Ident(tSym).setType(lambdaIdent.sym.owner.type);
t = make.Select(t, lambdaIdent.name);
t.setType(lambdaIdent.type);
TreeInfo.setSymbol(t, lambdaIdent.sym);
return t;
}
break;
}
}
return null;
Expand Down Expand Up @@ -1737,10 +1700,6 @@ void complete() {
params.append(make.VarDef((VarSymbol) thisSym, null));
parameterSymbols.append((VarSymbol) thisSym);
}
for (Symbol thisSym : getSymbolMap(CAPTURED_OUTER_THIS).values()) {
params.append(make.VarDef((VarSymbol) thisSym, null));
parameterSymbols.append((VarSymbol) thisSym);
}
for (Symbol thisSym : getSymbolMap(PARAM).values()) {
params.append(make.VarDef((VarSymbol) thisSym, null));
parameterSymbols.append((VarSymbol) thisSym);
Expand All @@ -1766,18 +1725,12 @@ Type generatedLambdaSig() {
}

/**
* This class retains all the useful information about a method reference;
* the contents of this class are filled by the LambdaAnalyzer visitor,
* and the used by the main translation routines in order to adjust method
* references (i.e. in case a bridge is needed)
* Simple subclass modelling the translation context of a method reference.
*/
final class ReferenceTranslationContext extends TranslationContext<JCMemberReference> {

final boolean isSuper;

ReferenceTranslationContext(JCMemberReference tree) {
super(tree);
this.isSuper = tree.hasKind(ReferenceKind.SUPER);
}
}
}
Expand All @@ -1791,14 +1744,12 @@ enum LambdaSymbolKind {
PARAM, // original to translated lambda parameters
LOCAL_VAR, // original to translated lambda locals
CAPTURED_VAR, // variables in enclosing scope to translated synthetic parameters
CAPTURED_THIS, // class symbols to translated synthetic parameters (for captured member access)
CAPTURED_OUTER_THIS; // used when `this' capture is illegal, but outer this capture is legit (JDK-8129740)
CAPTURED_THIS; // class symbols to translated synthetic parameters (for captured member access)

boolean propagateAnnotations() {
switch (this) {
case CAPTURED_VAR:
case CAPTURED_THIS:
case CAPTURED_OUTER_THIS:
return false;
default:
return true;
Expand Down

0 comments on commit ea0943d

Please sign in to comment.