diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index 569bfbe7eb4..d9d8aed04f5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -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) ) diff --git a/compiler/testData/diagnostics/tests/implicitNothing.kt b/compiler/testData/diagnostics/tests/implicitNothing.kt index ef43da2e8ea..84235471582 100644 --- a/compiler/testData/diagnostics/tests/implicitNothing.kt +++ b/compiler/testData/diagnostics/tests/implicitNothing.kt @@ -34,3 +34,17 @@ class Klass { val x = y } } + +interface Base { + val x: Int + + fun foo(): String +} + +class Derived : Base { + // Ok for override + + override val x = null!! + + override fun foo() = null!! +} diff --git a/compiler/testData/diagnostics/tests/implicitNothing.txt b/compiler/testData/diagnostics/tests/implicitNothing.txt index 3a4daf0cdbd..6d79c4fdc15 100644 --- a/compiler/testData/diagnostics/tests/implicitNothing.txt +++ b/compiler/testData/diagnostics/tests/implicitNothing.txt @@ -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