Worksheet error on import statement

With following worksheet content

------

import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration._

import scala.concurrent.ExecutionContext.Implicits.global

val f = Future { "Hello!"}
println(Await.ready(f, 1.minute))

------

I get import errors. Not sure why the unused import error is being reported

-----

/home/user/.IntelliJIdea2017.3/config/scratches/scratch_15.scala
Error:Error:line (13)Unused import
println(MacroPrinter211.printImportInfo({import scala.concurrent.Future;}))
^
Error:Error:line (15)Unused import
println(MacroPrinter211.printImportInfo({import scala.concurrent.Await;}))
^
Error:Error:line (17)Unused import
println(MacroPrinter211.printImportInfo({import scala.concurrent.duration._;}))
^
Error:Error:line (20)Unused import
println(MacroPrinter211.printImportInfo({import scala.concurrent.ExecutionContext.Implicits.global;}))
^

----

This project uses Scala 2.11, 

IntelliJ IDEA 2017.3.4 (Ultimate Edition)
Build #IU-173.4548.28, built on January 30, 2018
JRE: 1.8.0_152-release-1024-b11 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 3.13.0-135-generic

 

1 comment
Comment actions Permalink

Looks like its because Scala Compiler config in my Gradle is set to "warn-unused-import" which is implicitly being applied to console/worksheet. 

 

gradle.ext.scala = [
version: '2.11.11',
compileFlags: ['-feature', '-unchecked', '-deprecation', '-Xfatal-warnings', '-Ywarn-unused-import']
]

 

So removing them from Compiler Config in Intellij settings help to make worksheet work. Probably Intellij should remove these flag when using compiler for worksheet evaluation

 

0

Please sign in to leave a comment.