Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save knjname/777891e81dd5a5dd7ba7 to your computer and use it in GitHub Desktop.
Save knjname/777891e81dd5a5dd7ba7 to your computer and use it in GitHub Desktop.
class A {
String u;
A(Object s){
System.out.println("A.new() with " + s);
}
String p(){return "p";}
}
@FunctionalInterface
interface Produce<T> {
T produce();
}
class B extends A {
class C {
C(){}
}
String f;
B(){
// Any of these are not legal.
// super(super.u);
// super(this);
// super(this.f);
// super(sayHello());
// super(new C());
// super(((Produce<String>)(() -> this.f)).produce());
// super(((Produce<String>)(() -> new C())).produce());
// super(new Produce() {
// @Override
// public Object produce() {
// return B.this;
// }
// });
// super(new Produce() {
// @Override
// public Object produce() {
// return B.this.new C();
// }
// });
// super((Produce<C>)C::new);
// super((Produce<C>)super::p);
// Also illegal.
// if(true) super("");
// This is legal.
// super(sayGoodbye());
}
static String sayGoodbye(){
return "see you";
}
String sayHello(){
return "hello";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment