@@ -2388,11 +2388,14 @@ public void visitAttributeExpression(AttributeExpression attr) {
23882388 queue .add (insideParentheses (attr , fmt -> {
23892389 Expression target = doVisit (attr .getObjectExpression ());
23902390 Space beforeDot = attr .isSafe () ? sourceBefore ("?." ) : sourceBefore (attr .isSpreadSafe () ? "*." : "." );
2391+ int saveCursor = cursor ;
23912392 J name = doVisit (attr .getProperty ());
23922393 if (name instanceof J .Literal ) {
23932394 String nameStr = ((J .Literal ) name ).getValueSource ();
23942395 assert nameStr != null ;
23952396 name = new J .Identifier (randomId (), name .getPrefix (), Markers .EMPTY , emptyList (), nameStr , null , null );
2397+ } else if (name instanceof G .GString ) {
2398+ name = gStringAsIdentifier ((G .GString ) name , saveCursor );
23962399 }
23972400 if (attr .isSpreadSafe ()) {
23982401 name = name .withMarkers (name .getMarkers ().add (new StarDot (randomId ())));
@@ -2409,10 +2412,13 @@ public void visitPropertyExpression(PropertyExpression prop) {
24092412 queue .add (insideParentheses (prop , fmt -> {
24102413 Expression target = doVisit (prop .getObjectExpression ());
24112414 Space beforeDot = prop .isSpreadSafe () ? sourceBefore ("*." ) : sourceBefore (prop .isSafe () ? "?." : "." );
2415+ int saveCursor = cursor ;
24122416 J name = doVisit (prop .getProperty ());
24132417 if (name instanceof J .Literal ) {
24142418 J .Literal nameLiteral = ((J .Literal ) name );
24152419 name = new J .Identifier (randomId (), name .getPrefix (), Markers .EMPTY , emptyList (), nameLiteral .getValueSource (), nameLiteral .getType (), null );
2420+ } else if (name instanceof G .GString ) {
2421+ name = gStringAsIdentifier ((G .GString ) name , saveCursor );
24162422 }
24172423 if (prop .isSpreadSafe ()) {
24182424 name = name .withMarkers (name .getMarkers ().add (new StarDot (randomId ())));
@@ -2423,6 +2429,12 @@ public void visitPropertyExpression(PropertyExpression prop) {
24232429 }));
24242430 }
24252431
2432+ private J .Identifier gStringAsIdentifier (G .GString gString , int saveCursor ) {
2433+ int gStringStart = indexOfNextNonWhitespace (saveCursor , source );
2434+ String text = source .substring (gStringStart , cursor );
2435+ return new J .Identifier (randomId (), gString .getPrefix (), Markers .EMPTY , emptyList (), text , gString .getType (), null );
2436+ }
2437+
24262438 @ Override
24272439 public void visitRangeExpression (RangeExpression range ) {
24282440 queue .add (insideParentheses (range , fmt -> new G .Range (randomId (), fmt , Markers .EMPTY ,
0 commit comments