java: receiver parameter highlighting

This commit is contained in:
Roman Shevchenko
2015-07-02 15:29:22 +03:00
parent e737db6dcc
commit fd0061d246
10 changed files with 182 additions and 81 deletions

View File

@@ -0,0 +1,47 @@
import java.lang.annotation.*;
@interface A { }
@Target(ElementType.TYPE_USE)
@interface TA { }
class C {
@Override
public String toString(@TA C this) { return ""; }
@Override
public boolean equals(@TA C this, @TA Object other) { return false; }
@interface Anno { String f(Anno this); }
void m0() {
try (Object <error descr="Receivers are not allowed outside of method parameter list">this</error>) { }
Runnable r = (C <error descr="Receivers are not allowed outside of method parameter list">C.this</error>) -> { };
}
void m1a(<error descr="Modifier 'final' not allowed here">final</error> C this) { }
void m1b(<error descr="'@A' not applicable to type use">@A</error> C this) { }
void m2(@TA Object other, @TA C <error descr="The receiver should be the first parameter">this</error>) { }
void m3a(@TA <error descr="The receiver type does not match the enclosing class type">Object</error> this) { }
void m3b(@TA <error descr="The receiver type does not match the enclosing class type">int</error> this) { }
void m4a(C C.this) { }
void m4b(C <error descr="The receiver name does not match the enclosing class type">C.X.this</error>) { }
static void sm1(@TA Object <error descr="The receiver cannot be used in a static context">this</error>) { }
C(C <error descr="The receiver cannot be used in a static context">this</error>) { }
static class X {
X(X <error descr="The receiver cannot be used in a static context">this</error>) { }
}
class B {
B(C C.this) { }
B(<error descr="The receiver type does not match the enclosing class type">B</error> C.this, int p) { }
B(C <error descr="The receiver name does not match the enclosing class type">B.this</error>, long p) { }
B(C <error descr="The receiver name does not match the enclosing class type">this</error>, float p) { }
}
}