Skip to content

Wrong staging level when accessing type from class #4350

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
biboudis opened this issue Apr 20, 2018 · 6 comments
Closed

Wrong staging level when accessing type from class #4350

biboudis opened this issue Apr 20, 2018 · 6 comments

Comments

@biboudis
Copy link
Contributor

biboudis commented Apr 20, 2018

When:

class F[T: Type] { '(null.asInstanceOf[T]) }

access to T from the class F is reported as a wrong level:

4 |  '(null.asInstanceOf[T])
  |                      ^
  |                      access to F.this from wrong staging level:
  |                       - the definition is at level 0,
  |                       - but the access is at level 1.

SImilarly:

class F {
  type T
  '(null.asInstanceOf[T])
}
@Blaisorblade
Copy link
Contributor

Isn't that correct in the absence of lifting for types? Introducing it makes sense, but last time this came up (while talking to @nicolasstucki during a meeting) there weren't rules for it.

@nicolasstucki
Copy link
Contributor

The problem is that it is the prefix of the type that gets the error. If we add the implicit Type[T] we still get this error. The code snippet should probably have the implicit type evidence.

@nicolasstucki
Copy link
Contributor

With prefix I referred to Foo.this in Foo.this.T which is the type of T.

@biboudis
Copy link
Contributor Author

Yes, I updated it to avoid any misconceptions.

@Blaisorblade
Copy link
Contributor

Blaisorblade commented Apr 21, 2018

Oh dear. That's because references to type params are still TypeRefs rather than TypeParamRefs? I am fine with that encoding, but that suggests that (for the theory) that classes need to exist in multiple phases?
EDIT:
Just confirmed, this happens in ReifyQuotes.check, which checks type T encoded as
TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class F)),type T), which then recurses on ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class F)).

@biboudis
Copy link
Contributor Author

Yeap. 😏

biboudis added a commit to dotty-staging/dotty that referenced this issue Apr 25, 2018
biboudis pushed a commit that referenced this issue Apr 27, 2018
Fix #4350: Do not check prefix of class type parameters
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants