FIR checker: fix local type approximation on delegated property
Previously types of delegated property is not approximated, which can cause local types to leak through public APIs.
This commit is contained in:
committed by
teamcityserver
parent
76e192fc8a
commit
d3e8cc577c
+6
@@ -7543,6 +7543,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("localObjectInInnerClass.kt")
|
||||||
|
public void testLocalObjectInInnerClass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localObjectInInnerClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
||||||
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
||||||
|
|||||||
+6
@@ -7543,6 +7543,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("localObjectInInnerClass.kt")
|
||||||
|
public void testLocalObjectInInnerClass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localObjectInInnerClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
||||||
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
||||||
|
|||||||
+6
@@ -7543,6 +7543,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("localObjectInInnerClass.kt")
|
||||||
|
public void testLocalObjectInInnerClass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localObjectInInnerClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
||||||
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
||||||
|
|||||||
+51
-26
@@ -6,10 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isInline
|
import org.jetbrains.kotlin.fir.declarations.utils.isInline
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isSuspend
|
import org.jetbrains.kotlin.fir.declarations.utils.isSuspend
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
@@ -68,7 +71,7 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
private val mode: Mode = Mode.Normal
|
private val mode: Mode = Mode.Normal
|
||||||
) : FirAbstractTreeTransformer<ExpectedArgumentType?>(phase = FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
) : FirAbstractTreeTransformer<ExpectedArgumentType?>(phase = FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
||||||
|
|
||||||
private val declarationWriter by lazy { FirDeclarationCompletionResultsWriter(finalSubstitutor) }
|
private val declarationWriter by lazy { FirDeclarationCompletionResultsWriter(finalSubstitutor, typeApproximator, session.typeContext) }
|
||||||
|
|
||||||
private val arrayOfCallTransformer = FirArrayOfCallTransformer()
|
private val arrayOfCallTransformer = FirArrayOfCallTransformer()
|
||||||
private var enableArrayOfCallTransformation = false
|
private var enableArrayOfCallTransformation = false
|
||||||
@@ -169,7 +172,10 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
session.lookupTracker?.recordTypeResolveAsLookup(resultType, qualifiedAccessExpression.source, null)
|
session.lookupTracker?.recordTypeResolveAsLookup(resultType, qualifiedAccessExpression.source, null)
|
||||||
|
|
||||||
if (mode == Mode.DelegatedPropertyCompletion) {
|
if (mode == Mode.DelegatedPropertyCompletion) {
|
||||||
subCandidate.symbol.fir.transformSingle(declarationWriter, null)
|
subCandidate.symbol.fir.transformSingle(
|
||||||
|
declarationWriter,
|
||||||
|
FirDeclarationCompletionResultsWriter.ApproximationData.NoApproximation
|
||||||
|
)
|
||||||
val typeUpdater = TypeUpdaterForDelegateArguments()
|
val typeUpdater = TypeUpdaterForDelegateArguments()
|
||||||
result.transformExplicitReceiver(typeUpdater, null)
|
result.transformExplicitReceiver(typeUpdater, null)
|
||||||
}
|
}
|
||||||
@@ -235,7 +241,10 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
session.lookupTracker?.recordTypeResolveAsLookup(resultType, functionCall.source, null)
|
session.lookupTracker?.recordTypeResolveAsLookup(resultType, functionCall.source, null)
|
||||||
|
|
||||||
if (mode == Mode.DelegatedPropertyCompletion) {
|
if (mode == Mode.DelegatedPropertyCompletion) {
|
||||||
subCandidate.symbol.fir.transformSingle(declarationWriter, null)
|
subCandidate.symbol.fir.transformSingle(
|
||||||
|
declarationWriter,
|
||||||
|
FirDeclarationCompletionResultsWriter.ApproximationData.NoApproximation
|
||||||
|
)
|
||||||
val typeUpdater = TypeUpdaterForDelegateArguments()
|
val typeUpdater = TypeUpdaterForDelegateArguments()
|
||||||
result.argumentList.transformArguments(typeUpdater, null)
|
result.argumentList.transformArguments(typeUpdater, null)
|
||||||
result.transformExplicitReceiver(typeUpdater, null)
|
result.transformExplicitReceiver(typeUpdater, null)
|
||||||
@@ -832,46 +841,62 @@ private fun ExpectedArgumentType.getExpectedType(argument: FirElement): ConeKotl
|
|||||||
|
|
||||||
fun ConeKotlinType.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ExpectedType(this)
|
fun ConeKotlinType.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ExpectedType(this)
|
||||||
|
|
||||||
class FirDeclarationCompletionResultsWriter(private val finalSubstitutor: ConeSubstitutor) : FirDefaultTransformer<Any?>() {
|
internal class FirDeclarationCompletionResultsWriter(
|
||||||
override fun <E : FirElement> transformElement(element: E, data: Any?): E {
|
private val finalSubstitutor: ConeSubstitutor,
|
||||||
|
private val typeApproximator: ConeTypeApproximator,
|
||||||
|
private val typeContext: ConeInferenceContext
|
||||||
|
) : FirDefaultTransformer<FirDeclarationCompletionResultsWriter.ApproximationData>() {
|
||||||
|
override fun <E : FirElement> transformElement(element: E, data: ApproximationData): E {
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: Any?): FirStatement {
|
override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: ApproximationData): FirStatement {
|
||||||
simpleFunction.transformReturnTypeRef(this, data)
|
return super.transformAnonymousObject(anonymousObject, ApproximationData.NoApproximation)
|
||||||
simpleFunction.transformValueParameters(this, data)
|
}
|
||||||
simpleFunction.transformReceiverTypeRef(this, data)
|
|
||||||
|
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: ApproximationData): FirStatement {
|
||||||
|
val newData = if (simpleFunction.isLocal || data == ApproximationData.NoApproximation) ApproximationData.NoApproximation
|
||||||
|
else ApproximationData.ApproximateByStatus(simpleFunction.visibility, simpleFunction.isInline)
|
||||||
|
simpleFunction.transformReturnTypeRef(this, newData)
|
||||||
|
simpleFunction.transformValueParameters(this, ApproximationData.NoApproximation)
|
||||||
|
simpleFunction.transformReceiverTypeRef(this, newData)
|
||||||
return simpleFunction
|
return simpleFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformProperty(property: FirProperty, data: Any?): FirStatement {
|
override fun transformProperty(property: FirProperty, data: ApproximationData): FirStatement {
|
||||||
property.transformGetter(this, data)
|
val newData = if (property.isLocal || data == ApproximationData.NoApproximation) ApproximationData.NoApproximation
|
||||||
property.transformSetter(this, data)
|
else ApproximationData.ApproximateByStatus(property.visibility, false)
|
||||||
property.transformReturnTypeRef(this, data)
|
property.transformGetter(this, newData)
|
||||||
property.transformReceiverTypeRef(this, data)
|
property.transformSetter(this, newData)
|
||||||
|
property.transformReturnTypeRef(this, newData)
|
||||||
|
property.transformReceiverTypeRef(this, newData)
|
||||||
return property
|
return property
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformPropertyAccessor(
|
override fun transformPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: ApproximationData): FirStatement {
|
||||||
propertyAccessor: FirPropertyAccessor,
|
|
||||||
data: Any?
|
|
||||||
): FirStatement {
|
|
||||||
propertyAccessor.transformReturnTypeRef(this, data)
|
propertyAccessor.transformReturnTypeRef(this, data)
|
||||||
propertyAccessor.transformValueParameters(this, data)
|
propertyAccessor.transformValueParameters(this, ApproximationData.NoApproximation)
|
||||||
return propertyAccessor
|
return propertyAccessor
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformValueParameter(
|
override fun transformValueParameter(valueParameter: FirValueParameter, data: ApproximationData): FirStatement {
|
||||||
valueParameter: FirValueParameter,
|
valueParameter.transformReturnTypeRef(this, ApproximationData.NoApproximation)
|
||||||
data: Any?
|
|
||||||
): FirStatement {
|
|
||||||
valueParameter.transformReturnTypeRef(this, data)
|
|
||||||
return valueParameter
|
return valueParameter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformTypeRef(typeRef: FirTypeRef, data: Any?): FirTypeRef {
|
override fun transformTypeRef(typeRef: FirTypeRef, data: ApproximationData): FirTypeRef {
|
||||||
return finalSubstitutor.substituteOrNull(typeRef.coneType)?.let {
|
val result = finalSubstitutor.substituteOrNull(typeRef.coneType)?.let {
|
||||||
typeRef.resolvedTypeFromPrototype(it)
|
typeRef.resolvedTypeFromPrototype(it)
|
||||||
} ?: typeRef
|
} ?: typeRef
|
||||||
|
if (data is ApproximationData.ApproximateByStatus) {
|
||||||
|
return result.approximatedIfNeededOrSelf(typeApproximator, data.visibility, typeContext, data.isInline)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class ApproximationData {
|
||||||
|
class ApproximateByStatus(val visibility: Visibility?, val isInline: Boolean) : ApproximationData()
|
||||||
|
object NoApproximation : ApproximationData()
|
||||||
|
object Default : ApproximationData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -264,8 +264,9 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
completedCalls.forEach {
|
completedCalls.forEach {
|
||||||
it.transformSingle(callCompletionResultsWriter, null)
|
it.transformSingle(callCompletionResultsWriter, null)
|
||||||
}
|
}
|
||||||
val declarationCompletionResultsWriter = FirDeclarationCompletionResultsWriter(finalSubstitutor)
|
val declarationCompletionResultsWriter =
|
||||||
property.transformSingle(declarationCompletionResultsWriter, null)
|
FirDeclarationCompletionResultsWriter(finalSubstitutor, inferenceComponents.approximator, session.typeContext)
|
||||||
|
property.transformSingle(declarationCompletionResultsWriter, FirDeclarationCompletionResultsWriter.ApproximationData.Default)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+55
-1
@@ -1,3 +1,9 @@
|
|||||||
|
interface Lazy<T> {
|
||||||
|
operator fun getValue(a1: Any, a2: Any): T
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> lazy(f: () -> T): Lazy<T> = throw Exception()
|
||||||
|
|
||||||
interface MyTrait {
|
interface MyTrait {
|
||||||
fun f1() {}
|
fun f1() {}
|
||||||
}
|
}
|
||||||
@@ -7,13 +13,21 @@ open class MyClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Foo {
|
class Foo(val myTrait: MyTrait) {
|
||||||
|
|
||||||
private val privateProperty = object : MyClass(), MyTrait {}
|
private val privateProperty = object : MyClass(), MyTrait {}
|
||||||
|
val publicPropertyWithSingleSuperType = object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
private val privatePropertyWithSingleSuperType = object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
privateProperty.f1()
|
privateProperty.f1()
|
||||||
privateProperty.f2()
|
privateProperty.f2()
|
||||||
|
publicPropertyWithSingleSuperType.<!UNRESOLVED_REFERENCE!>onlyFromAnonymousObject<!>() // unresolved due to approximation
|
||||||
|
privatePropertyWithSingleSuperType.onlyFromAnonymousObject() // resolvable since private
|
||||||
}
|
}
|
||||||
|
|
||||||
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>protected val protectedProperty<!> = object : MyClass(), MyTrait {}
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>protected val protectedProperty<!> = object : MyClass(), MyTrait {}
|
||||||
@@ -27,6 +41,46 @@ class Foo {
|
|||||||
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val propertyWithGetter<!>
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val propertyWithGetter<!>
|
||||||
get() = object: MyClass(), MyTrait {}
|
get() = object: MyClass(), MyTrait {}
|
||||||
|
|
||||||
|
private val privateDelegateProperty by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
val publicDelegatePropertyWithSingleSuperType by lazy {
|
||||||
|
object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val privateDelegatePropertyWithSingleSuperType by lazy {
|
||||||
|
object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
privateDelegateProperty.f1()
|
||||||
|
privateDelegateProperty.f2()
|
||||||
|
publicDelegatePropertyWithSingleSuperType.<!UNRESOLVED_REFERENCE!>onlyFromAnonymousObject<!>() // unresolved due to approximation
|
||||||
|
privateDelegatePropertyWithSingleSuperType.onlyFromAnonymousObject() // resolvable since private
|
||||||
|
}
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>protected val protectedDelegateProperty<!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val internalDelegateProperty<!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>internal val internal2DelegateProperty<!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>public val publicDelegateProperty<!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
private val privateDelegate = object : MyTrait by myTrait {
|
||||||
|
fun f2() {}
|
||||||
|
}
|
||||||
|
val delegate = object : MyTrait by myTrait {
|
||||||
|
fun f2() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
privateDelegate.f1()
|
||||||
|
privateDelegate.f2()
|
||||||
|
delegate.f1()
|
||||||
|
delegate.<!UNRESOLVED_REFERENCE!>f2<!>()
|
||||||
|
}
|
||||||
|
|
||||||
private fun privateFunction() = object : MyClass(), MyTrait {}
|
private fun privateFunction() = object : MyClass(), MyTrait {}
|
||||||
|
|
||||||
|
|||||||
+55
-1
@@ -1,3 +1,9 @@
|
|||||||
|
interface Lazy<T> {
|
||||||
|
operator fun getValue(a1: Any, a2: Any): T
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> lazy(f: () -> T): Lazy<T> = throw Exception()
|
||||||
|
|
||||||
interface MyTrait {
|
interface MyTrait {
|
||||||
fun f1() {}
|
fun f1() {}
|
||||||
}
|
}
|
||||||
@@ -7,13 +13,21 @@ open class MyClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Foo {
|
class Foo(val myTrait: MyTrait) {
|
||||||
|
|
||||||
private val privateProperty = object : MyClass(), MyTrait {}
|
private val privateProperty = object : MyClass(), MyTrait {}
|
||||||
|
val publicPropertyWithSingleSuperType = object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
private val privatePropertyWithSingleSuperType = object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
privateProperty.f1()
|
privateProperty.f1()
|
||||||
privateProperty.f2()
|
privateProperty.f2()
|
||||||
|
publicPropertyWithSingleSuperType.<!UNRESOLVED_REFERENCE!>onlyFromAnonymousObject<!>() // unresolved due to approximation
|
||||||
|
privatePropertyWithSingleSuperType.onlyFromAnonymousObject() // resolvable since private
|
||||||
}
|
}
|
||||||
|
|
||||||
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>protected val <!EXPOSED_PROPERTY_TYPE!>protectedProperty<!><!> = object : MyClass(), MyTrait {}
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>protected val <!EXPOSED_PROPERTY_TYPE!>protectedProperty<!><!> = object : MyClass(), MyTrait {}
|
||||||
@@ -27,6 +41,46 @@ class Foo {
|
|||||||
val <!EXPOSED_PROPERTY_TYPE!>propertyWithGetter<!>
|
val <!EXPOSED_PROPERTY_TYPE!>propertyWithGetter<!>
|
||||||
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>get()<!> = object: MyClass(), MyTrait {}
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>get()<!> = object: MyClass(), MyTrait {}
|
||||||
|
|
||||||
|
private val privateDelegateProperty by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
val publicDelegatePropertyWithSingleSuperType by lazy {
|
||||||
|
object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val privateDelegatePropertyWithSingleSuperType by lazy {
|
||||||
|
object : MyClass() {
|
||||||
|
fun onlyFromAnonymousObject() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
<!DEBUG_INFO_LEAKING_THIS!>privateDelegateProperty<!>.f1()
|
||||||
|
<!DEBUG_INFO_LEAKING_THIS!>privateDelegateProperty<!>.f2()
|
||||||
|
<!DEBUG_INFO_LEAKING_THIS!>publicDelegatePropertyWithSingleSuperType<!>.<!UNRESOLVED_REFERENCE!>onlyFromAnonymousObject<!>() // unresolved due to approximation
|
||||||
|
<!DEBUG_INFO_LEAKING_THIS!>privateDelegatePropertyWithSingleSuperType<!>.onlyFromAnonymousObject() // resolvable since private
|
||||||
|
}
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>protected val <!EXPOSED_PROPERTY_TYPE!>protectedDelegateProperty<!><!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val <!EXPOSED_PROPERTY_TYPE!>internalDelegateProperty<!><!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>internal val <!EXPOSED_PROPERTY_TYPE!>internal2DelegateProperty<!><!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>public val <!EXPOSED_PROPERTY_TYPE!>publicDelegateProperty<!><!> by lazy { object : MyClass(), MyTrait {} }
|
||||||
|
|
||||||
|
private val privateDelegate = object : MyTrait by myTrait {
|
||||||
|
fun f2() {}
|
||||||
|
}
|
||||||
|
val delegate = object : MyTrait by myTrait {
|
||||||
|
fun f2() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
privateDelegate.f1()
|
||||||
|
privateDelegate.f2()
|
||||||
|
delegate.f1()
|
||||||
|
delegate.<!UNRESOLVED_REFERENCE!>f2<!>()
|
||||||
|
}
|
||||||
|
|
||||||
private fun privateFunction() = object : MyClass(), MyTrait {}
|
private fun privateFunction() = object : MyClass(), MyTrait {}
|
||||||
|
|
||||||
|
|||||||
+22
-1
@@ -6,19 +6,32 @@ private val packagePrivateProperty: packagePrivateProperty.<no name provided>
|
|||||||
protected val packageProtectedProperty: packageProtectedProperty.<no name provided>
|
protected val packageProtectedProperty: packageProtectedProperty.<no name provided>
|
||||||
public val packagePublicProperty: packagePublicProperty.<no name provided>
|
public val packagePublicProperty: packagePublicProperty.<no name provided>
|
||||||
public fun fooPackage(): kotlin.Unit
|
public fun fooPackage(): kotlin.Unit
|
||||||
|
public fun </*0*/ T> lazy(/*0*/ f: () -> T): Lazy<T>
|
||||||
internal fun packageInternal2Function(): packageInternal2Function.<no name provided>
|
internal fun packageInternal2Function(): packageInternal2Function.<no name provided>
|
||||||
public fun packageInternalFunction(): packageInternalFunction.<no name provided>
|
public fun packageInternalFunction(): packageInternalFunction.<no name provided>
|
||||||
protected fun packageProtectedFunction(): packageProtectedFunction.<no name provided>
|
protected fun packageProtectedFunction(): packageProtectedFunction.<no name provided>
|
||||||
public fun packagePublicFunction(): packagePublicFunction.<no name provided>
|
public fun packagePublicFunction(): packagePublicFunction.<no name provided>
|
||||||
|
|
||||||
public final class Foo {
|
public final class Foo {
|
||||||
public constructor Foo()
|
public constructor Foo(/*0*/ myTrait: MyTrait)
|
||||||
|
public final val delegate: MyTrait
|
||||||
|
internal final val internal2DelegateProperty: Foo.internal2DelegateProperty.<anonymous>.<no name provided>
|
||||||
internal final val internal2Property: Foo.internal2Property.<no name provided>
|
internal final val internal2Property: Foo.internal2Property.<no name provided>
|
||||||
|
public final val internalDelegateProperty: Foo.internalDelegateProperty.<anonymous>.<no name provided>
|
||||||
public final val internalProperty: Foo.internalProperty.<no name provided>
|
public final val internalProperty: Foo.internalProperty.<no name provided>
|
||||||
|
public final val myTrait: MyTrait
|
||||||
|
private final val privateDelegate: Foo.privateDelegate.<no name provided>
|
||||||
|
private final val privateDelegateProperty: Foo.privateDelegateProperty.<anonymous>.<no name provided>
|
||||||
|
private final val privateDelegatePropertyWithSingleSuperType: Foo.privateDelegatePropertyWithSingleSuperType.<anonymous>.<no name provided>
|
||||||
private final val privateProperty: Foo.privateProperty.<no name provided>
|
private final val privateProperty: Foo.privateProperty.<no name provided>
|
||||||
|
private final val privatePropertyWithSingleSuperType: Foo.privatePropertyWithSingleSuperType.<no name provided>
|
||||||
public final val propertyWithGetter: Foo.<get-propertyWithGetter>.<no name provided>
|
public final val propertyWithGetter: Foo.<get-propertyWithGetter>.<no name provided>
|
||||||
|
protected final val protectedDelegateProperty: Foo.protectedDelegateProperty.<anonymous>.<no name provided>
|
||||||
protected final val protectedProperty: Foo.protectedProperty.<no name provided>
|
protected final val protectedProperty: Foo.protectedProperty.<no name provided>
|
||||||
|
public final val publicDelegateProperty: Foo.publicDelegateProperty.<anonymous>.<no name provided>
|
||||||
|
public final val publicDelegatePropertyWithSingleSuperType: MyClass
|
||||||
public final val publicProperty: Foo.publicProperty.<no name provided>
|
public final val publicProperty: Foo.publicProperty.<no name provided>
|
||||||
|
public final val publicPropertyWithSingleSuperType: MyClass
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public final fun foo(): kotlin.Unit
|
public final fun foo(): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
@@ -47,6 +60,13 @@ public final class Foo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface Lazy</*0*/ T> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public abstract operator fun getValue(/*0*/ a1: kotlin.Any, /*1*/ a2: kotlin.Any): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
public open class MyClass {
|
public open class MyClass {
|
||||||
public constructor MyClass()
|
public constructor MyClass()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
@@ -61,3 +81,4 @@ public interface MyTrait {
|
|||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
interface I1
|
||||||
|
interface I2
|
||||||
|
|
||||||
|
interface Lazy<T> {
|
||||||
|
operator fun getValue(a1: Any, a2: Any): T
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> lazy(f: () -> T): Lazy<T> = throw Exception()
|
||||||
|
|
||||||
|
class A {
|
||||||
|
private inner class B {
|
||||||
|
val o1 = object : I1 {}
|
||||||
|
val o2 by lazy {
|
||||||
|
object : I1 {}
|
||||||
|
}
|
||||||
|
val o3 = object : I1, I2 {} // FIR allows this since the containing class is private
|
||||||
|
val o4 by lazy { // FIR allows this since the containing class is private
|
||||||
|
object : I1, I2 {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val privateO1 = object : I1 {}
|
||||||
|
private val privateO2 by lazy {
|
||||||
|
object : I1 {}
|
||||||
|
}
|
||||||
|
private val privateO3 = object : I1, I2 {}
|
||||||
|
private val privateO4 by lazy {
|
||||||
|
object : I1, I2 {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
interface I1
|
||||||
|
interface I2
|
||||||
|
|
||||||
|
interface Lazy<T> {
|
||||||
|
operator fun getValue(a1: Any, a2: Any): T
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> lazy(f: () -> T): Lazy<T> = throw Exception()
|
||||||
|
|
||||||
|
class A {
|
||||||
|
private inner class B {
|
||||||
|
val o1 = object : I1 {}
|
||||||
|
val o2 by lazy {
|
||||||
|
object : I1 {}
|
||||||
|
}
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val o3<!> = object : I1, I2 {} // FIR allows this since the containing class is private
|
||||||
|
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val o4<!> by lazy { // FIR allows this since the containing class is private
|
||||||
|
object : I1, I2 {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val privateO1 = object : I1 {}
|
||||||
|
private val privateO2 by lazy {
|
||||||
|
object : I1 {}
|
||||||
|
}
|
||||||
|
private val privateO3 = object : I1, I2 {}
|
||||||
|
private val privateO4 by lazy {
|
||||||
|
object : I1, I2 {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ T> lazy(/*0*/ f: () -> T): Lazy<T>
|
||||||
|
|
||||||
|
public final class A {
|
||||||
|
public constructor A()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
private final inner class B {
|
||||||
|
public constructor B()
|
||||||
|
public final val o1: I1
|
||||||
|
public final val o2: I1
|
||||||
|
public final val o3: A.B.o3.<no name provided>
|
||||||
|
public final val o4: A.B.o4.<anonymous>.<no name provided>
|
||||||
|
private final val privateO1: A.B.privateO1.<no name provided>
|
||||||
|
private final val privateO2: A.B.privateO2.<anonymous>.<no name provided>
|
||||||
|
private final val privateO3: A.B.privateO3.<no name provided>
|
||||||
|
private final val privateO4: A.B.privateO4.<anonymous>.<no name provided>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface I1 {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface I2 {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Lazy</*0*/ T> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public abstract operator fun getValue(/*0*/ a1: kotlin.Any, /*1*/ a2: kotlin.Any): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Generated
+6
@@ -7549,6 +7549,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("localObjectInInnerClass.kt")
|
||||||
|
public void testLocalObjectInInnerClass() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/declarationChecks/localObjectInInnerClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
@TestMetadata("LocalVariableWithNoTypeInformation.kt")
|
||||||
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
public void testLocalVariableWithNoTypeInformation() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user