[FIR] Hide primary constructor parameters from accessors

This commit is contained in:
simon.ogorodnik
2020-02-11 16:10:00 +03:00
parent a0ed2c8640
commit d9883067e6
3 changed files with 11 additions and 8 deletions
@@ -100,10 +100,13 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
dataFlowAnalyzer.enterProperty(property)
withFullBodyResolve {
withScopeCleanup(localScopes) {
localScopes.addIfNotNull(primaryConstructorParametersScope)
components.withContainer(property) {
property.transformChildrenWithoutAccessors(returnTypeRef)
property.transformInitializer(integerLiteralTypeApproximator, null)
withScopeCleanup(localScopes) {
localScopes.addIfNotNull(primaryConstructorParametersScope)
property.transformChildrenWithoutAccessors(returnTypeRef)
property.transformInitializer(integerLiteralTypeApproximator, null)
}
if (property.initializer != null) {
storeVariableReturnType(property)
}
@@ -5,5 +5,5 @@ class Foo(val a: Int, b: Int) {
get() = a
val e: Int
get() = b
get() = <!UNRESOLVED_REFERENCE!>b<!>
}
@@ -8,16 +8,16 @@ fun <T> delegateFactory(p: Any) = Delegate
class C(p: Any, val v: Any) {
val test1 get() = p
val test1 get() = <!UNRESOLVED_REFERENCE!>p<!>
val test2 get() = v
// NB here we can use both 'T' (property type parameter) and 'p' (primary constructor parameter)
val <T> List<T>.test3 by delegateFactory<T>(p)
val test4 get() { return p }
val test4 get() { return <!UNRESOLVED_REFERENCE!>p<!> }
var test5
get() { return p }
set(nv) { p.let {} }
get() { return <!UNRESOLVED_REFERENCE!>p<!> }
set(nv) { <!UNRESOLVED_REFERENCE!>p<!>.<!INAPPLICABLE_CANDIDATE!>let<!> {} }
}