Skip to content
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

VarCouldBeVal false positive #1257

Closed
marianosimone opened this issue Oct 19, 2018 · 2 comments
Closed

VarCouldBeVal false positive #1257

marianosimone opened this issue Oct 19, 2018 · 2 comments

Comments

@marianosimone
Copy link
Contributor

I'm still trying to look into it, but initially, this minimal example shows a false positive:

fun createObject() = object {
	private var myVar: String? = null
	fun assign(value: String?) {
		this.myVar = value
	}
}

However, this one doesn't (note that I removed this):

fun createObject() = object {
	private var myVar: String? = null
	fun assign(value: String?) {
		myVar = value
	}
}

Nor this one (this is there, but there's no function body):

val myObject = object {
	private var myVar: String? = null
	fun assign(value: String?) {
		this.myVar = value
	}
}
@arturbosch
Copy link
Member

Thanks for reporting, this is due to the fact that we cache variables on different declaration levels but do not consider this in variable usages. Will look into it now.

@lock
Copy link

lock bot commented Jun 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants