Skip to content

Recipe InlineVariable and Enum array results in non compilable code #9

@jbessels

Description

@jbessels

I have the following public enum ImportType. With the following method

 public static ImportType[] getList() {
   	ImportType[] list = {ImportType.TIMETABLE, ImportType.DUTIES};
   	return list;
   }

org.openrewrite.java.cleanup.InlineVariable translates this to

public static ImportType[] getList() {
    	return {ImportType.TIMETABLE, ImportType.DUTIES};
    }

This does no longer compile. Correct code suggested by IntelliJ

 public static ImportType[] getList() {
    	return new ImportType[]{ImportType.TIMETABLE, ImportType.DUTIES};
    }

I hope this is enough to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions