svoid tok_selfType(L tok) { int i; mainLoop: while ((i = jfind(tok, "selfType", (_tok, nIdx) -> { S next = get(_tok, nIdx+3); ret isIdentifier(next) || eq(next, "."); }) >= 0) { // Now find class name by going backwards. int j = i, level = 1; while (j > 0 && level > 0) { S t = tok.get(j); if (t.equals("}")) ++level; if (t.equals("{")) --level; j -= 2; } // search for class name while (j > 0) { S t = tok.get(j); if (eqOneOf(t, "class", "interface")) { S type = tok_typeArgs_declToInvocation(tok_scanType(tok, j+2)); tokSet_reTok(tok, i, type); continue mainLoop; } j -= 2; } tok.set(i, "Object"); // avoid endless loop if no outer class found } }