Skip to content
Permalink
Browse files
8272618: Unnecessary Attr.visitIdent.noOuterThisPath
Reviewed-by: vromero
  • Loading branch information
Jan Lahoda committed Sep 1, 2021
1 parent 2fce7cb commit e600fe1a1a57d7e4060b3a1b9a8ecdb65664a506
Showing 1 changed file with 3 additions and 11 deletions.
@@ -4186,15 +4186,9 @@ public void visitIdent(JCIdent tree) {
}
tree.sym = sym;

// (1) Also find the environment current for the class where
// sym is defined (`symEnv').
// Only for pre-tiger versions (1.4 and earlier):
// (2) Also determine whether we access symbol out of an anonymous
// class in a this or super call. This is illegal for instance
// members since such classes don't carry a this$n link.
// (`noOuterThisPath').
// Also find the environment current for the class where
// sym is defined (`symEnv').
Env<AttrContext> symEnv = env;
boolean noOuterThisPath = false;
if (env.enclClass.sym.owner.kind != PCK && // we are in an inner class
sym.kind.matches(KindSelector.VAL_MTH) &&
sym.owner.kind == TYP &&
@@ -4203,8 +4197,6 @@ public void visitIdent(JCIdent tree) {
// Find environment in which identifier is defined.
while (symEnv.outer != null &&
!sym.isMemberOf(symEnv.enclClass.sym, types)) {
if ((symEnv.enclClass.sym.flags() & NOOUTERTHIS) != 0)
noOuterThisPath = false;
symEnv = symEnv.outer;
}
}
@@ -4226,7 +4218,7 @@ public void visitIdent(JCIdent tree) {
// In a constructor body,
// if symbol is a field or instance method, check that it is
// not accessed before the supertype constructor is called.
if ((symEnv.info.isSelfCall || noOuterThisPath) &&
if (symEnv.info.isSelfCall &&
sym.kind.matches(KindSelector.VAL_MTH) &&
sym.owner.kind == TYP &&
(sym.flags() & STATIC) == 0) {

1 comment on commit e600fe1

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on e600fe1 Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.