[FIR] Reorder scopes for KT-34822
This commit is contained in:
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
interface Some
|
interface Some
|
||||||
abstract class My<T : Some> {
|
abstract class My<T : Some> {
|
||||||
open inner class T
|
open inner class T
|
||||||
abstract val x: My<T>.T
|
abstract val x: T
|
||||||
abstract fun foo(arg: My<T>.T)
|
abstract fun foo(arg: T)
|
||||||
abstract val y: My<Some>.T
|
abstract val y: My<Some>.T
|
||||||
abstract val z: My<Some>.T
|
abstract val z: My<Some>.T
|
||||||
abstract class Some : My<Some>.T
|
abstract class Some : My<Some>.T
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
interface Some
|
interface Some
|
||||||
abstract class My<T : Some> {
|
abstract class My<T : Some> {
|
||||||
open inner class T
|
open inner class T
|
||||||
abstract val x: My<T>.T
|
abstract val x: T
|
||||||
abstract fun foo(arg: My<T>.T)
|
abstract fun foo(arg: T)
|
||||||
abstract val y: My<Some>.T
|
abstract val y: My<Some>.T
|
||||||
abstract val z: My<Some>.T
|
abstract val z: My<Some>.T
|
||||||
abstract class Some : My<Some>.T
|
abstract class Some : My<Some>.T
|
||||||
|
|||||||
+21
-11
@@ -1,32 +1,42 @@
|
|||||||
FILE: typeParameterVsNested.kt
|
FILE: typeParameterVsNested.kt
|
||||||
public abstract interface Some : R|kotlin/Any| {
|
public abstract interface Some : R|kotlin/Any| {
|
||||||
|
public open fun test(): R|kotlin/Int| {
|
||||||
|
^test Int(10)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public abstract class My<T : R|test/Some|> : R|kotlin/Any| {
|
public abstract class My<T : R|test/Some|> : R|kotlin/Any| {
|
||||||
public constructor<T : R|test/Some|>(): R|test/My<T>| {
|
public constructor<T : R|test/Some|>(): R|test/My<T>| {
|
||||||
super<R|kotlin/Any|>()
|
super<R|kotlin/Any|>()
|
||||||
}
|
}
|
||||||
|
|
||||||
public final inner class T<T : R|test/Some|> : R|kotlin/Any| {
|
public open class T : R|kotlin/Any| {
|
||||||
public test/My<T>.constructor(): R|test/My.T<T>| {
|
public constructor(): R|test/My.T| {
|
||||||
super<R|kotlin/Any|>()
|
super<R|kotlin/Any|>()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract val x: R|test/My.T<T>|
|
public abstract val x: R|T|
|
||||||
public get(): R|test/My.T<T>|
|
public get(): R|T|
|
||||||
|
|
||||||
public abstract fun foo(arg: R|test/My.T<T>|): R|kotlin/Unit|
|
public final fun foo(arg: R|T|): R|kotlin/Int| {
|
||||||
|
^foo R|<local>/arg|.R|test/Some.test|().R|kotlin/Int.plus|(this@R|test/My|.R|test/My.x|.R|test/Some.test|())
|
||||||
|
}
|
||||||
|
|
||||||
public abstract val y: <ERROR TYPE REF: Wrong number of type arguments>
|
public abstract val y: R|test/My.T|
|
||||||
public get(): <ERROR TYPE REF: Wrong number of type arguments>
|
public get(): R|test/My.T|
|
||||||
|
|
||||||
public abstract val z: <ERROR TYPE REF: Wrong number of type arguments>
|
public abstract val z: R|test/My.T|
|
||||||
public get(): <ERROR TYPE REF: Wrong number of type arguments>
|
public get(): R|test/My.T|
|
||||||
|
|
||||||
public final class Some : <ERROR TYPE REF: Type parameter T cannot be a supertype> {
|
public final fun boo(): R|kotlin/String| {
|
||||||
|
^boo this@R|test/My|.R|test/My.y|.<Unresolved name: test>#().R|kotlin/plus|(this@R|test/My|.R|test/My.z|.<Unresolved name: test>#())
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Some : R|test/My.T| {
|
||||||
public constructor(): R|test/My.Some| {
|
public constructor(): R|test/My.Some| {
|
||||||
super<R|test/My.T<T>|>()
|
super<R|T|>()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
interface Some
|
interface Some {
|
||||||
|
fun test() = 10
|
||||||
|
}
|
||||||
|
|
||||||
abstract class My<T : Some> {
|
abstract class My<T : Some> {
|
||||||
inner class T
|
open class T
|
||||||
|
|
||||||
abstract val x: T
|
abstract val x: T
|
||||||
|
|
||||||
abstract fun foo(arg: T)
|
// Wouldn't work for the inner class T
|
||||||
|
fun foo(arg: T) = arg.test() + x.test()
|
||||||
|
|
||||||
abstract val y: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>My<!>.T
|
abstract val y: My.T
|
||||||
|
|
||||||
abstract val z: test.<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>My<!>.T
|
abstract val z: test.My.T
|
||||||
|
|
||||||
class Some : <!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, UNRESOLVED_REFERENCE!>T<!>()
|
// Would work for the type parameter T
|
||||||
|
fun boo() = y.<!UNRESOLVED_REFERENCE!>test<!>() + z.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||||
|
|
||||||
|
class Some : T()
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class Your<T : Some> : <!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE!>T<!>
|
abstract class Your<T : Some> : <!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE!>T<!>
|
||||||
|
|||||||
+1
-1
@@ -172,7 +172,6 @@ private fun createScopesForNestedClasses(
|
|||||||
mutableListOf<FirScope>().apply {
|
mutableListOf<FirScope>().apply {
|
||||||
// Note: from higher priority to lower priority
|
// Note: from higher priority to lower priority
|
||||||
// See also: BodyResolveContext.withScopesForClass
|
// See also: BodyResolveContext.withScopesForClass
|
||||||
addIfNotNull(klass.typeParametersScope())
|
|
||||||
addIfNotNull(session.nestedClassifierScope(klass))
|
addIfNotNull(session.nestedClassifierScope(klass))
|
||||||
val companionObjects = klass.declarations.filterIsInstance<FirRegularClass>().filter { it.isCompanion }
|
val companionObjects = klass.declarations.filterIsInstance<FirRegularClass>().filter { it.isCompanion }
|
||||||
for (companionObject in companionObjects) {
|
for (companionObject in companionObjects) {
|
||||||
@@ -186,6 +185,7 @@ private fun createScopesForNestedClasses(
|
|||||||
it.lookupTag.getNestedClassifierScope(session, scopeSession)
|
it.lookupTag.getNestedClassifierScope(session, scopeSession)
|
||||||
?.wrapNestedClassifierScopeWithSubstitutionForSuperType(it, session)
|
?.wrapNestedClassifierScopeWithSubstitutionForSuperType(it, session)
|
||||||
}
|
}
|
||||||
|
addIfNotNull(klass.typeParametersScope())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FirRegularClass.resolveSupertypesInTheAir(session: FirSession): List<FirTypeRef> {
|
fun FirRegularClass.resolveSupertypesInTheAir(session: FirSession): List<FirTypeRef> {
|
||||||
|
|||||||
+2
-3
@@ -249,16 +249,15 @@ open class FirTypeResolveTransformer(
|
|||||||
scopes.add(scope)
|
scopes.add(scope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
session.nestedClassifierScope(firClass)?.let(scopes::add)
|
||||||
if (firClass is FirRegularClass) {
|
if (firClass is FirRegularClass) {
|
||||||
firClass.addTypeParametersScope()
|
|
||||||
val companionObject = firClass.companionObject
|
val companionObject = firClass.companionObject
|
||||||
if (companionObject != null) {
|
if (companionObject != null) {
|
||||||
session.nestedClassifierScope(companionObject)?.let(scopes::add)
|
session.nestedClassifierScope(companionObject)?.let(scopes::add)
|
||||||
}
|
}
|
||||||
|
firClass.addTypeParametersScope()
|
||||||
}
|
}
|
||||||
|
|
||||||
session.nestedClassifierScope(firClass)?.let(scopes::add)
|
|
||||||
|
|
||||||
// Note that annotations are still visited here
|
// Note that annotations are still visited here
|
||||||
// again, although there's no need in it
|
// again, although there's no need in it
|
||||||
transformElement(firClass, data)
|
transformElement(firClass, data)
|
||||||
|
|||||||
Vendored
-1
@@ -2,7 +2,6 @@
|
|||||||
// WITH_REFLECT
|
// WITH_REFLECT
|
||||||
|
|
||||||
// FIR incorrectly resolves typeParameterType's return type to the nested class `A.T`.
|
// FIR incorrectly resolves typeParameterType's return type to the nested class `A.T`.
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user