OK, I’m confused. I have this method defined (in ...
# getting-started
l
OK, I’m confused. I have this method defined (in a test class):
Copy code
fun fakeThingie() = object : AThingieInterface {
  override fun doSomething(): Boolean = false
}
The documentation says this is the correct syntax for an anonymous class: https://kotlinlang.org/docs/object-declarations.html However, my IDE is yelling at me that “object” is not a valid keyword in Kotlin and I should use Any. Er, what? And yet the code does run; the IDE is just yelling at me, and there’s a bunch of warnings when running tests, but the relevant tests all pass. What is going on? Edit: Wow, never mind. The mock class was missing a method from the interface. So of course the IDE was reporting it as a keyword issue. Because that makes total sense. /s
d
That's quite strange. If you didn't implemented all the interface methods the code shouldn't even compile, IDE or not.
c
Can you reproduce it on https://play.kotlinlang.org/?
j
@Larry Garfield are you sure you didn't also have a syntax error somewhere? I can't reproduce what you're saying neither in the playground nor in the IDE. In both cases, the error is clearly reported that a member is missing: https://pl.kotl.in/PJQXwsmEE
l
The only errors I saw of any kind where it objecting to “object” when there was a missing method, and then the missing method. No other errors were reported, and tests were running despite that. I have no explanation.
j
Do you have a snippet that reproduces the problem?
l
I do not. I fixed it last night and it hasn’t reappeared.
I think I’m going to chalk this one up to gremlins for now. Not sure what else to do with it. 😕
j
Oh, ok. I tried to make random changes to see what could produce the error you mention (like capitalizing
Object
), but to no avail 😞 If one day you run into this again, please let me know how 🙏
👍 1