@@ -202,6 +202,34 @@ object MethodResolveProcessor {
202
202
}
203
203
204
204
def checkFunction (fun : PsiNamedElement ): ConformanceExtResult = {
205
+ def default (): ConformanceExtResult = {
206
+ fun match {
207
+ case fun : ScFunction if fun.paramClauses.clauses.isEmpty ||
208
+ fun.paramClauses.clauses.head.parameters.isEmpty ||
209
+ isUnderscore => ConformanceExtResult (problems)
210
+ case fun : ScFun if fun.paramClauses == Seq () || fun.paramClauses == Seq (Seq ()) || isUnderscore =>
211
+ addExpectedTypeProblems()
212
+ ConformanceExtResult (problems)
213
+ case method : PsiMethod if method.getParameterList.getParameters.isEmpty ||
214
+ isUnderscore =>
215
+ addExpectedTypeProblems()
216
+ ConformanceExtResult (problems)
217
+ case _ =>
218
+ addExpectedTypeProblems()
219
+ problems += MissedParametersClause (null )
220
+ ConformanceExtResult (problems)
221
+ }
222
+ }
223
+
224
+ def processFunctionType (retType : ScType , params : Seq [ScType ]): ConformanceExtResult = {
225
+ val args = params.map(new Expression (_))
226
+ val result = Compatibility .compatible(fun, substitutor, List (args), checkWithImplicits = false ,
227
+ scope = ref.getResolveScope, isShapesResolve = isShapeResolve)
228
+ problems ++= result.problems
229
+ addExpectedTypeProblems(Some (retType))
230
+ result.copy(problems)
231
+ }
232
+
205
233
fun match {
206
234
case fun : ScFunction if fun.paramClauses.clauses.isEmpty =>
207
235
addExpectedTypeProblems()
@@ -213,30 +241,13 @@ object MethodResolveProcessor {
213
241
}
214
242
215
243
expectedOption().map(_.removeAbstracts) match {
216
- case Some (ScFunctionType (retType, params)) =>
217
- val args = params.map(new Expression (_))
218
- val result = Compatibility .compatible(fun, substitutor, List (args), checkWithImplicits = false ,
219
- scope = ref.getResolveScope, isShapesResolve = isShapeResolve)
220
- problems ++= result.problems
221
- addExpectedTypeProblems(Some (retType))
222
- result.copy(problems)
223
- case _ =>
224
- fun match {
225
- case fun : ScFunction if fun.paramClauses.clauses.isEmpty ||
226
- fun.paramClauses.clauses.head.parameters.isEmpty ||
227
- isUnderscore => ConformanceExtResult (problems)
228
- case fun : ScFun if fun.paramClauses == Seq () || fun.paramClauses == Seq (Seq ()) || isUnderscore =>
229
- addExpectedTypeProblems()
230
- ConformanceExtResult (problems)
231
- case method : PsiMethod if method.getParameterList.getParameters.isEmpty ||
232
- isUnderscore =>
233
- addExpectedTypeProblems()
234
- ConformanceExtResult (problems)
235
- case _ =>
236
- addExpectedTypeProblems()
237
- problems += MissedParametersClause (null )
238
- ConformanceExtResult (problems)
244
+ case Some (ScFunctionType (retType, params)) => processFunctionType(retType, params)
245
+ case Some (tp : ScType ) if ScalaPsiUtil .isSAMEnabled(fun) =>
246
+ ScalaPsiUtil .toSAMType(tp, fun.getResolveScope) match {
247
+ case Some (ScFunctionType (retType, params)) => processFunctionType(retType, params)
248
+ case _ => default()
239
249
}
250
+ case _ => default()
240
251
}
241
252
}
242
253
0 commit comments