You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following code compiles fine with Scala 2, but does not compile with Scala 3:
importscala.util.parsing.combinator.lexical.LexicalclassScalaLikeLexerextendsLexical {
sealedabstractclassScalaLikeTokenextendsToken {
deftoSource= chars
}
@annotation.tailrec
privatedefparseAllTokensLoop(s: Scanner, prevTokens: Seq[ScalaLikeToken]):Seq[ScalaLikeToken] = {
if (s.atEnd) prevTokens.reverse // reversed, so that we can prepend (this is fast on Seq)else parseAllTokensLoop(s.rest, s.first.asInstanceOf[ScalaLikeToken] +: prevTokens)
}
}
Could the type be provided explicitly as Scanner, so that it is the same in all Scala versions? Other overridden members of Scanner could perhaps receive the same treatment.
If this seems acceptable, I can prepare the PR if desired.
The text was updated successfully, but these errors were encountered:
Following code compiles fine with Scala 2, but does not compile with Scala 3:
The error with Scala 3 is:
See https://scastie.scala-lang.org/bxUTWXp5SNeaXpgvqm24Mw
The reason is type of
Scanner.rest
is not specified in the source. The method is implemented usingnew Scanner(rest2)
, therefore the type isScanner
in Scala 2, while it isReader[Token]
in Scala 3 (see https://docs.scala-lang.org/scala3/guides/migration/incompat-type-inference.html)Could the type be provided explicitly as
Scanner
, so that it is the same in all Scala versions? Other overridden members ofScanner
could perhaps receive the same treatment.If this seems acceptable, I can prepare the PR if desired.
The text was updated successfully, but these errors were encountered: