Expression is inaccessible from a nested class


#1

Hello.

Could you please explain the difference between code fragments:

Compiles and works well:

class Test(val value: Int) {
  class object {
  fun create(init: () -> Int): Test {
           return Test(init.invoke())
  }
  }
}


Failes with “Expression is inaccessible from a nested class ‘<class-object-for-Test>’, use ‘inner’ keyword to make the class inner” on init()

class Test(val value: Int) {
  class object {
  fun create(init: () -> Int): Test {
           return Test(init())
  }
  }
}

Thanks, Alexey


#2

The explanation is rather simple: it's a bug :) Please, report to the tracker. Thanks


#3

Done: KT-3647