@Override
        public PsiType fun(GrMethodBaseImpl method) {
          PsiType nominal = method.getNominalType();
          if (nominal != null) {
            if (!(nominal instanceof PsiClassType
                && hasTypeParametersToInfer((PsiClassType) nominal))) {
              return nominal;
            }
          }

          if (!GppTypeConverter.hasTypedContext(method)) {
            LOG.assertTrue(method.isValid(), "invalid method");

            final GrOpenBlock block = method.getBlock();
            if (block != null) {
              LOG.assertTrue(block.isValid(), "invalid code block");
              PsiType inferred =
                  GroovyPsiManager.inferType(method, new MethodTypeInferencer(block));
              if (inferred != null) {
                if (nominal == null || nominal.isAssignableFrom(inferred)) {
                  return inferred;
                }
              }
            }
          }
          if (nominal != null) {
            return nominal;
          }

          return TypesUtil.getJavaLangObject(method);
        }