aspect InlineMethodAccess { public AnonymousMethod MethodAccess.inlineToAnonymousMethod() { expatiateQualifiers(); MethodDecl target = getUniqueTarget(); if(target == null) throw new RefactoringException("cannot inline ambiguous method call"); if(!target.hasBlock() || !target.fromSource()) throw new RefactoringException("cannot inline call to method without body"); MethodDecl target_cp = (MethodDecl) target.fullCopyAndDetach(); target.unfoldSynchronized(); target.expatiateQualifiers(); target.lockAllNames(); AnonymousMethod anon; bundleQualifier(); if(isRightChildOfDot()) { Expr qual = qualifier(); if(qual.isSuperAccess()) { TypeDecl sup = qual.type(); // construct typeUpdate map Map typeUpdate = new HashMap(); for(ThisAccess acc : target.collectThisAccesses()) { if(acc.isQualified()) { if(acc.type() == sup) acc.unqualify(); else throw new RefactoringException("cannot preserve enclosing instances"); } typeUpdate.put(acc, hostType()); } Program.adjustVirtualCalls(typeUpdate); anon = target.asAnonymousMethod(); } else if(decl().hostType() != this.hostType()) { qual.lockAllNames(); anon = target.asAnonymousMethod(); anon.setBlock(new Block(new List().add(new WithStmt((Access)qual, anon.getBlock())))); } else { anon = target.asAnonymousMethod(); } parentDot().replaceWith(anon); } else { anon = target.asAnonymousMethod(); replaceWith(anon); } target.replaceWith(target_cp); anon.setArgList(getArgList()); anon.removeSyntheticThis(); target_cp.hostType().flushCaches(); return anon; } // make implicit "this" qualifiers explicit public void ASTNode.expatiateQualifiers() { for(int i=0;i