blob: a7bdc867af1b045f56f1e1ad59321b7d057994bc [file] [log] [blame]
package groovy
import gls.CompilableTestSupport
class StaticThisTest extends CompilableTestSupport {
void testThisFail() {
staticMethod()
}
static def staticMethod() {
def foo = this
assert foo != null
assert foo.name.endsWith("StaticThisTest")
def s = super
assert s != null
assert s.name.endsWith("CompilableTestSupport")
}
void testThisPropertyInStaticMethodShouldNotCompile() {
shouldNotCompile """
class A {
def prop
static method(){
this.prop
}
}
"""
}
void testSuperPropertyInStaticMethodShouldNotCompile() {
shouldNotCompile """
class A { def prop }
class B extends A {
static method(){
super.prop
}
}
"""
}
}