<commit_before>package org.jetbrains.plugins.scala
package lang
package parser
package parsing
package patterns

import com.intellij.lang.PsiBuilder
import lexer.ScalaTokenTypes
import types.{ExistentialClause, InfixType, Type}
import builder.ScalaPsiBuilder

/**
* @author <NAME>
* Date: 29.02.2008
*/

/*
 * TypePattern ::= Type (but it can't be InfixType => Type (because case A => B => C?))
 */

object TypePattern {
  def parse(builder: ScalaPsiBuilder): Boolean = {
    val typeMarker = builder.mark
    builder.getTokenType match {
      case ScalaTokenTypes.tLPARENTHESIS => {
        val parMarker = builder.mark
        builder.advanceLexer //Ate (
        builder.disableNewlines
        builder.getTokenType match {
          case ScalaTokenTypes.tFUNTYPE | ScalaTokenTypes.tRPARENTHESIS => {
            if (builder.getTokenType == ScalaTokenTypes.tFUNTYPE) {
              builder.advanceLexer //Ate =>
              if (!Type.parse(builder,false,true)) {
                builder error ScalaBundle.message("wrong.type")
              }
            }
            builder.getTokenType match {
              case ScalaTokenTypes.tRPARENTHESIS => {
                builder.advanceLexer //Ate )
              }
              case _ => {
                builder error ScalaBundle.message("rparenthesis.expected")
              }
            }
            builder.restoreNewlinesState
            builder.getTokenType match {
              case ScalaTokenTypes.tFUNTYPE => {
                builder.advanceLexer //Ate =>
              }
              case _ => {
                builder error ScalaBundle.message("fun.sign.expected")
              }
            }
            if (!Type.parse(builder,false,true)) {
              builder error ScalaBundle.message("wrong.type")
            }
            typeMarker.done(ScalaElementTypes.TYPE_PATTERN)
            parMarker.drop
            return true
          }
          case _ => {parMarker.rollbackTo}
        }
      }
      case _ => {}
    }
    if (!InfixType.parse(builder,false,true)) {
      typeMarker.drop
      return false
    }
    builder.getTokenType match {
      case ScalaTokenTypes.kFOR_SOME => {
        ExistentialClause parse builder
        typeMarker.done(ScalaElementTypes.TYPE_PATTERN)
        return true
      }
      case _ => {
        typeMarker.done(ScalaElementTypes.TYPE_PATTERN)
        return true
      }
    }
  }
}<commit_msg>SCL-2713 Parser bug fix.<commit_after>package org.jetbrains.plugins.scala
package lang
package parser
package parsing
package patterns

import com.intellij.lang.PsiBuilder
import lexer.ScalaTokenTypes
import types.{ExistentialClause, InfixType, Type}
import builder.ScalaPsiBuilder

/**
* @author <NAME>
* Date: 29.02.2008
*/

/*
 * TypePattern ::= Type (but it can't be InfixType => Type (because case A => B => C?))
 */

object TypePattern {
  def parse(builder: ScalaPsiBuilder): Boolean = {
    val typeMarker = builder.mark
    builder.getTokenType match {
      case ScalaTokenTypes.tLPARENTHESIS => {
        val parMarker = builder.mark
        builder.advanceLexer //Ate (
        builder.disableNewlines
        builder.getTokenType match {
          case ScalaTokenTypes.tFUNTYPE | ScalaTokenTypes.tRPARENTHESIS => {
            if (builder.getTokenType == ScalaTokenTypes.tFUNTYPE) {
              builder.advanceLexer //Ate =>
              if (!Type.parse(builder,false,true)) {
                builder error ScalaBundle.message("wrong.type")
              }
            }
            builder.getTokenType match {
              case ScalaTokenTypes.tRPARENTHESIS => {
                builder.advanceLexer //Ate )
              }
              case _ => {
                builder error ScalaBundle.message("rparenthesis.expected")
              }
            }
            builder.restoreNewlinesState
            builder.getTokenType match {
              case ScalaTokenTypes.tFUNTYPE => {
                builder.advanceLexer //Ate =>
              }
              case _ => {
                builder error ScalaBundle.message("fun.sign.expected")
              }
            }
            if (!Type.parse(builder,false,true)) {
              builder error ScalaBundle.message("wrong.type")
            }
            typeMarker.done(ScalaElementTypes.TYPE_PATTERN)
            parMarker.drop
            return true
          }
          case _ =>
            builder.restoreNewlinesState
            parMarker.rollbackTo
        }
      }
      case _ => {}
    }
    if (!InfixType.parse(builder,false,true)) {
      typeMarker.drop
      return false
    }
    builder.getTokenType match {
      case ScalaTokenTypes.kFOR_SOME => {
        ExistentialClause parse builder
        typeMarker.done(ScalaElementTypes.TYPE_PATTERN)
        return true
      }
      case _ => {
        typeMarker.done(ScalaElementTypes.TYPE_PATTERN)
        return true
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.09055759055759056, 'fraction_numerical': 0.00407000407000407, 'mean_word_length': 1.8214695752009185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1568623', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1361, 'n_words': 250}