Skip to content

Add some missing tailrec annotations for clarity #4280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ object Types {
* def o: Outer
* <o.x.type>.widen = o.C
*/
@tailrec
final def widen(implicit ctx: Context): Type = widenSingleton match {
case tp: ExprType => tp.resultType.widen
case tp => tp
Expand All @@ -929,6 +930,7 @@ object Types {
/** Widen from singleton type to its underlying non-singleton
* base type by applying one or more `underlying` dereferences.
*/
@tailrec
final def widenSingleton(implicit ctx: Context): Type = stripTypeVar.stripAnnots match {
case tp: SingletonType if !tp.isOverloaded => tp.underlying.widenSingleton
case _ => this
Expand All @@ -937,6 +939,7 @@ object Types {
/** Widen from TermRef to its underlying non-termref
* base type, while also skipping Expr types.
*/
@tailrec
final def widenTermRefExpr(implicit ctx: Context): Type = stripTypeVar match {
case tp: TermRef if !tp.isOverloaded => tp.underlying.widenExpr.widenTermRefExpr
case _ => this
Expand Down