FIR: use typeWithStarProjections for protected visibility check
This commit is contained in:
committed by
TeamCityServer
parent
a14a00809f
commit
881b15a677
+6
@@ -25706,6 +25706,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("generic.kt")
|
||||||
|
public void testGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/generic.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassInJava.kt")
|
@TestMetadata("innerClassInJava.kt")
|
||||||
public void testInnerClassInJava() throws Exception {
|
public void testInnerClassInJava() throws Exception {
|
||||||
|
|||||||
+6
@@ -25706,6 +25706,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("generic.kt")
|
||||||
|
public void testGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/generic.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassInJava.kt")
|
@TestMetadata("innerClassInJava.kt")
|
||||||
public void testInnerClassInJava() throws Exception {
|
public void testInnerClassInJava() throws Exception {
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ abstract class FirVisibilityChecker : FirSessionComponent {
|
|||||||
stubTypesEqualToAnything = false
|
stubTypesEqualToAnything = false
|
||||||
)
|
)
|
||||||
return AbstractTypeChecker.isSubtypeOf(
|
return AbstractTypeChecker.isSubtypeOf(
|
||||||
typeCheckerState, dispatchReceiverType.fullyExpandedType(session), containingUseSiteClass.defaultType()
|
typeCheckerState, dispatchReceiverType.fullyExpandedType(session), containingUseSiteClass.typeWithStarProjections()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve
|
package org.jetbrains.kotlin.fir.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcast
|
import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcast
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcastToNull
|
import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcastToNull
|
||||||
@@ -101,14 +99,7 @@ private fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: Scope
|
|||||||
fun FirClassSymbol<*>.defaultType(): ConeClassLikeType = fir.defaultType()
|
fun FirClassSymbol<*>.defaultType(): ConeClassLikeType = fir.defaultType()
|
||||||
|
|
||||||
fun FirClass.defaultType(): ConeClassLikeType =
|
fun FirClass.defaultType(): ConeClassLikeType =
|
||||||
when (this) {
|
ConeClassLikeTypeImpl(
|
||||||
is FirRegularClass -> defaultType()
|
|
||||||
is FirAnonymousObject -> defaultType()
|
|
||||||
else -> error("Unknown class ${this::class}")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirRegularClass.defaultType(): ConeClassLikeTypeImpl {
|
|
||||||
return ConeClassLikeTypeImpl(
|
|
||||||
symbol.toLookupTag(),
|
symbol.toLookupTag(),
|
||||||
typeParameters.map {
|
typeParameters.map {
|
||||||
ConeTypeParameterTypeImpl(
|
ConeTypeParameterTypeImpl(
|
||||||
@@ -118,20 +109,6 @@ fun FirRegularClass.defaultType(): ConeClassLikeTypeImpl {
|
|||||||
}.toTypedArray(),
|
}.toTypedArray(),
|
||||||
isNullable = false
|
isNullable = false
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
fun FirAnonymousObject.defaultType(): ConeClassLikeType {
|
|
||||||
return ConeClassLikeTypeImpl(
|
|
||||||
symbol.toLookupTag(),
|
|
||||||
typeParameters.map {
|
|
||||||
ConeTypeParameterTypeImpl(
|
|
||||||
it.symbol.toLookupTag(),
|
|
||||||
isNullable = false
|
|
||||||
)
|
|
||||||
}.toTypedArray(),
|
|
||||||
isNullable = false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ClassId.defaultType(parameters: List<FirTypeParameterSymbol>): ConeClassLikeType =
|
fun ClassId.defaultType(parameters: List<FirTypeParameterSymbol>): ConeClassLikeType =
|
||||||
ConeClassLikeTypeImpl(
|
ConeClassLikeTypeImpl(
|
||||||
@@ -145,4 +122,11 @@ fun ClassId.defaultType(parameters: List<FirTypeParameterSymbol>): ConeClassLike
|
|||||||
isNullable = false,
|
isNullable = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun FirClass.typeWithStarProjections(): ConeClassLikeType =
|
||||||
|
ConeClassLikeTypeImpl(
|
||||||
|
symbol.toLookupTag(),
|
||||||
|
typeParameters.map { ConeStarProjection }.toTypedArray(),
|
||||||
|
isNullable = false
|
||||||
|
)
|
||||||
|
|
||||||
val TYPE_PARAMETER_SCOPE_KEY = scopeSessionKey<FirTypeParameterSymbol, FirTypeScope>()
|
val TYPE_PARAMETER_SCOPE_KEY = scopeSessionKey<FirTypeParameterSymbol, FirTypeScope>()
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
abstract class Parent<F> {
|
||||||
|
protected fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived<E> : Parent<E>() {
|
||||||
|
fun bar(x: Derived<String>) {
|
||||||
|
x.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public final class Derived</*0*/ E> : Parent<E> {
|
||||||
|
public constructor Derived</*0*/ E>()
|
||||||
|
public final fun bar(/*0*/ x: Derived<kotlin.String>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected final override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class Parent</*0*/ F> {
|
||||||
|
public constructor Parent</*0*/ F>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected final fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Generated
+6
@@ -25718,6 +25718,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("generic.kt")
|
||||||
|
public void testGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/generic.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassInJava.kt")
|
@TestMetadata("innerClassInJava.kt")
|
||||||
public void testInnerClassInJava() throws Exception {
|
public void testInnerClassInJava() throws Exception {
|
||||||
|
|||||||
+6
@@ -25706,6 +25706,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("generic.kt")
|
||||||
|
public void testGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/scopes/protectedVisibility/generic.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassInJava.kt")
|
@TestMetadata("innerClassInJava.kt")
|
||||||
public void testInnerClassInJava() throws Exception {
|
public void testInnerClassInJava() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user