-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Reproduction steps
Scala 2 version: 2.13.16
Scala 3 version: 3.6.3
Please let me know if scala/scala3 is a better place to post this.
- Compile the following with Scala 3:
package foo
package object bar {
implicit class EnrichedNumberOption(private val number: Option[Int]) {
def +(other: Option[Int]): Option[Int] = number.flatMap(number => other.map(number + _))
}
}
- Compile the following with Scala 2:
package foo.bar
object Main {
None + None
}
- Observe the following exception:
java.lang.StackOverflowError
scala.reflect.internal.Symbols$Symbol.isTopLevel(Symbols.scala:1048)
scala.reflect.internal.Symbols$ClassSymbol.associatedFile(Symbols.scala:3442)
scala.reflect.internal.Symbols$Symbol.isCoDefinedWith(Symbols.scala:2346)
scala.reflect.internal.Symbols$Symbol.$anonfun$companionClass$1(Symbols.scala:2385)
scala.reflect.internal.Symbols$Symbol.$anonfun$companionClass$1$adapted(Symbols.scala:2385)
scala.reflect.internal.Symbols$Symbol.filter(Symbols.scala:2061)
scala.reflect.internal.Symbols$Symbol.suchThat(Symbols.scala:2065)
scala.reflect.internal.Symbols$Symbol.companionClass(Symbols.scala:2385)
scala.reflect.internal.Symbols$ModuleClassSymbol.linkedClassOfClass(Symbols.scala:3549)
scala.tools.nsc.typechecker.Infer$Inferencer.isProperSubClassOrObject(Infer.scala:923)
scala.tools.nsc.typechecker.Infer$Inferencer.isProperSubClassOrObject(Infer.scala:923)
scala.tools.nsc.typechecker.Infer$Inferencer.isProperSubClassOrObject(Infer.scala:923)
...
Problem
I'd expect the Scala 2 code to compile.
Metadata
Metadata
Assignees
Labels
No labels