KT-11666: Implicit nothing is allowed for overridden function / properties
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4c03aaabd4
commit
8c131f4790
@@ -705,7 +705,7 @@ class DeclarationsChecker(
|
||||
descriptor.returnType?.let {
|
||||
if (declaration.typeReference == null) {
|
||||
val target = declaration.nameIdentifier ?: declaration
|
||||
if (it.isNothing()) {
|
||||
if (it.isNothing() && !declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
trace.report(
|
||||
(if (declaration is KtProperty) IMPLICIT_NOTHING_PROPERTY_TYPE else IMPLICIT_NOTHING_RETURN_TYPE).on(target)
|
||||
)
|
||||
|
||||
@@ -34,3 +34,17 @@ class Klass {
|
||||
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>x<!> =<!> y
|
||||
}
|
||||
}
|
||||
|
||||
interface Base {
|
||||
val x: Int
|
||||
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
// Ok for override
|
||||
|
||||
override val x = null!!
|
||||
|
||||
override fun foo() = null!!
|
||||
}
|
||||
|
||||
@@ -8,6 +8,23 @@ public fun check(): kotlin.Unit
|
||||
public fun foo(): kotlin.Nothing
|
||||
public fun gav(): kotlin.Any
|
||||
|
||||
public interface Base {
|
||||
public abstract val x: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Derived : Base {
|
||||
public constructor Derived()
|
||||
public open override /*1*/ val x: kotlin.Nothing
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun foo(): kotlin.Nothing
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Klass {
|
||||
public constructor Klass()
|
||||
public final val y: kotlin.Nothing
|
||||
|
||||
Reference in New Issue
Block a user