homberghp opened a new issue, #8375:
URL: https://github.com/apache/netbeans/issues/8375

   ### Apache NetBeans version
   
   Apache NetBeans 25
   
   ### What happened
   
   In the following code, the method defined inside the inner record is not 
pulled up with its enclosing record.
   
   ```
   /*
    * Click 
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change 
this license
    * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit 
this template
    */
   package recordast;
   
   import java.io.Serializable;
   import java.time.LocalDate;
   import java.util.Arrays;
   import java.util.Objects;
   
   /**
    *
    * @author homberghp (Pieter van den Hombergh) {@code <your.name at 
your.org>}
    */
   class School extends Institute {
   
       Student[] students;
       Employee[] teachers;
   
       School(Student... students) {
           assert students != null;
           this.students = students;
       }
   
       record Teacher(String name, String... topics) implements Serializable, 
Cloneable {
   
       }
   
       record Student(int id, String name, LocalDate dob, String... grades) 
implements Serializable {
   
           Student    {
               // ensure valid id
               assert id > 0;
               assert name != null && !name.isBlank();
               assert dob.isAfter(LocalDate.EPOCH);
           }
   
           String gradesAsString() {
               return Arrays.toString(grades);
           }
       }
   
       class Employee<R> implements Serializable {
   
           private final int id;
           private final String name;
           private final LocalDate dob;
   
           Employee(int id, String name, LocalDate dob, R role) {
               assert id > 0;
               assert name != null;
               assert dob.isAfter(LocalDate.EPOCH);
               this.id = id;
               this.name = name;
               this.dob = dob;
           }
   
           @Override
           public int hashCode() {
               int hash = 7;
               hash = 71 * hash + this.id;
               hash = 71 * hash + Objects.hashCode(this.name);
               hash = 71 * hash + Objects.hashCode(this.dob);
               return hash;
           }
   
           @Override
           public boolean equals(Object obj) {
               if (this == obj) {
                   return true;
               }
               if (obj == null) {
                   return false;
               }
               if (getClass() != obj.getClass()) {
                   return false;
               }
               final Employee other = (Employee) obj;
               if (this.id != other.id) {
                   return false;
               }
               if (!Objects.equals(this.name, other.name)) {
                   return false;
               }
               return Objects.equals(this.dob, other.dob);
           }
   
           @Override
           public String toString() {
               return "Employee{" + "id=" + id + ", name=" + name + ", dob=" + 
dob + '}';
           }
   
       }
   
       public static void main(String[] args) {
           Student jan = new Student(123, "Jan", LocalDate.now(), "A", "D+");
           School s = new School(jan);
           System.out.println("s = " + s);
           System.out.println("jan = " + jan + "grades" + jan.gradesAsString());
       }
   }
   ```
   and 
   ```
   class Institute {
       
   }
   ```
   The problem may ly in the improper handling of the compact constructor, 
which may not contain a super
   call.
   
   
   ### Language / Project Type / NetBeans Component
   
   java refactoring (java/refactoring.java)
   
   ### How to reproduce
   
   Try pull up e.g. Student member to super class Institute.
   
   The compact constructor is miss formed.
   
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   linux ubuntu 24.04 LTS
   
   ### JDK
   
   jdk 17 (the build platform for netbeans 25)
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### Anything else
   
   The problem occurs consistently.
   I found the error while extending the tests on PR .... 
   The test is on my branch issue7044a in my repo homberghp/netbeans.
   
   If hope to work on a solution, because I may be the culprit.
   
   
   ### Are you willing to submit a pull request?
   
   Yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to