<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58504>58504</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] FunctionOpInterfaceTrait::getFunctionType() cause compile error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          RIvance
      </td>
    </tr>
</table>

<pre>
    Hi!

When I was trying to reproduce the `FuncOp` operator in the [Toy example Ch2](https://github.com/llvm/llvm-project/tree/main/mlir/examples/toy/Ch2), I got a compile error:
```
/path/to/project/build/include/Toy/ToyOps.h.inc:202:32: error: ‘class mlir::Type’ has no member named ‘getInputs’
  202 |       return getFunctionType().getInputs();
      |                                ^~~~~~~~~
```
Finding out that `FunctionOpInterfaceTrait::getFunctionType()` returns `mlir::Type` instead of `mlir::FunctionType`, I tried to change the [code in `CH2/include/toy/Ops.td`](https://github.com/llvm/llvm-project/blob/main/mlir/examples/toy/Ch2/include/toy/Ops.td#L151) from
```
llvm::ArrayRef<mlir::Type> getArgumentTypes() 

    return getFunctionType().getInputs();
}
```
to 
```
llvm::ArrayRef<mlir::Type> getArgumentTypes() 

    return getFunctionType().cast<mlir::FunctionType>().getInputs();
}
```
this error is gone, but another has appeared:
```
/path/to/llvm/build/tools/mlir/include/mlir/IR/FunctionOpInterfaces.h.inc:521:67: error: ‘class mlir::Type’ has no member named ‘clone’
  521 |       return (*static_cast<ConcreteOp *>(this)).getFunctionType().clone(inputs, results);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
```
It seems still an issue with the return type of `FunctionOpInterfaceTrait::getFunctionType()` since `mlir::FunctionType` does have a `clone()` method but `mlir::Type` does not.

This is the environment I was using when this issue occurred:
```
OS: Arch Linux x86_64
Kernel: linux-6.0.2
Compiler: clang 14.0.6 x86_64-pc-linux-gnu
LLVM & MLIR: 15.0.2 git
Options when compile LLVM & MLIR:
     -DLLVM_ENABLE_PROJECTS=mlir \
     -DLLVM_BUILD_EXAMPLES=ON \
     -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
     -DCMAKE_BUILD_TYPE=Debug \
     -DLLVM_ENABLE_ASSERTIONS=ON \
     -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON \
     -DLLVM_CCACHE_BUILD=OFF \
     -DLLVM_USE_SANITIZER="Address;Undefined"
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVl9v4jgQ_zThxSpKHAjwwEMI6ZZbKAjSvd69IJMMJKdgR7bTlm9_4ySUhcKqV93DRpadZMbzz78Zz0Ykh-FDZlHHsseW7dfznylwMiGvTBEtDxnfES2IhEKKpIyB6BSI5dn3JY_nBb4QUYBkWkiS8ZrYHUXiQOCN7YscSJBSqzu2aD_VulCW61v0Hscu02m5acdijx95_nJc7lDPPxBr_NQSAJc9y7hZ8kzi0ohVhi4OOBv5dGDRAG3eCU0YQZlFhppBSiGNwto5z25G_UnvC6bTSox5f9e6KbM8wTXjcV4mxoCo0oPzvFDttI0EFEptirNrpndFxAqp1betQT_OmVKkMhn1u350KOBIHJAUQ8sF2cN-A5JwtofktHUHesKLUqt3_tpgQlAlsXoBqR8JupScILs5Cp0JXimhfYxG-ySk-rbc0VGIeU5Cbj5WN7R6N8a1cGK4EgMVUWoEAdNHiBi75sWEa5BbFkMkWabrkFw13OCpdkwZCRcBRGLGlQaWELE9p5-JQqMqOGiZYWQRvXHK-A6O6IxFAgasyBc80LOjriFlzlknRszXgLvJxeaTwL2lm7pTp-tgRMhWoqZrIa90V877UrLDEraWG1xEzA0NQHy5K_fAtfnVIII0InsjckLGlyBl9cZXzcOw_w5mx0zpMwVnPG74Ve_STNV5T_BlJzgYyG0Q_YwLxJmskpwVBTAJySeLUIOmYw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