remove requirements for explicit return type for public members
This commit is contained in:
@@ -42,7 +42,7 @@ public class SpecifyTypeExplicitlyIntention : JetSelfTargetingIntention<JetCalla
|
||||
if (element is JetConstructor<*>) return false
|
||||
if (element.getTypeReference() != null) return false
|
||||
|
||||
if (getTypeForDeclaration(element).isError() || hasPublicMemberDiagnostic(element)) return false
|
||||
if (getTypeForDeclaration(element).isError()) return false
|
||||
|
||||
val initializer = (element as? JetWithExpressionInitializer)?.getInitializer()
|
||||
if (initializer != null && initializer.getTextRange().containsOffset(caretOffset)) return false
|
||||
@@ -54,11 +54,6 @@ public class SpecifyTypeExplicitlyIntention : JetSelfTargetingIntention<JetCalla
|
||||
return true
|
||||
}
|
||||
|
||||
private fun hasPublicMemberDiagnostic(declaration: JetNamedDeclaration): Boolean {
|
||||
return declaration.analyze().getDiagnostics().forElement(declaration)
|
||||
.any { it.getFactory() == Errors.PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE }
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetCallableDeclaration, editor: Editor) {
|
||||
val type = getTypeForDeclaration(element)
|
||||
addTypeAnnotation(editor, element, type)
|
||||
|
||||
@@ -172,7 +172,6 @@ public class QuickFixRegistrar : QuickFixContributor {
|
||||
UNNECESSARY_NOT_NULL_ASSERTION.registerFactory(RemoveExclExclCallFix)
|
||||
UNSAFE_INFIX_CALL.registerFactory(ReplaceInfixCallFix)
|
||||
|
||||
PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE.registerActions(SpecifyTypeExplicitlyFix())
|
||||
AMBIGUOUS_ANONYMOUS_TYPE_INFERRED.registerActions(SpecifyTypeExplicitlyFix())
|
||||
|
||||
ELSE_MISPLACED_IN_WHEN.registerFactory(MoveWhenElseBranchFix.createFactory())
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// "Specify type explicitly" "false"
|
||||
// ACTION: Convert property to function
|
||||
// ERROR: Public or protected member should have specified type
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
class A() {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Specify type explicitly" "true"
|
||||
// ERROR: Public or protected member should have specified type
|
||||
|
||||
package a
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Specify type explicitly" "true"
|
||||
// ERROR: Public or protected member should have specified type
|
||||
|
||||
package a
|
||||
|
||||
|
||||
Reference in New Issue
Block a user