0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IntelliJのScalaコンパイラで、挙動が怪しい部分

Last updated at Posted at 2018-06-06

環境

  • Scala 2.12.5
  • IntelliJ IDEA 2018.1 (Community Edition)
  • JRE: 1.8.0_152-release-1136-b20 amd64

for式のジェネレータ部分にリテラル識別子を使うと、IntelliJの構文チェックツールではエラーだが、ビルド&実行ができる

for式のジェネレータ部分に、リテラル識別子を使いました。

def sampleOpt(i: Int): Option[Int] = Some(i)

val a = for (
  `type` <- sampleOpt(10)
) yield `type` * 2
println("a=" + a) //⇒ a=Sample(20)

IntelliJ IDEAのエディタウィンドウでは、"Cannot resolve symbol `type"というエラーが表示されました。
image.png

しかし、ビルド&実行はできました。

build.sbtの設定が間違っていても、別モジュールのテストクラスを参照できてしまう。

作成中

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?