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

qwert_ukg

12/05/2017, 7:44 AM
can u compile it?
h

holgerbrandl

12/05/2017, 7:45 AM
No
Error:(2, 7) Kotlin: Unresolved reference: DependsOn
To see yourself @Czar @qwert_ukg just add
compile 'com.github.holgerbrandl:kscript-annotations:1.1'
to a project and add a
@file:DependsOn("de.mpicbg.scicomp:kutils:0.4")
somewhere before a
package
statement.
Maybe it’s a compiler bug?
c

Czar

12/05/2017, 10:45 AM
How is DependsOn defined?
Its target should be
AnnotationTarget.FILE
, check here: https://kotlinlang.org/docs/reference/annotations.html
The problem actually can be reproduced more easily by creating a annotation containing class in the toplevel of a project.
To prove that point I’ve created a small test-repo under https://github.com/holgerbrandl/file_target_annotations
@Czar What do you think?
c

Czar

12/05/2017, 1:45 PM
Oh, you have the annotation in different package than your file, you just need to import, and by the way it is really bad idea to use default package. To fix specifically your example add
import MyAnno
after package declaration.
You're right that IJ has some problem here though, it should've suggested to import the annotation. Although if you ask me I'd leave this bug unreported to dissuade people from putting stuff in root package 😄
h

holgerbrandl

12/05/2017, 1:55 PM
Thanks a lot for the nice explanation. I incorrectly assumed that the default package would be inferred from the source root directory structure, but in fact kotlin assumes the root package as default, if no package is specified. That’s why the
import MyAnno
is not need without the package statement.
I agree about avoiding the root package for the annotations implementation.
c

Czar

12/05/2017, 1:59 PM
You're welcome, you can look up Kotlin docs on the matter here: https://kotlinlang.org/docs/reference/packages.html It's quite brief, so won't take much time.
h

holgerbrandl

12/05/2017, 2:02 PM
Still the import should work imho so https://youtrack.jetbrains.com/issue/KT-21630
👍 1
3 Views