Created
May 8, 2014 21:37
-
-
Save uehaj/289be3873ddee225b5e5 to your computer and use it in GitHub Desktop.
multi method and Static groovy(TypeChecked, CompileStatic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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