Skip to content
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

ThisType prefix leaks outside of the class it's defined instead of being substituted when referencing a member from the self-type (bug in asSeenFrom?) #15030

Closed
kitlangton opened this issue Apr 26, 2022 · 0 comments · Fixed by #20474

Comments

@kitlangton
Copy link

kitlangton commented Apr 26, 2022

Compiler version

3.1.1

Minimized code

Here's a Scastie link

sealed trait Schema[A]

object Schema extends RecordInstances:
  case class Field[A]() 

sealed trait RecordInstances: 
  self: Schema.type =>
  
  case class Record[A](field: Field[A]) extends Schema[A]

import Schema._

val field: Field[Int] = Field()

// Uh oh Found Playground.Schema.Field[Int] but Requried RecordInstances.this.Field[Int]
val record = Record[Int](field)

Expectation

I would expect to be able to instantiate my record correctly. This actually will compile if I delete theField[Int] type ascription on val field (https://scastie.scala-lang.org/y6cLE8oXRE6bXmCcYH5lLw).

@kitlangton kitlangton added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 26, 2022
@smarter smarter changed the title Compiler error when doing weird thing (@smarter will surely have a better name for this) ThisType prefix leaks outside of the class it's defined instead of being substituted when referencing a member from the self-type (bug in asSeenFrom?) Apr 26, 2022
@smarter smarter added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 26, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue May 26, 2024
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
WojciechMazur added a commit that referenced this issue Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants