Using else instead of yield after for comprehension causes NPE

Snippet to reproduce:

object BugTest {
  for {
    x <- 1 to 10
    y <- 1 to 10
  } else { }
}


Save, then try to reopen.

java.lang.NullPointerException      at org.jetbrains.plugins.scala.lang.formatting.getDummyBlocks$.addTail$1(getDummyBlocks.scala:498)      at org.jetbrains.plugins.scala.lang.formatting.getDummyBlocks$.getForSubBlocks(getDummyBlocks.scala:507)      at org.jetbrains.plugins.scala.lang.formatting.getDummyBlocks$.applyInner(getDummyBlocks.scala:74)      at org.jetbrains.plugins.scala.lang.formatting.getDummyBlocks$.apply(getDummyBlocks.scala:44)      at org.jetbrains.plugins.scala.lang.formatting.ScalaBlock.getSubBlocks(ScalaBlock.scala:131)      at com.intellij.psi.formatter.common.NewLineBlocksIterator.a(NewLineBlocksIterator.java:115)      at com.intellij.psi.formatter.common.NewLineBlocksIterator.next(NewLineBlocksIterator.java:86)      at com.intellij.psi.codeStyle.autodetect.FormatterBasedLineIndentInfoBuilder.a(FormatterBasedLineIndentInfoBuilder.java:133)      at com.intellij.psi.codeStyle.autodetect.FormatterBasedLineIndentInfoBuilder.build(FormatterBasedLineIndentInfoBuilder.java:49)      at com.intellij.psi.codeStyle.autodetect.IndentOptionsDetectorImpl.a(IndentOptionsDetectorImpl.java:73)      at com.intellij.psi.codeStyle.autodetect.IndentOptionsDetectorImpl.getIndentOptions(IndentOptionsDetectorImpl.java:56)      at com.intellij.psi.codeStyle.autodetect.DetectableIndentOptionsProvider.getIndentOptions(DetectableIndentOptionsProvider.java:56)      at com.intellij.psi.codeStyle.CodeStyleSettings.getIndentOptionsByFile(CodeStyleSettings.java:672)      at com.intellij.psi.codeStyle.CodeStyleSettingsManager.updateDocumentIndentOptions(CodeStyleSettingsManager.java:145)      at com.intellij.openapi.editor.impl.SettingsImpl$1.run(SettingsImpl.java:339)      at com.intellij.psi.impl.PsiDocumentManagerBase.performForCommittedDocument(PsiDocumentManagerBase.java:228)      at com.intellij.openapi.editor.impl.SettingsImpl.a(SettingsImpl.java:336)      at com.intellij.openapi.editor.impl.SettingsImpl.reinitSettings(SettingsImpl.java:318)      at com.intellij.openapi.editor.impl.EditorImpl.reinitSettings(EditorImpl.java:793)      at com.intellij.openapi.editor.impl.EditorImpl.setHighlighter(EditorImpl.java:1183)      at com.intellij.openapi.fileEditor.impl.text.TextEditorComponent.b(TextEditorComponent.java:168)      at com.intellij.openapi.fileEditor.impl.text.TextEditorComponent.<init>(TextEditorComponent.java:100)      at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl$PsiAwareTextEditorComponent.<init>(PsiAwareTextEditorImpl.java:62)      at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl$PsiAwareTextEditorComponent.<init>(PsiAwareTextEditorImpl.java:55)      at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl.createEditorComponent(PsiAwareTextEditorImpl.java:44)      at com.intellij.openapi.fileEditor.impl.text.TextEditorImpl.<init>(TextEditorImpl.java:46)      at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl.<init>(PsiAwareTextEditorImpl.java:38)      at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider$1.build(PsiAwareTextEditorProvider.java:77)      at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$13.run(FileEditorManagerImpl.java:873)      at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2351)      at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl4(FileEditorManagerImpl.java:855)      at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl3(FileEditorManagerImpl.java:789)      at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$10.run(FileEditorManagerImpl.java:769)      at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)      at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)      at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:85)      at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl2(FileEditorManagerImpl.java:766)      at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWithProviders(FileEditorManagerImpl.java:707)      at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.java:151)      at com.intellij.codeInsight.navigation.NavigationUtil.a(NavigationUtil.java:200)      at com.intellij.codeInsight.navigation.NavigationUtil.openFileWithPsiElement(NavigationUtil.java:176)      at com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode.navigate(AbstractPsiBasedNode.java:207)      at com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode.navigate(AbstractPsiBasedNode.java:217)      at com.intellij.util.OpenSourceUtil.navigate(OpenSourceUtil.java:53)      at com.intellij.util.OpenSourceUtil.openSourcesFrom(OpenSourceUtil.java:31)      at com.intellij.util.EditSourceOnDoubleClickHandler$TreeMouseListener.processDoubleClick(EditSourceOnDoubleClickHandler.java:130)      at com.intellij.util.EditSourceOnDoubleClickHandler$TreeMouseListener.onDoubleClick(EditSourceOnDoubleClickHandler.java:122)      at com.intellij.ui.DoubleClickListener.onClick(DoubleClickListener.java:30)      at com.intellij.ui.ClickListener$1.mouseReleased(ClickListener.java:73)      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)      at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)      at java.awt.Component.processMouseEvent(Component.java:6543)      at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)      at com.intellij.ui.treeStructure.Tree.processMouseEvent(Tree.java:410)      at com.intellij.ide.dnd.aware.DnDAwareTree.processMouseEvent(DnDAwareTree.java:58)      at java.awt.Component.processEvent(Component.java:6308)      at java.awt.Container.processEvent(Container.java:2235)      at java.awt.Component.dispatchEventImpl(Component.java:4899)      at java.awt.Container.dispatchEventImpl(Container.java:2293)      at java.awt.Component.dispatchEvent(Component.java:4721)      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4897)      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4461)      at java.awt.Container.dispatchEventImpl(Container.java:2279)      at java.awt.Window.dispatchEventImpl(Window.java:2750)      at java.awt.Component.dispatchEvent(Component.java:4721)      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)      at java.awt.EventQueue.access$500(EventQueue.java:97)      at java.awt.EventQueue$3.run(EventQueue.java:702)      at java.awt.EventQueue$3.run(EventQueue.java:696)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)      at java.awt.EventQueue$4.run(EventQueue.java:724)      at java.awt.EventQueue$4.run(EventQueue.java:722)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)      at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)      at com.intellij.ide.IdeEventQueue.f(IdeEventQueue.java:861)      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:645)      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:380)      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

1 comment

Please sign in to leave a comment.