Open KadenGordon opened 6 years ago
Update: Similar errors happen with Boolean and Double also. If I assign 0.375 to a double, for instance, it says "The floating-point literal does not conform to the expected type Double".
@KadenGordon This seems to be an issue where the language server can't locate your Kotlin standard library for some reason. Could you please post the output log of the language server?
This is what happens after hovering over a couple random things.
[INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 278:59 [INFO] async0 main Re-parsing DriveMotorSystem.kt 278:5-279:150 [INFO] async0 main Hovering DOT_QUALIFIED_EXPRESSION [INFO] async0 main Finished in 27 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 287:62 [INFO] async0 main Re-parsing DriveMotorSystem.kt 287:56-288:66 [INFO] async0 main Couldn't find expression at DriveMotorSystem.kt 288:63 [INFO] async0 main Re-parsing DriveMotorSystem.kt 287:56-288:66 [INFO] async0 main No hover found at DriveMotorSystem.kt 288:63 [INFO] async0 main Finished in 6 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 280:61 [INFO] async0 main Re-parsing DriveMotorSystem.kt 280:53-281:63 [INFO] async0 main Couldn't find expression at DriveMotorSystem.kt 281:62 [INFO] async0 main Re-parsing DriveMotorSystem.kt 280:53-281:63 [INFO] async0 main No hover found at DriveMotorSystem.kt 281:62 [INFO] async0 main Finished in 6 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 294:41 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:41-295:51 [INFO] async0 main Couldn't find expression at DriveMotorSystem.kt 295:42 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:41-295:51 [INFO] async0 main No hover found at DriveMotorSystem.kt 295:42 [INFO] async0 main Finished in 7 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 294:40 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:41-295:51 [INFO] async0 main Couldn't find expression at DriveMotorSystem.kt 295:41 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:41-295:51 [INFO] async0 main No hover found at DriveMotorSystem.kt 295:41 [INFO] async0 main Finished in 8 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 294:41 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:41-295:51 [INFO] async0 main Couldn't find expression at DriveMotorSystem.kt 295:42 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:41-295:51 [INFO] async0 main No hover found at DriveMotorSystem.kt 295:42 [INFO] async0 main Finished in 8 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 296:29 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:5-300:6 [INFO] async0 main Hovering REFERENCE_EXPRESSION [INFO] async0 main Finished in 24 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 295:27 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:5-300:6 [INFO] async0 main Hovering REFERENCE_EXPRESSION [INFO] async0 main Finished in 25 ms [INFO] async0 main Hovering at file:///home/kaden/Desktop/RoverRuckus/Library/src/main/java/org/BeehiveRobotics/Library/Systems/DriveMotorSystem.kt 294:70 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:65-295:75 [INFO] async0 main Couldn't find expression at DriveMotorSystem.kt 295:71 [INFO] async0 main Re-parsing DriveMotorSystem.kt 294:65-295:75 [INFO] async0 main No hover found at DriveMotorSystem.kt 295:71 [INFO] async0 main Finished in 7 ms
@KadenGordon I suspect there is an issue with your project layout:
src/main/java/.../DriveMotorSystem.kt
Your Kotlin source files should be placed in src/main/kotlin
instead.
@fwcd I'm seeing this same issue. Not sure that it's the wrong directory though - Android Studio at least seems to create new Android Kotlin projects in the src/main/java directory. It's definitely counter intuitive
You can read more at https://developer.android.com/studio/projects/add-kotlin but here's the relevant part
By default, new Kotlin files are saved into src/main/java/. You might find it's easier to see both Kotlin and Java files in one location.
What's interesting is I haven't touched the project or anything Kotlin for a couple weeks, and it still builds successfully. I'll try renaming directories though, and see how that works.
I renamed directories, and it still has all those errors
Update: The newest version of VS Code did not fix the problem either
+1 I believe Intellij puts Kotlin files under src/main/java.
Either way, I still can't find anything more about the problem
Hi, I seem to have found a workaround for this issue, and have described it here.
This seems to be related to how primitive types are resolved when using the JDK7/8 - specific Kotlin standard library. To me it seems like JDK-specific standard libraries cause a confusion between Kotlin and Java primitives types.
Hope this is useful as a temporary solution, or as a way for someone to figure out the root of the problem. :)
Whenever I attempt to use the 'String' class, it shows it as one of a couple errors shown below.
This is when I call the String class, like for declaring parameters
This is when I call a Java function that takes a String as a parameter
My project builds just fine with Gradle, and it happens on all my dozens of file.. I have not edited anything for a couple weeks and came back to work on it and saw this.