Changes to singleton objects?


#1

I have been using M2 for a while and have decided to try to upgrade my project and use the kotlin daily build (3392).

There are two problems that I ran into so far:

http://youtrack.jetbrains.com/issue/KT-2763
It’s a major annoyance, but at least it still builds fine

And the fact that none of my calls to object singleton methods work any more (I get unresolved reference errors).
Is that a bug or was something changed in object singletons since M2?


#2

Hi,

Unfortunately, the Android stuf seems to be broken on the IntelliJ side, and we are working with IDEA people to fix it.

Regarding the singltone objects. This code works fine for me:

``

object A {
  fun foo() {}
}

fun foo() {
  A.foo()
}


Could you clarify your report? Thanks.

#3

I have narrowed down the problem to the use of library.

Here are my findings:

I have two files:

obj.kt

package pkg1

public object Singleton {
  public fun m1(): Boolean = true
}

test.kt

package pkg2

public class TestClass {
  public fun m1(): Unit {
  Singleton.method1()
  }
}

As long as obj.kt and test.kt are in the same module, there’s no problem.

But if I have two modules (intelliJ idea modules), Module1 and Module2
Module1 has obj.kt
Module2 depends on Module1 and has obj.kt
Then it can’'t find Singleton.m1()


#4

Hi,

It seems that this issue is related to http://youtrack.jetbrains.com/issue/KT-1973

Did it work for you in M2?


#5

No, with M2 there were more things that got broken when using modules, so I simply made ntfs junctions to avoid duplicating my code. Not having to do that was one of my main reason for trying to move to the daily builds.

I have entered a bug report:
http://youtrack.jetbrains.com/issue/KT-2806


#6

We didn't manage to cover this problem in M3. Will fix soo, you can star the issue to know when it's fixed.