-
Notifications
You must be signed in to change notification settings - Fork 53
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
Incorrectly removing Kotlin members #571
Comments
It appears to be happening for private var hitCount = 0 @Synchronized fun hitCount(): Int = hitCount |
Also happens with setXxx methods: fun setType(type: MediaType) = apply { private var type = MIXED |
Fixes: #571 Don't mark `public` Kotlin methods as `private` if they "shadow" -- share the same name as -- a private property or field. If a library uses Kotlin's `NAME_SHADOWING` we incorrectly match the `private` property/field to the `public` method and mark the methods as `private`. Given Kotlin: @Suppress("NAME_SHADOWING") public class NameShadowing { // Property and method private val count: Int = 3 fun count(): Int = count // Field and method private var hitCount = 0 fun hitCount(): Int = hitCount // Property and setter private var type = 0 fun setType(type: Int) = { println (type); } } Then the public methods `NameShadowing.count()`, `NameShadowing.hitCount()`, and `NameShadowing.setType()` were not present within the C# binding. Support name shadowing by only considering `getFoo()` methods as potential property getters, instead of allowing `foo`. (Allowing `foo` was likely incorrect anyways.) Additionally, when considering if a method is a potential property setter, also check that the method's return type is `void`. [Xamarin.Android.Tools.Bytecode] Kotlin name shadowing support (#573)
Fixes: #571 Don't mark `public` Kotlin methods as `private` if they "shadow" -- share the same name as -- a private property or field. If a library uses Kotlin's `NAME_SHADOWING` we incorrectly match the `private` property/field to the `public` method and mark the methods as `private`. Given Kotlin: @Suppress("NAME_SHADOWING") public class NameShadowing { // Property and method private val count: Int = 3 fun count(): Int = count // Field and method private var hitCount = 0 fun hitCount(): Int = hitCount // Property and setter private var type = 0 fun setType(type: Int) = { println (type); } } Then the public methods `NameShadowing.count()`, `NameShadowing.hitCount()`, and `NameShadowing.setType()` were not present within the C# binding. Support name shadowing by only considering `getFoo()` methods as potential property getters, instead of allowing `foo`. (Allowing `foo` was likely incorrect anyways.) Additionally, when considering if a method is a potential property setter, also check that the method's return type is `void`. [Xamarin.Android.Tools.Bytecode] Kotlin name shadowing support (#573)
Release status update A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this again when a Release version is available that includes the fix. Fix included in Xamarin.Android 10.2.100.7 and 10.3.0.33. Fix included on Windows in Visual Studio 2019 version 16.6 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.) Fix included on macOS in Visual Studio 2019 for Mac version 8.6 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel. |
Release status update A new Release version of Xamarin.Android has now been published that includes the fix for this item. Fix included in Xamarin.Android 10.3.1.0. Fix included on Windows in Visual Studio 2019 version 16.6. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/. Fix included on macOS in Visual Studio 2019 for Mac version 8.6. To get the new version that includes the fix, check for the latest updates on the Stable updater channel. |
Not sure of exactly why, but a member is being removed. It might have to do with the fact that there is a property and a method with the same name...
Message:
Property:
https://github.com/square/okhttp/blob/parent-4.2.2/okhttp/src/main/java/okhttp3/MultipartBody.kt#L38
Method:
https://github.com/square/okhttp/blob/parent-4.2.2/okhttp/src/main/java/okhttp3/MultipartBody.kt#L51
Binlog:
msbuild.zip
Project:
Square.OkHttp3.zip
The text was updated successfully, but these errors were encountered: