getType

open fun getType(node: Node): ResolvedType(source)

Get the type associated with the node.

This method was originally intended to get the type of a value: any value has a type.

For example:

int foo(int a) {
    return a; // when getType is invoked on "a" it returns the type "int"
}

Now, users started using also of names of types itself, which do not have a type.

For example:

class A {
    int foo(int a) {
        return A.someStaticField; // when getType is invoked on "A", which represents a class, it returns
            // the type "A" itself while it used to throw UnsolvedSymbolException
}

To accommodate this usage and avoid confusion this method return the type itself when used on the name of type.


open fun getType(node: Node, solveLambdas: Boolean): ResolvedType(source)