[Inject] and @Inject

I can't get a new style constructor annotation to compile:

public class Foo [Inject] () {  // compiles

public class Foo @Inject () { // "Error:(9, 28) Kotlin: Expecting 'constructor' keyword")

Hey,

adding the constructor keyword solves this problem:

public class Foo @Inject constructor() {}

This keyword is also useful to encapsulate the primary constructor behind a private keyword

public class Foo private constructor() {}

Reference:

“If you need to annotate the primary constructor of a class, you need to add the constructor keyword to the constructor declaration, and add the annotations before it”, http://kotlinlang.org/docs/reference/annotations.html#usage

More:

Indeed, but isn't the asymmetry between @Inject and [Inject] a bug?

No, it isn't. The old deprecated syntax with "[...]" works as it used to, the new syntax with "@" requires "constructor" as it's supposed to.