Skip to content

Disambiguate owners of fields in output #6699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9dc4e4d
Start of implementation of `JavaExpression.SuperReference`
jyoo980 May 20, 2024
374c0ec
Merge branch 'master' into yoo/implement-super-javaexpresssion
jyoo980 May 20, 2024
ee6469c
Make one test pass
jyoo980 May 20, 2024
60ce998
Merge branch 'master' into yoo/implement-super-javaexpresssion
jyoo980 May 21, 2024
feb2dd5
Add start of impl. for `JavaExpressionVisitor.visitSuperReference`
jyoo980 May 22, 2024
6347006
Merge branch 'master' into yoo/implement-super-javaexpresssion
jyoo980 May 22, 2024
e21390f
Move code to addComputedTypeAnnotations.
smillst May 22, 2024
089f087
Merge remote-tracking branch 'typetools/master' into yoo/implement-su…
jyoo980 May 22, 2024
4f57db4
When verbose, always output resultValue
mernst May 22, 2024
f72bb0e
Merge remote-tracking branch 'smillst/optional-addComput' into yoo/im…
jyoo980 May 22, 2024
5db0a36
Merge ../checker-framework-fork-mernst-branch-viz-resultValue into yo…
mernst May 22, 2024
719dfd0
Merge branch 'yoo/implement-super-javaexpresssion' of github.com:jyoo…
jyoo980 May 22, 2024
dbc778c
Test
mernst May 22, 2024
7675d61
Change stub -> todo
jyoo980 May 22, 2024
453fecd
Merge branch 'yoo/implement-super-javaexpresssion' of github.com:jyoo…
jyoo980 May 22, 2024
aa9093d
Implement `JavaExpressionConverter#visitSuperReference`
jyoo980 May 22, 2024
6e4af74
Fix typo
mernst May 22, 2024
bc4c314
Merge branch 'yoo/implement-super-javaexpresssion' of github.com:jyoo…
mernst May 22, 2024
b7009f0
Merge branch 'master' into yoo/implement-super-javaexpresssion
jyoo980 May 22, 2024
46a928e
Merge branch 'master' into yoo/implement-super-javaexpresssion
jyoo980 May 23, 2024
d072c0b
Merge ../checker-framework-branch-master into yoo-implement-super-jav…
mernst May 23, 2024
9d167c4
Merge ../checker-framework-branch-master into yoo-implement-super-jav…
mernst May 26, 2024
f062d7f
Work around type-checking
mernst May 26, 2024
ccc2b1a
Checkpoint
mernst May 30, 2024
ddf3694
Fix HTML
mernst Jun 3, 2024
95d9711
Merge ../checker-framework-branch-master into yoo-implement-super-jav…
mernst Jun 3, 2024
a239b1d
Merge ../checker-framework-branch-master into yoo-implement-super-jav…
mernst Jun 7, 2024
253382b
Undo a change
mernst Jun 7, 2024
979782c
Merge ../checker-framework-branch-master into yoo-implement-super-jav…
mernst Jul 7, 2024
52ec1da
Make `disambiguateOwner` a field
mernst Jul 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {

@Override
public String toString() {
return "this";
if (Node.disambiguateOwner) {
return "this{owner=" + type + "}";
} else {
return "this";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.MemberSelectTree;
import com.sun.source.tree.Tree;
import com.sun.tools.javac.code.Symbol;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
Expand Down Expand Up @@ -91,7 +92,11 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {

@Override
public String toString() {
return getReceiver() + "." + field;
if (Node.disambiguateOwner) {
return getReceiver() + "." + field + "{owner=" + ((Symbol) element).owner + "}";
} else {
return getReceiver() + "." + field;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {
// used in an inner class context.
@Override
public String toString() {
return "(this)";
if (Node.disambiguateOwner) {
return "(this{owner=" + type + "})";
} else {
return "(this)";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
*/
public abstract class Node implements UniqueId {

/**
* If true, print the owner of each field and {@code this}, to disambiguate shadowing. This field
* is intended for debugging.
*/
public static final boolean disambiguateOwner = false;

/**
* The basic block this node belongs to. If null, this object represents a method formal
* parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* <pre>
* <em>super</em>
* </pre>
*
* Its {@link #type} field is the type of the class in which "super" appears, <em>not</em> the type
* to which the "super" identifier resolves.
*/
public class SuperNode extends Node {

Expand All @@ -36,7 +39,11 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {

@Override
public String toString() {
return "super";
if (Node.disambiguateOwner) {
return "super{owner=" + type + "}";
} else {
return "super";
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.analysis.Store;
import org.checkerframework.dataflow.cfg.node.FieldAccessNode;
import org.checkerframework.dataflow.cfg.node.Node;
import org.checkerframework.javacutil.AnnotationProvider;
import org.checkerframework.javacutil.BugInCF;
import org.checkerframework.javacutil.ElementUtils;
Expand Down Expand Up @@ -139,8 +140,10 @@ public boolean containsModifiableAliasOf(Store<?> store, JavaExpression other) {

@Override
public String toString() {
if (receiver instanceof ClassName) {
return receiver.getType() + "." + field;
String receiverString =
(receiver instanceof ClassName) ? receiver.getType().toString() : receiver.toString();
if (Node.disambiguateOwner) {
return receiverString + "." + field + "{owner=" + ((Symbol) field).owner + "}";
} else {
return receiver + "." + field;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import javax.lang.model.type.TypeMirror;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.analysis.Store;
import org.checkerframework.dataflow.cfg.node.Node;
import org.checkerframework.javacutil.AnnotationProvider;
import org.checkerframework.javacutil.TypesUtils;

Expand All @@ -29,7 +30,11 @@ public int hashCode() {

@Override
public String toString() {
return "this";
if (Node.disambiguateOwner) {
return "this{" + type + "}";
} else {
return "this";
}
}

@SuppressWarnings("unchecked") // generic cast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static JavaExpression viewpointAdapt(
/** List of arguments used to replace occurrences {@link FormalParameter}s. */
private final @Nullable List<JavaExpression> args;

/** The expression to replace occurrences of {@link ThisReference}s. */
/** The expression to replace occurrences of {@link ThisReference}. */
private final @Nullable JavaExpression thisReference;

// Instance methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,9 @@ public static boolean isLocalVariable(Tree tree) {
* Returns the type as a TypeMirror of {@code tree}. To obtain {@code tree}'s AnnotatedTypeMirror,
* call {@code AnnotatedTypeFactory.getAnnotatedType()}.
*
* <p>Note that for the expression "super", this method returns the type of "this", not "this"'s
* superclass.
*
* @return the type as a TypeMirror of {@code tree}
*/
public static TypeMirror typeOf(Tree tree) {
Expand Down