diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidConst.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidConst.kt
index 8eb0d02a781..3fcc8460aa7 100644
--- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidConst.kt
+++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidConst.kt
@@ -49,7 +49,7 @@ public fun idToName(id: String): String? {
if (isResourceIdDeclaration(id)) id.replace(AndroidConst.ID_DECLARATION_PREFIX, "")
else if (isResourceIdUsage(id)) id.replace(AndroidConst.ID_USAGE_PREFIX, "")
else null
- return if (unescaped != null) escapeWidgetId(unescaped) else null
+ return if (unescaped != null) escapeAndroidIdentifier(unescaped) else null
}
public fun isResourceIdDeclaration(str: String?): Boolean = str?.startsWith(AndroidConst.ID_DECLARATION_PREFIX) ?: false
@@ -67,6 +67,6 @@ public fun getRealWidgetType(xmlType: String): String = when (xmlType) {
else -> xmlType
}
-public fun escapeWidgetId(id: String): String {
+fun escapeAndroidIdentifier(id: String): String {
return if (id in AndroidConst.ESCAPED_IDENTIFIERS) "`$id`" else id
}
\ No newline at end of file
diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt
index e227d7c8ec9..a29f2a8291c 100644
--- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt
+++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt
@@ -136,7 +136,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
}
private fun PsiFile.genSyntheticPackageName(): String {
- return AndroidConst.SYNTHETIC_PACKAGE + "." + getName().substringBefore('.')
+ return AndroidConst.SYNTHETIC_PACKAGE + "." + escapeAndroidIdentifier(getName().substringBefore('.'))
}
private fun KotlinStringWriter.writeSyntheticProperty(receiver: String, widget: AndroidWidget, stubCall: String) {
diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/AndroidManifest.xml b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/layout.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/layout.kt
new file mode 100644
index 00000000000..38939afe031
--- /dev/null
+++ b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/layout.kt
@@ -0,0 +1,38 @@
+package kotlinx.android.synthetic.`get`
+
+import android.app.*
+import android.view.*
+import android.widget.*
+import android.webkit.*
+import android.inputmethodservice.*
+import android.opengl.*
+import android.appwidget.*
+import android.support.v4.app.*
+import android.support.v4.view.*
+import android.support.v4.widget.*
+import kotlin.internal.flexible.ft
+
+val android.app.Activity.item_detail_container: ft
+ get() = findViewById(0) as? FrameLayout
+
+val android.app.Fragment.item_detail_container: ft
+ get() = getView().findViewById(0) as? FrameLayout
+
+val android.app.Activity.textView1: ft
+ get() = findViewById(0) as? TextView
+
+val android.app.Fragment.textView1: ft
+ get() = getView().findViewById(0) as? TextView
+
+val android.app.Activity.password: ft
+ get() = findViewById(0) as? EditText
+
+val android.app.Fragment.password: ft
+ get() = getView().findViewById(0) as? EditText
+
+val android.app.Activity.login: ft