Skip to content

Regression for type inference of cyclic non-inlined methods #21568

Closed
@WojciechMazur

Description

@WojciechMazur

Compiler version

Last good release: 3.6.0-RC1-bin-20240821-a2c53a1-NIGHTLY
First bad release: 3.6.0-RC1-bin-20240822-d490d13-NIGHTLY
Bisect points to b34df4d

Minimized code

class Lang(name: String)
object Lang {
  val Default = Lang("")
  def apply(language: String): Lang = Lang(language)
  def apply(maybeLang: Option[String], default: Lang = Default): Lang = maybeLang.map(apply).getOrElse(default)
}

Output

[error] ./test.scala:5:56
[error] Recursive value Default needs type
[error] 
[error] The error occurred while trying to compute the signature of value Default
[error]   which required to type the right hand side of value Default since no explicit type was given
[error]   which required to compute the signature of method apply$default$2
[error]   which required to type the right hand side of method apply$default$2 since no explicit type was given
[error]   which required to compute the signature of value Default
[error] 
[error]  Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace.
[error]   def apply(maybeLang: Option[String], default: Lang = Default): Lang = maybeLang.map(apply).getOrElse(default)
[error]                                                        ^
Error compiling project (Scala 3.6.0-RC1-bin-20240907-614170f-NIGHTLY, JVM (17))

Expectation

Non inlined methods should not require explicit rhs type.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions