Skip to content

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

Description

@kitlangton

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions