Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Attachment actions
Unintended behavior
View staffing
Description
1. Just copy-paste this code into a new project:
class MainActivity : AppCompatActivity() {
@UiThread
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
@UiThread
fun foo(myClass:MyClass){
myClass.foo()
}
@WorkerThread
class MyClass(val someInt: Int) {
fun foo() {
Log.d("AppLog", "int:$someInt")
}
}
}
The bug:
As you can see, the CTOR alone of the class is set to be called on a background thread, but there is a warning about using "foo" function which isn't annotated with anything.
It seems as if the annotations reaches every single function of the class.
If this is intentional, it's not intuitive, because I wanted to set it only for the CTOR alone.
Currently, the workaround is to convert to secondary CTOR, move the annotation there, and then convert back to a primary CTOR. Then it will look as such, which is the correct form (and it's quite weird too):
class MyClass @WorkerThread constructor(val someInt: Int) {
Please offer a quick-fix to move the annotation to the CTOR alone.
Check the video to see what I mean.
------------------
Studio Build:
Version of Gradle Plugin:
Version of Gradle:
Version of Java:
OS:
Android Studio Flamingo | 2022.2.1 Canary 10
Build #AI-222.4459.24.2221.9409768, built on December 15, 2022
Runtime version: 17.0.4.1+0-b2043.56-9127311 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 9048M
Cores: 12
Registry:
external.system.auto.import.disabled=true
debugger.watches.in.variables=false
ide.text.editor.with.preview.show.floating.toolbar=false
gradle.version.catalogs.dynamic.support=true
ide.images.show.chessboard=true
Non-Bundled Plugins:
idea.plugin.protoeditor (222.4459.16)
com.intellij.marketplace (222.4459.28)
com.dubreuia (2.3.0)
com.dethlex.numberconverter (1.5.0)
String Manipulation (9.6.1)
Show As ... (1.0.3)
GenerateSerializationHelpers (1.0.6)
GenerateSerialVersionUID (3.0.3)
com.google.mad-scorecard (1.2)
com.developerphil.adbidea (1.6.8)
net.aquadc.mike.plugin (0.27)
izhangzhihao.rainbow.brackets (2022.3.5-ij)
com.ppismerov.ksvu (0.0.1)