@@ -171,11 +171,7 @@ internal class UltraLightMembersCreator(
171
171
val returnType: PsiType ? by lazyPub {
172
172
when {
173
173
isConstructor -> null
174
- isSuspendFunction -> support.moduleDescriptor
175
- .builtIns
176
- .nullableAnyType
177
- .asPsiType(support, TypeMappingMode .DEFAULT , wrapper)
178
- else -> methodReturnType(ktFunction, wrapper)
174
+ else -> methodReturnType(ktFunction, wrapper, isSuspendFunction)
179
175
}
180
176
}
181
177
@@ -188,7 +184,20 @@ internal class UltraLightMembersCreator(
188
184
method.delegate.addParameter(KtUltraLightReceiverParameter (callable, support, method))
189
185
}
190
186
191
- private fun methodReturnType (ktDeclaration : KtDeclaration , wrapper : KtUltraLightMethod ): PsiType {
187
+ private fun methodReturnType (ktDeclaration : KtDeclaration , wrapper : KtUltraLightMethod , isSuspendFunction : Boolean ): PsiType {
188
+
189
+ if (isSuspendFunction) {
190
+ return support.moduleDescriptor
191
+ .builtIns
192
+ .nullableAnyType
193
+ .asPsiType(support, TypeMappingMode .DEFAULT , wrapper)
194
+ }
195
+
196
+ if (ktDeclaration is KtNamedFunction &&
197
+ ktDeclaration.hasBlockBody() &&
198
+ ! ktDeclaration.hasDeclaredReturnType()
199
+ ) return PsiType .VOID
200
+
192
201
val desc =
193
202
ktDeclaration.resolve()?.getterIfProperty() as ? FunctionDescriptor
194
203
? : return PsiType .NULL
@@ -359,7 +368,7 @@ internal class UltraLightMembersCreator(
359
368
val getterName = computeMethodName(ktGetter ? : declaration, JvmAbi .getterName(propertyName), MethodType .GETTER )
360
369
val getterPrototype = lightMethod(getterName, ktGetter ? : declaration, onlyJvmStatic || forceStatic)
361
370
val getterWrapper = KtUltraLightMethodForSourceDeclaration (getterPrototype, declaration, support, containingClass)
362
- val getterType: PsiType by lazyPub { methodReturnType(declaration, getterWrapper) }
371
+ val getterType: PsiType by lazyPub { methodReturnType(declaration, getterWrapper, isSuspendFunction = false ) }
363
372
getterPrototype.setMethodReturnType { getterType }
364
373
addReceiverParameter(declaration, getterWrapper)
365
374
result.add(getterWrapper)
0 commit comments