# HG changeset patch # Parent aaec84f8c400342378151488cb984ee46637596d 8234445: spurious error message for record constructors with receiver parameters diff -r aaec84f8c400 -r 09b722a8f293 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Tue Dec 17 14:11:26 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Tue Dec 17 15:14:41 2019 -0500 @@ -902,6 +902,19 @@ for (JCVariableDecl field : fields) { sym.getRecordComponent(field.sym, true); } + + // enter symbols for 'this' into current scope. + VarSymbol thisSym = + new VarSymbol(FINAL | HASINIT, names._this, sym.type, sym); + thisSym.pos = Position.FIRSTPOS; + env.info.scope.enter(thisSym); + + VarSymbol superSym = + new VarSymbol(FINAL | HASINIT, names._super, + syms.recordType, sym); + superSym.pos = Position.FIRSTPOS; + env.info.scope.enter(superSym); + // lets enter all constructors for (JCTree def : tree.defs) { if (TreeInfo.isConstructor(def)) { @@ -932,19 +945,21 @@ JCTree constrDef = defaultConstructor(make.at(tree.pos), helper); tree.defs = tree.defs.prepend(constrDef); } - // enter symbols for 'this' into current scope. - VarSymbol thisSym = - new VarSymbol(FINAL | HASINIT, names._this, sym.type, sym); - thisSym.pos = Position.FIRSTPOS; - env.info.scope.enter(thisSym); - // if this is a class, enter symbol for 'super' into current scope. - if ((sym.flags_field & INTERFACE) == 0 && - ct.supertype_field.hasTag(CLASS)) { - VarSymbol superSym = - new VarSymbol(FINAL | HASINIT, names._super, - ct.supertype_field, sym); - superSym.pos = Position.FIRSTPOS; - env.info.scope.enter(superSym); + if (!sym.isRecord()) { + // enter symbols for 'this' into current scope. + VarSymbol thisSym = + new VarSymbol(FINAL | HASINIT, names._this, sym.type, sym); + thisSym.pos = Position.FIRSTPOS; + env.info.scope.enter(thisSym); + // if this is a class, enter symbol for 'super' into current scope. + if ((sym.flags_field & INTERFACE) == 0 && + ct.supertype_field.hasTag(CLASS)) { + VarSymbol superSym = + new VarSymbol(FINAL | HASINIT, names._super, + ct.supertype_field, sym); + superSym.pos = Position.FIRSTPOS; + env.info.scope.enter(superSym); + } } if (!tree.typarams.isEmpty()) {