Commit b4c2a67
[Xamarin.Android.Tools.Bytecode] Hide Kotlin synthetic constructors (#700)
Fixes: #694
Context: dotnet/android#3776
When using a Kotlin default constructor like:
class MaterialDialog(
val windowContext: Context,
val dialogBehavior: DialogBehavior = DEFAULT_BEHAVIOR
) : Dialog(windowContext, inferTheme(windowContext, dialogBehavior))
{ ... }
Kotlin will create 2 constructors, the "real" one, and a synthetic one
denoting which constructor is the default constructor using a
`kotlin.jvm.internal.DefaultConstructorMarker` parameter:
<constructor deprecated="not deprecated" final="false"
name="MaterialDialog" static="false" visibility="public"
bridge="false" synthetic="false"
jni-signature="(Landroid/content/Context;Lcom/afollestad/materialdialogs/DialogBehavior;)V">
<parameter name="windowContext" type="android.content.Context" jni-type="Landroid/content/Context;" not-null="true"/>
<parameter name="dialogBehavior" type="com.afollestad.materialdialogs.DialogBehavior" jni-type="Lcom/afollestad/materialdialogs/DialogBehavior;" not-null="true"/>
</constructor>
<constructor deprecated="not deprecated" final="false"
name="MaterialDialog" static="false" visibility="public"
bridge="false" synthetic="true"
jni-signature="(Landroid/content/Context;Lcom/afollestad/materialdialogs/DialogBehavior;ILkotlin/jvm/internal/DefaultConstructorMarker;)V">
<parameter name="p0" type="android.content.Context" jni-type="Landroid/content/Context;"/>
<parameter name="p1" type="com.afollestad.materialdialogs.DialogBehavior" jni-type="Lcom/afollestad/materialdialogs/DialogBehavior;"/>
<parameter name="p2" type="int" jni-type="I"/>
<parameter name="p3" type="kotlin.jvm.internal.DefaultConstructorMarker" jni-type="Lkotlin/jvm/internal/DefaultConstructorMarker;"/>
</constructor>
Additionally, the `kotlin.jvm.internal.DefaultConstructorMarker` type
is not available in the `Xamarin.Kotlin.StdLib` NuGet package, because
the type is `internal`.
Consequently, when trying to bind the constructor, `ApiXmlAdjuster`
reports this "error":
Error while processing '[Constructor] MaterialDialog(android.content.Context p0, com.afollestad.materialdialogs.DialogBehavior p1, int p2, kotlin.jvm.internal.DefaultConstructorMarker p3)' in '[Class] com.afollestad.materialdialogs.MaterialDialog': Type 'kotlin.jvm.internal.DefaultConstructorMarker' was not found.
This is actually good, as we shouldn't bind this synthetic constructor,
but we should detect this Kotlin-ism and not emit the "error", as it
misleads users into thinking they need to do something to fix it.
Update `Xamarin.Android.Tools.Bytecode` to *hide* constructors for
which the final two parameter types are `int, DefaultConstructorMarker`,
thus ensuring that `ApiXmlAdjuster` & co. won't process such members
or attempt to resolve the unresolvable `DefaultConstructorMarker` type.1 parent 4141d84 commit b4c2a67
File tree
6 files changed
+54
-38
lines changed- src/Xamarin.Android.Tools.Bytecode/Kotlin
- tests/Xamarin.Android.Tools.Bytecode-Tests
- Resources
- kotlin
6 files changed
+54
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
54 | 80 | | |
55 | 81 | | |
56 | 82 | | |
| |||
Lines changed: 0 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | 78 | | |
117 | 79 | | |
118 | 80 | | |
| |||
Binary file not shown.
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments