Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent name clashes between a function in class and a function call in current scope. #1850

Merged
merged 3 commits into from
Mar 4, 2024

Conversation

ivk1800
Copy link
Contributor

@ivk1800 ivk1800 commented Mar 3, 2024

This pull request aims to fix clashes name between a function in class and a function call. We have below generate code, which contains function in class and call another function with same name.

Actual:

      package com.squareup.tacos
      
      import com.squareup.Fridge.meat
      
      public class DeliciousTaco {
        public fun build(): Taco = Taco(deliciousMeat = meat { })
      
        public fun deliciousMeat() {
        }
      }
      
      public class TastelessTaco {
        public fun build(): Taco = Taco(meat = meat { }) // <----
      
        public fun meat() { // <----
        }
      }
      

Expected:

      package com.squareup.tacos
      
      import com.squareup.Fridge.meat
      
      public class DeliciousTaco {
        public fun build(): Taco = Taco(deliciousMeat = meat { })
      
        public fun deliciousMeat() {
        }
      }
      
      public class TastelessTaco {
        public fun build(): Taco = Taco(meat = com.squareup.Fridge.meat { }) // <----
      
        public fun meat() { // <----
        }
      }
      

@ivk1800 ivk1800 changed the title Prevent name clashes between an function in class and a function call in current scope. Prevent name clashes between a function in class and a function call in current scope. Mar 3, 2024
@Egorand
Copy link
Collaborator

Egorand commented Mar 4, 2024

Thanks @ivk1800! Please sign our CLA so that we can merge the PR.

@ivk1800
Copy link
Contributor Author

ivk1800 commented Mar 4, 2024

Thanks @ivk1800! Please sign our CLA so that we can merge the PR.

done

@Egorand Egorand merged commit c9c94cf into square:main Mar 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants