97
97
import com .sun .tools .javac .tree .JCTree .LetExpr ;
98
98
import com .sun .tools .javac .tree .TreeInfo ;
99
99
import com .sun .tools .javac .util .Assert ;
100
+ import com .sun .tools .javac .util .JCDiagnostic .DiagnosticPosition ;
100
101
import com .sun .tools .javac .util .List ;
101
102
102
103
/**
@@ -284,7 +285,7 @@ public void visitRecordPattern(JCRecordPattern tree) {
284
285
names .fromString (target .syntheticNameChar () + "c" + target .syntheticNameChar () + component .name ),
285
286
component .erasure (types ),
286
287
currentMethodSym );
287
- Symbol accessor = getAccessor (component );
288
+ Symbol accessor = getAccessor (tree . pos (), component );
288
289
JCVariableDecl nestedTempVar =
289
290
make .VarDef (nestedTemp ,
290
291
make .App (make .QualIdent (accessor ),
@@ -344,12 +345,8 @@ public void visitRecordPattern(JCRecordPattern tree) {
344
345
result = test != null ? test : makeLit (syms .booleanType , 1 );
345
346
}
346
347
347
- private MethodSymbol getAccessor (RecordComponent component ) {
348
+ private MethodSymbol getAccessor (DiagnosticPosition pos , RecordComponent component ) {
348
349
return component2Proxy .computeIfAbsent (component , c -> {
349
- MethodSymbol realAccessor = (MethodSymbol ) component .owner
350
- .members ()
351
- .findFirst (component .name , s -> s .kind == Kind .MTH &&
352
- ((MethodSymbol ) s ).params .isEmpty ());
353
350
MethodType type = new MethodType (List .of (component .owner .erasure (types )),
354
351
types .erasure (component .type ),
355
352
List .nil (),
@@ -359,7 +356,7 @@ private MethodSymbol getAccessor(RecordComponent component) {
359
356
type ,
360
357
currentClass );
361
358
JCStatement accessorStatement =
362
- make .Return (make .App (make .Select (make .Ident (proxy .params ().head ), realAccessor )));
359
+ make .Return (make .App (make .Select (make .Ident (proxy .params ().head ), c . accessor )));
363
360
VarSymbol ctch = new VarSymbol (Flags .SYNTHETIC ,
364
361
names .fromString ("catch" + currentClassTree .pos + target .syntheticNameChar ()),
365
362
syms .throwableType ,
0 commit comments