Skip to content

Migrate TestElement interface to Kotlin #5959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2023
Merged

Conversation

vlsi
Copy link
Collaborator

@vlsi vlsi commented Jun 2, 2023

Description

This a transparent migration of TestElement interface to Kotiln.

Motivation and Context

Kotlin enables better nullability which is good both for Kotlin (compilation fails if null is passed to a method not expecting null), and Java (Kotlin compiler generates @NotNull annotations, so IDEs show when Java code does not handle nulls properly).

Writing the interface in Kotlin enables the use of operator fun get(property), and operator fun set(property) so it enables better APIs for Kotlin code. See #5946 (comment)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

@vlsi vlsi added this to the 5.6 milestone Jun 2, 2023
@vlsi vlsi force-pushed the testelement_kotlin branch 2 times, most recently from c164460 to d7c339d Compare June 2, 2023 11:24
Comment on lines +252 to +255
/**
* Associates a name with this element.
*/
public var name: String?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if name should be nullable, however, I keep it for backward compatibility

@vlsi vlsi force-pushed the testelement_kotlin branch from d7c339d to 0a39fa1 Compare June 2, 2023 18:28
vlsi added 2 commits June 2, 2023 22:53
…Kotlin

Renaming the file first helps Git to track history better
It enables better control over nullability of the parameters and return types,
and it enables declaring "operator fun get", and "operator fun set" so
TestElements are easier to use in Kotlin.
@vlsi vlsi force-pushed the testelement_kotlin branch from 2ab4b39 to c507e57 Compare June 2, 2023 19:54
…es that contain Kotlin code in src/main

Java's Javadoc can't build documentation for Kotlin code, so we need something else.

Dokka can create documentation for both Kotlin and Java.

See https://kotlinlang.org/docs/dokka-introduction.html
@vlsi vlsi force-pushed the testelement_kotlin branch from c507e57 to 6f5936b Compare June 3, 2023 07:34
@vlsi vlsi merged commit 6f5936b into apache:master Jun 3, 2023
@vlsi vlsi deleted the testelement_kotlin branch June 5, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant