Dont show warning for KT-21515 with LV>=1.3
This commit is contained in:
+6
@@ -652,6 +652,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getShouldReportCyclicScopeWithCompanionWarning() {
|
||||
return !c.getLanguageVersionSettings()
|
||||
.supportsFeature(LanguageFeature.ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reportScopesLoopError(@NotNull KotlinType type) {
|
||||
PsiElement reportOn = DescriptorToSourceUtils.getSourceFromDescriptor(type.getConstructor().getDeclarationDescriptor());
|
||||
|
||||
Vendored
+3
-3
@@ -2,14 +2,14 @@
|
||||
// see https://youtrack.jetbrains.com/issue/KT-21515
|
||||
|
||||
open class Container {
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!> {
|
||||
open class Base {
|
||||
open fun m() {}
|
||||
}
|
||||
|
||||
// note that Base() supertype will be resolved in scope that was created on recursion
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : Base()
|
||||
abstract class DerivedAbstract : Base()
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract() {
|
||||
companion object : DerivedAbstract() {
|
||||
override fun m() {}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,15 +1,15 @@
|
||||
// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// see https://youtrack.jetbrains.com/issue/KT-21515
|
||||
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base() {
|
||||
abstract class DerivedAbstract : C.Base() {
|
||||
open class Data
|
||||
}
|
||||
|
||||
public class C {
|
||||
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!> ()
|
||||
open class Base ()
|
||||
|
||||
class Foo : <!UNRESOLVED_REFERENCE!>Data<!>()
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract()
|
||||
companion object : DerivedAbstract()
|
||||
}
|
||||
+3
-3
@@ -6,13 +6,13 @@ open class Container {
|
||||
// (this is case because we can't know if there are any loops without resolving, but resolving
|
||||
// itself provokes loops)
|
||||
|
||||
interface <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!> {
|
||||
interface Base {
|
||||
open fun m() {}
|
||||
}
|
||||
|
||||
interface <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : Base
|
||||
interface DerivedAbstract : Base
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract {
|
||||
companion object : DerivedAbstract {
|
||||
override fun m() {}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,20 +1,20 @@
|
||||
// see https://youtrack.jetbrains.com/issue/KT-21515
|
||||
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base() {
|
||||
abstract class DerivedAbstract : C.Base() {
|
||||
override abstract fun m()
|
||||
}
|
||||
|
||||
public class C {
|
||||
class Data
|
||||
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!> () {
|
||||
open class Base () {
|
||||
open fun m() {}
|
||||
}
|
||||
|
||||
// Note that Data is resolved successfully here because we don't step on error-scope
|
||||
val data: Data = Data()
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract() {
|
||||
companion object : DerivedAbstract() {
|
||||
override fun m() {}
|
||||
}
|
||||
}
|
||||
Vendored
+3
-3
@@ -4,7 +4,7 @@
|
||||
interface SomeIrrelevantInterface
|
||||
|
||||
// note that C.Base() supertype will be resolved in normal scope
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base()
|
||||
abstract class DerivedAbstract : C.Base()
|
||||
|
||||
class Data
|
||||
|
||||
@@ -14,7 +14,7 @@ public class C {
|
||||
|
||||
// Note that any supertype of Base will be resolved in error-scope, even if it absolutely irrelevant
|
||||
// to the types in cycle.
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!>() : SomeIrrelevantInterface
|
||||
open class Base() : SomeIrrelevantInterface
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract()
|
||||
companion object : DerivedAbstract()
|
||||
}
|
||||
|
||||
+9
-9
@@ -2,37 +2,37 @@
|
||||
// see https://youtrack.jetbrains.com/issue/KT-21515
|
||||
|
||||
object WithFunctionInBase {
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base()
|
||||
abstract class DerivedAbstract : C.Base()
|
||||
|
||||
class Data
|
||||
|
||||
public class C {
|
||||
val data: Data = Data()
|
||||
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!>() {
|
||||
open class Base() {
|
||||
fun foo(): Int = 42
|
||||
}
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract()
|
||||
companion object : DerivedAbstract()
|
||||
}
|
||||
}
|
||||
|
||||
object WithPropertyInBase {
|
||||
// This case is very similar to previous one, but there are subtle differences from POV of implementation
|
||||
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base()
|
||||
abstract class DerivedAbstract : C.Base()
|
||||
|
||||
class Data
|
||||
|
||||
public class C {
|
||||
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!>() {
|
||||
open class Base() {
|
||||
val foo: Int = 42
|
||||
}
|
||||
|
||||
val data: Data = Data()
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract()
|
||||
companion object : DerivedAbstract()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,18 +41,18 @@ object WithPropertyInBaseDifferentOrder {
|
||||
// Note how position of property in file affected order of resolve, and, consequently, its results and
|
||||
// diagnostics.
|
||||
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base()
|
||||
abstract class DerivedAbstract : C.Base()
|
||||
|
||||
class Data
|
||||
|
||||
public class C {
|
||||
val data: Data = Data()
|
||||
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!>() {
|
||||
open class Base() {
|
||||
val foo: Int = 42
|
||||
|
||||
}
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract()
|
||||
companion object : DerivedAbstract()
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,17 +1,17 @@
|
||||
// see https://youtrack.jetbrains.com/issue/KT-21515
|
||||
|
||||
abstract class <!CYCLIC_SCOPES_WITH_COMPANION!>DerivedAbstract<!> : C.Base()
|
||||
abstract class DerivedAbstract : C.Base()
|
||||
|
||||
class Data
|
||||
|
||||
open class C {
|
||||
open class <!CYCLIC_SCOPES_WITH_COMPANION!>Base<!> {
|
||||
open class Base {
|
||||
open fun m() {}
|
||||
}
|
||||
|
||||
val field = Data()
|
||||
|
||||
companion <!CYCLIC_SCOPES_WITH_COMPANION!>object<!> : DerivedAbstract() {
|
||||
companion object : DerivedAbstract() {
|
||||
override fun m() {}
|
||||
}
|
||||
}
|
||||
@@ -97,11 +97,13 @@ abstract class AbstractTypeConstructor(storageManager: StorageManager) : TypeCon
|
||||
// We also check if there are a loop with additional edges going from owner of companion to
|
||||
// the companion itself.
|
||||
// Note that we use already disconnected types to not report two diagnostics on cyclic supertypes
|
||||
supertypeLoopChecker.findLoopsInSupertypesAndDisconnect(
|
||||
this, resultWithoutCycles,
|
||||
{ it.computeNeighbours(useCompanions = true) },
|
||||
{ reportScopesLoopError(it) }
|
||||
)
|
||||
if (shouldReportCyclicScopeWithCompanionWarning) {
|
||||
supertypeLoopChecker.findLoopsInSupertypesAndDisconnect(
|
||||
this, resultWithoutCycles,
|
||||
{ it.computeNeighbours(useCompanions = true) },
|
||||
{ reportScopesLoopError(it) }
|
||||
)
|
||||
}
|
||||
|
||||
supertypes.supertypesWithoutCycles = (resultWithoutCycles as? List<KotlinType>) ?: resultWithoutCycles.toList()
|
||||
})
|
||||
@@ -118,6 +120,7 @@ abstract class AbstractTypeConstructor(storageManager: StorageManager) : TypeCon
|
||||
|
||||
// TODO: overload in AbstractTypeParameterDescriptor?
|
||||
protected open fun reportScopesLoopError(type: KotlinType) {}
|
||||
protected open val shouldReportCyclicScopeWithCompanionWarning: Boolean = false
|
||||
|
||||
protected open fun getAdditionalNeighboursInSupertypeGraph(useCompanions: Boolean): Collection<KotlinType> = emptyList()
|
||||
protected open fun defaultSupertypeIfEmpty(): KotlinType? = null
|
||||
|
||||
Reference in New Issue
Block a user