@@ -2390,11 +2390,14 @@ public void visitAttributeExpression(AttributeExpression attr) {
23902390 queue .add (insideParentheses (attr , fmt -> {
23912391 Expression target = doVisit (attr .getObjectExpression ());
23922392 Space beforeDot = attr .isSafe () ? sourceBefore ("?." ) : sourceBefore (attr .isSpreadSafe () ? "*." : "." );
2393+ int saveCursor = cursor ;
23932394 J name = doVisit (attr .getProperty ());
23942395 if (name instanceof J .Literal ) {
23952396 String nameStr = ((J .Literal ) name ).getValueSource ();
23962397 assert nameStr != null ;
23972398 name = new J .Identifier (randomId (), name .getPrefix (), Markers .EMPTY , emptyList (), nameStr , null , null );
2399+ } else if (name instanceof G .GString ) {
2400+ name = gStringAsIdentifier ((G .GString ) name , saveCursor );
23982401 }
23992402 if (attr .isSpreadSafe ()) {
24002403 name = name .withMarkers (name .getMarkers ().add (new StarDot (randomId ())));
@@ -2411,10 +2414,13 @@ public void visitPropertyExpression(PropertyExpression prop) {
24112414 queue .add (insideParentheses (prop , fmt -> {
24122415 Expression target = doVisit (prop .getObjectExpression ());
24132416 Space beforeDot = prop .isSpreadSafe () ? sourceBefore ("*." ) : sourceBefore (prop .isSafe () ? "?." : "." );
2417+ int saveCursor = cursor ;
24142418 J name = doVisit (prop .getProperty ());
24152419 if (name instanceof J .Literal ) {
24162420 J .Literal nameLiteral = ((J .Literal ) name );
24172421 name = new J .Identifier (randomId (), name .getPrefix (), Markers .EMPTY , emptyList (), nameLiteral .getValueSource (), nameLiteral .getType (), null );
2422+ } else if (name instanceof G .GString ) {
2423+ name = gStringAsIdentifier ((G .GString ) name , saveCursor );
24182424 }
24192425 if (prop .isSpreadSafe ()) {
24202426 name = name .withMarkers (name .getMarkers ().add (new StarDot (randomId ())));
@@ -2425,6 +2431,12 @@ public void visitPropertyExpression(PropertyExpression prop) {
24252431 }));
24262432 }
24272433
2434+ private J .Identifier gStringAsIdentifier (G .GString gString , int saveCursor ) {
2435+ int gStringStart = indexOfNextNonWhitespace (saveCursor , source );
2436+ String text = source .substring (gStringStart , cursor );
2437+ return new J .Identifier (randomId (), gString .getPrefix (), Markers .EMPTY , emptyList (), text , gString .getType (), null );
2438+ }
2439+
24282440 @ Override
24292441 public void visitRangeExpression (RangeExpression range ) {
24302442 queue .add (insideParentheses (range , fmt -> new G .Range (randomId (), fmt , Markers .EMPTY ,
0 commit comments