Skip to content

Unexpected level-correctness interaction with type alias #6008

Closed
@fhackett

Description

@fhackett
class C {
    type T = Int
    def fn(e : Expr[T]) : Expr[T] = '{ ~e }
}

This fails to compile under Dotty 0.13.0-RC1 (specifically; 0.12.0 accepts this) with the following error:

3 |    def fn(e : Expr[T]) : Expr[T] = '{ ~e }
  |                                       ^^
  |                                access to C.this from wrong staging level:
  |                                 - the definition is at level 0,
  |                                 - but the access is at level 1.

Changing the code like this acts as a workaround:

class C {
    type T = Int
    def fn(e : Expr[Int]) : Expr[T] = '{ ~e }
}

The weird part is that this suddenly started happening in version 0.13.0-RC1. So, either I was taking advantage of a bug that is now fixed, or there is a new bug.

At least, it doesn't make sense to me how adding this layer of indirection changes the meaning of the program. Since it's a plain = alias, there's no chance of T ever not being an Int. In turn, there should be no reason for '{ ~e } to be looking up C.this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions