https://kotlinlang.org logo
#announcements
Title
# announcements
m

marcinmoskala

06/21/2017, 9:25 AM
And if you decompile code from your first question, you will get answer why variable 'map' is not initialized. Delegates are set before map. I am not sure why.
Copy code
public final class User {
   @NotNull
   private final Map map;
   @NotNull
   private final Map name$delegate;
   @NotNull
   private final Map age$delegate;
   // $FF: synthetic field
   static final KProperty[] $$delegatedProperties = new KProperty[]{(KProperty)Reflection.property1(new PropertyReference1Impl(Reflection.getOrCreateKotlinClass(User.class), "name", "getName()Ljava/lang/String;")), (KProperty)Reflection.property1(new PropertyReference1Impl(Reflection.getOrCreateKotlinClass(User.class), "age", "getAge()I"))};

   @NotNull
   public final Map getMap() {
      return this.map;
   }

   @NotNull
   public final String getName() {
      Map var1 = this.name$delegate;
      KProperty var3 = $$delegatedProperties[0];
      return (String)MapsKt.getOrImplicitDefaultNullable(var1, var3.getName());
   }

   public final int getAge() {
      Map var1 = this.age$delegate;
      KProperty var3 = $$delegatedProperties[1];
      return ((Number)MapsKt.getOrImplicitDefaultNullable(var1, var3.getName())).intValue();
   }

   public User(@NotNull Map map) {
      Intrinsics.checkParameterIsNotNull(map, "map");
      super();
      this.name$delegate = this.map;
      this.age$delegate = this.map;
      this.map = map;
   }
}
5 Views