Skip to content

Instantly share code, notes, and snippets.

@uehaj
Created May 8, 2014 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uehaj/289be3873ddee225b5e5 to your computer and use it in GitHub Desktop.
Save uehaj/289be3873ddee225b5e5 to your computer and use it in GitHub Desktop.
multi method and Static groovy(TypeChecked, CompileStatic)
class Sample {
def test(String strParam) {
println "String = $strParam"
}
def test(Integer intParam) {
println "int = $intParam"
}
}
@groovy.transform.TypeChecked
def foo(Object param1, Object param2) {
def sample = new Sample()
sample.test(param1) // [Static type checking] - Cannot find matching method Sample#test(java.lang.Object). Please check if the declared type is right and if the method exists.
sample.test(param2) // [Static type checking] - Cannot find matching method Sample#test(java.lang.Object). Please check if the declared type is right and if the method exists.
}
foo("test2", 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment