5

when I declare a property in a class as following:

class xx{
    var b:()->Boolean={false}
}

and then decompiled as following:

......

public xxx() {
    this.b = (Function0)null.INSTANCE;
}

......

what does the (Function0)null.INSTANCE stand for? I think it will be :

this.b= new Function0() {
        public final Object invoke() {
                 return false;
         }
};

but it doesn't ,why?

Thanks!

3
  • 3
    Possibly because your decompiler is bad at decompiling. Commented Jul 3, 2017 at 3:38
  • Which decompiler did you use? Can you also post the imports. Commented Jul 3, 2017 at 5:26
  • 1
    AndroidStudio built in:Tools->Kotlin->Show Kotlin Bytecode->Decompile Commented Jul 3, 2017 at 9:32

1 Answer 1

6

Decompiler not showing the correct result: e.g. when doing it with JD-GUI, you get:

final class xx$b$1 extends Lambda implements kotlin.jvm.functions.Function0<Boolean> { 
  public final boolean invoke() { return false; }

  public static final 1 INSTANCE = new 1();
  xx$b$1()
  {
    super(0);
  }
}


public final class xx { 
  // ... getter and setter
  private Function0<Boolean> b = (Function0)xx.b.1.INSTANCE;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @xzwhappy, if this is the solution, please just mark this answer as such. thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.