Fix variable name validator (take parameters into account)

This commit is contained in:
Mikhail Glukhikh
2017-11-28 15:56:25 +03:00
parent e341ec969f
commit 52053695fe
3 changed files with 5 additions and 5 deletions
@@ -119,7 +119,7 @@ class NewDeclarationNameValidator(
if (nameAsName != name) return false
if (this is KtCallableDeclaration && receiverTypeReference != null) return false
return when(target) {
Target.VARIABLES -> this is KtVariableDeclaration
Target.VARIABLES -> this is KtVariableDeclaration || this is KtParameter
Target.FUNCTIONS_AND_CLASSES -> this is KtNamedFunction || this is KtClassOrObject || this is KtTypeAlias
}
}
@@ -31,9 +31,9 @@ fun baz(f: (Int, Boolean) -> String) {
class Baz1(f: (Int, Boolean) -> String) : Foo({ i -> f(i, this) })
class Baz2 : Foo({ i -> (::g)(i, this) })
val f = lambda()
val f1 = lambda()
class Baz3 : Foo({ i -> f(i, this) })
class Baz3 : Foo({ i -> f1(i, this) })
class Baz4 : Foo({ i -> "${i + 1} ${this}" })
class Baz5 : Foo {
@@ -31,9 +31,9 @@ fun baz(f: (Int, Boolean) -> String) {
class Baz1(f: (Int, Boolean) -> String) : Foo({ i -> f(i, this) })
class Baz2 : Foo({ i -> (::g)(i, this) })
val f = lambda()
val f1 = lambda()
class Baz3 : Foo({ i -> f(i, this) })
class Baz3 : Foo({ i -> f1(i, this) })
class Baz4 : Foo({ i -> "${i + 1} ${this}" })
class Baz5 : Foo {