Add/fix extra cases for #KT-41886 Fixed
This commit is contained in:
committed by
teamcity
parent
7d3368da58
commit
76aaecbdf0
@@ -462,11 +462,14 @@ class OptInUsageChecker(project: Project) : CallChecker {
|
||||
}
|
||||
|
||||
if (element.getParentOfType<KtImportDirective>(false) == null) {
|
||||
val containingClass = element.getParentOfType<KtClassOrObject>(strict = true)
|
||||
val descriptions = targetDescriptor.loadOptIns(
|
||||
moduleAnnotationsResolver,
|
||||
bindingContext,
|
||||
context.languageVersionSettings,
|
||||
fromSupertype = element.getParentOfType<KtSuperTypeListEntry>(strict = true) != null
|
||||
fromSupertype = containingClass != null && containingClass.superTypeListEntries.any {
|
||||
it.typeAsUserType == element.parent
|
||||
}
|
||||
)
|
||||
reportNotAllowedOptIns(descriptions, element, context)
|
||||
}
|
||||
|
||||
+16
-1
@@ -25,7 +25,7 @@ class GrandDerivedFourth : DerivedFourth()
|
||||
open class Marked
|
||||
|
||||
@SubclassOptInRequired(Marker::class)
|
||||
class DerivedMarked : <!OPT_IN_USAGE_ERROR!>Marked<!>()
|
||||
open class DerivedMarked : <!OPT_IN_USAGE_ERROR!>Marked<!>()
|
||||
|
||||
fun test() {
|
||||
val b = Base()
|
||||
@@ -34,3 +34,18 @@ fun test() {
|
||||
val d3 = DerivedThird()
|
||||
val d4 = DerivedFourth()
|
||||
}
|
||||
|
||||
fun test2(b: Base, g: Generic<Base>) {
|
||||
object : <!OPT_IN_USAGE_ERROR!>Base<!>() {}
|
||||
}
|
||||
|
||||
open class Generic<T>
|
||||
|
||||
class DerivedGeneric : Generic<Base>()
|
||||
|
||||
@SubclassOptInRequired(Marker::class)
|
||||
interface BaseInterface
|
||||
|
||||
interface DerivedInterface : <!OPT_IN_USAGE_ERROR!>BaseInterface<!>
|
||||
|
||||
class Delegated(val bi: BaseInterface) : <!OPT_IN_USAGE_ERROR!>BaseInterface<!> by bi
|
||||
|
||||
+36
-1
@@ -1,6 +1,7 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
public fun test2(/*0*/ b: Base, /*1*/ g: Generic<Base>): kotlin.Unit
|
||||
|
||||
@kotlin.SubclassOptInRequired(markerClass = Marker::class) public open class Base {
|
||||
public constructor Base()
|
||||
@@ -9,6 +10,20 @@ public fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.SubclassOptInRequired(markerClass = Marker::class) public interface BaseInterface {
|
||||
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 final class Delegated : BaseInterface {
|
||||
public constructor Delegated(/*0*/ bi: BaseInterface)
|
||||
public final val bi: BaseInterface
|
||||
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
|
||||
}
|
||||
|
||||
@Marker public final class DerivedFirst : Base {
|
||||
public constructor DerivedFirst()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@@ -23,7 +38,20 @@ public open class DerivedFourth : Base {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.SubclassOptInRequired(markerClass = Marker::class) public final class DerivedMarked : Marked {
|
||||
public final class DerivedGeneric : Generic<Base> {
|
||||
public constructor DerivedGeneric()
|
||||
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 DerivedInterface : BaseInterface {
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.SubclassOptInRequired(markerClass = Marker::class) public open class DerivedMarked : Marked {
|
||||
public constructor DerivedMarked()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -44,6 +72,13 @@ public open class DerivedFourth : Base {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Generic</*0*/ T> {
|
||||
public constructor Generic</*0*/ T>()
|
||||
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 final class GrandDerivedFourth : DerivedFourth {
|
||||
public constructor GrandDerivedFourth()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
Reference in New Issue
Block a user