String (@NotNull KtTypeReference typeReference) { KtTypeElement typeElement = typeReference.getTypeElement(); assert typeElement != null; return typeElement.accept(new KtVisitor<String, Void>() { @Override public String visitDeclaration(@NotNull KtDeclaration declaration, Void data) { throw new IllegalStateException("This visitor shouldn't be invoked for " + declaration.getClass()); } @Override public String visitUserType(@NotNull KtUserType type, Void data) { KtSimpleNameExpression referenceExpression = type.getReferenceExpression(); assert referenceExpression != null; return referenceExpression.getReferencedName(); } @Override public String visitFunctionType(@NotNull KtFunctionType type, Void data) { return StandardNames.getFunctionName(type.getParameters().size() + (type.getReceiverTypeReference() != null ? 1 : 0)); } @Override public String visitNullableType(@NotNull KtNullableType nullableType, Void data) { KtTypeElement innerType = nullableType.getInnerType(); assert innerType != null : "No inner type: " + nullableType; return innerType.accept(this, null); } @Override public String visitDynamicType(@NotNull KtDynamicType type, Void data) { return "dynamic"; } }, null); }