'Nothing' as function return type and property type can't be abbreviated.
This commit is contained in:
@@ -766,6 +766,8 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<PsiElement> IMPLICIT_NOTHING_RETURN_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> IMPLICIT_NOTHING_PROPERTY_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ABBREVIATED_NOTHING_RETURN_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ABBREVIATED_NOTHING_PROPERTY_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> IMPLICIT_INTERSECTION_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Context tracking
|
||||
|
||||
+2
@@ -563,6 +563,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(INCOMPATIBLE_TYPES, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE);
|
||||
MAP.put(IMPLICIT_NOTHING_RETURN_TYPE, "'Nothing' return type needs to be specified explicitly");
|
||||
MAP.put(IMPLICIT_NOTHING_PROPERTY_TYPE, "'Nothing' property type needs to be specified explicitly");
|
||||
MAP.put(ABBREVIATED_NOTHING_RETURN_TYPE, "'Nothing' return type can't be specified with type alias");
|
||||
MAP.put(ABBREVIATED_NOTHING_PROPERTY_TYPE, "'Nothing' property type can't be specified with type alias");
|
||||
MAP.put(IMPLICIT_INTERSECTION_TYPE, "Inferred type {0} is an intersection, please specify the required type explicitly", RENDER_TYPE);
|
||||
MAP.put(EXPECTED_CONDITION, "Expected condition of type Boolean");
|
||||
|
||||
|
||||
@@ -718,8 +718,8 @@ class DeclarationsChecker(
|
||||
|
||||
private fun checkImplicitCallableType(declaration: KtCallableDeclaration, descriptor: CallableDescriptor) {
|
||||
descriptor.returnType?.let {
|
||||
val target = declaration.nameIdentifier ?: declaration
|
||||
if (declaration.typeReference == null) {
|
||||
val target = declaration.nameIdentifier ?: declaration
|
||||
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)
|
||||
@@ -729,6 +729,11 @@ class DeclarationsChecker(
|
||||
trace.report(IMPLICIT_INTERSECTION_TYPE.on(target, it))
|
||||
}
|
||||
}
|
||||
else if (it.isNothing() && it is AbbreviatedType) {
|
||||
trace.report(
|
||||
(if (declaration is KtProperty) ABBREVIATED_NOTHING_PROPERTY_TYPE else ABBREVIATED_NOTHING_RETURN_TYPE).on(target)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
typealias N = Nothing
|
||||
|
||||
fun <!ABBREVIATED_NOTHING_RETURN_TYPE!>testFun<!>(): N = null!!
|
||||
val <!ABBREVIATED_NOTHING_PROPERTY_TYPE!>testVal<!>: N = null!!
|
||||
val <!ABBREVIATED_NOTHING_PROPERTY_TYPE!>testValWithGetter<!>: N get() = null!!
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public typealias N = kotlin.Nothing
|
||||
public val testVal: N [= kotlin.Nothing]
|
||||
public val testValWithGetter: N [= kotlin.Nothing]
|
||||
public fun testFun(): N [= kotlin.Nothing]
|
||||
@@ -19605,6 +19605,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("returnTypeNothingShouldBeSpecifiedExplicitly.kt")
|
||||
public void testReturnTypeNothingShouldBeSpecifiedExplicitly() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/returnTypeNothingShouldBeSpecifiedExplicitly.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleTypeAlias.kt")
|
||||
public void testSimpleTypeAlias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/simpleTypeAlias.kt");
|
||||
|
||||
Reference in New Issue
Block a user