Unresolved reference println in IntelliJ - kotlin

I'm getting unresolved println errors in Kotlin. The IDE does not recognize the function, I guess. However, when I run the code, it is working perfectly. I don't know what the problem is. I'm new to Kotlin.

Related

error related with v-slot in my IDE, or some other issue

I am working in vue.js and placed this syntax all over the place, everything works as expected, but I cannot get rid of this error all over the place (Unrecognized slot name).
I've read in several places that maany people have the same issue but I haven't found an answer.
Do you know a work around?
Seems to be an unresolved issue with WebStorm IDE. For what it's worth, I've not seen this problem when using Visual Studio Code.

Scratch file not running on IntelliJ IDEA

I am trying to run a Kotlin scratch file in IntelliJ just like you would run a Java scratch file, but it doesn't work.
I created a new Kotlin scratch file, but can't run the code even after attempting the following:
Create a main function and print something inside.
Print something with println outside of the main function.
Create a class with a main function inside and println something.
When I create a new kotlin project, the project runs fine.
The issue happens only with scratch files. I am using kotlin plugin version 1.1.51 on IntelliJ 2017.1
As the screenshot shows, the icon that allows you to run kotlin code doesn't show up on the left of the editor window:
Your observations are correct, and this is a known issue.

IntelliJ IDEA doesn't like a HashMap as delegate

Let's consider the following code:
class MyClass { //Here:IJ says method putAll not implemented
#Delegate
HashMap<String, Integer> map = new HashMap<String, Integer>()
}
hello = new MyClass()
hello.put("x", 1)
println "x=" + hello.get("x")
It works fine when called with Groovy directly on the command line, but IntelliJ IDEA complains about the first line with the following error message:
Method putAll() is not implemented
Any idea why and how to fix it?
I have experienced the same behavior.
What I found was in my IntelliJ project, the class (MyClass) was showing with the .groovy file extension in the Project view. By doing a refactor-->Rename and removing the .groovy extension, the class would then show without the extension in the Project view and the issue was resolved.
The explanation for the issue came when I tried to run the class, which is really a Groovy Script and not just a plain Class. When it compiles, it would encounter an error:
Invalid duplicate class definition, which gave me a hint that I had created what IntelliJ saw as a Class definition, but was really a Groovy script, so IntelliJ, behind the scenes processed the script and created a second, synthetic class for the script.

How to execute a compiled code snipped in Frege online repl

OK, I guess this is a stupid beginners question:
I try to learn Frege through the online repl. For doing so, I though it would be a good idea to paste code examples from Dierk's Real World Frege to the upper right window of the repl, press compile and... ? How do I start this code?
I guess I partly found the answer myself:
the :java command in the command line shows the generated code. Within this code, it is visible that the compiled module is automatically imported, so we don't have to reference it.
Now, if we take the HelloWorld example from the repl, it is simply executed by typing
frege> main
into the left window.
Dierk uses for his examples the syntax
main _ = do
If we now type
frege> main
we only get
:: a -> IO ()
as output. But if we type
frege> main "something"
the repl gives the expected output. While I still don't know what's going on, this helps me with my next steps :-)

Intellij suppress warnings

I'm trying to suppress an instance of a warning in my code. I use the intellij feature alt-enter to add the suppress warning annotation to the method, also tried with the class. But whenever I hit the rebuild button, the warning keeps coming up as if the suppress warning annotation isn't being recognised.
I've read a few answers that suggest disable completely, or you can suppress individual entry using this notation. I know I can disable it completely through settings, but I'd rather just suppress this instance. Does anyone know why it wouldn't be suppressing the warning?
Information:Using Eclipse compiler to compile java sources
Information:Compilation completed successfully with 1 warning in 9 sec
Information:0 errors
Information:1 warning
...TagValidator.java
Warning:(41, 16) java: Type safety: Unchecked cast from java.lang.Object to java.util.List<common.model.Tag>
Method in question:
#SuppressWarnings("unchecked")
#Override
public void validate(Object target, Errors errors) {
logger.entry();
List<Tag> list;
list = (List<Tag>) target;
for (Tag tag : list) {
if (tag.getTag().length() > 30) {
errors.rejectValue("tags", "tags.length");
break;
}
}
logger.exit();
}
This appears to be an issue with the eclipse (ejc) compiler. When the javac compiler is used, no warnings are present upon make/compilation. But if you switch to the eclipse compiler, then you get the warnings. In the (closed) IntelliJ IDEA bug report ecj doesn't use #SuppressWarnings the JetBrains development team indicated that
IDEA uses such suppressions for its own error highlighting, which is compiler-independent. Similarly, it runs external compiler as is, without any interference.
So IDEA isn't doing anything to tell ejc not to use/honor the SuppressWarnings annotations.