Fix Map<*,*> index type error (col 99:35): cast message map first
Browse files
app/src/main/java/dev/nova/browser/TabManager.kt
CHANGED
|
@@ -92,14 +92,19 @@ class TabManager(private val runtime: GeckoRuntime) {
|
|
| 92 |
}
|
| 93 |
}
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
fun recordConsoleMessage(raw: Any) {
|
| 96 |
-
val line = when (raw) {
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
val
|
|
|
|
| 100 |
"[$type] $payload"
|
| 101 |
}
|
| 102 |
-
else -> raw.toString()
|
| 103 |
}
|
| 104 |
consoleLines.add(line)
|
| 105 |
android.util.Log.i("NovaConsole", line)
|
|
|
|
| 92 |
}
|
| 93 |
}
|
| 94 |
|
| 95 |
+
/**
|
| 96 |
+
* Console lines arrive as message maps from the extension. Cast to a
|
| 97 |
+
* concretely-keyed map first — indexing a star-projected Map<*, *> with a
|
| 98 |
+
* String key does not typecheck in Kotlin.
|
| 99 |
+
*/
|
| 100 |
fun recordConsoleMessage(raw: Any) {
|
| 101 |
+
val line = when (val msg = raw as? Map<String, Any?>) {
|
| 102 |
+
null -> raw.toString()
|
| 103 |
+
else -> {
|
| 104 |
+
val type = msg["type"] ?: "log"
|
| 105 |
+
val payload = msg["payload"]?.toString() ?: ""
|
| 106 |
"[$type] $payload"
|
| 107 |
}
|
|
|
|
| 108 |
}
|
| 109 |
consoleLines.add(line)
|
| 110 |
android.util.Log.i("NovaConsole", line)
|