Skip to content

extension method error should account for access modifier #12573

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
soronpo opened this issue May 23, 2021 · 0 comments · Fixed by #14730
Closed

extension method error should account for access modifier #12573

soronpo opened this issue May 23, 2021 · 0 comments · Fixed by #14730
Milestone

Comments

@soronpo
Copy link
Contributor

soronpo commented May 23, 2021

Compiler version

v3.0.0

Minimized code

class Value[T <: Int](val value: T)

sealed trait DFType:
  type Width <: Int
  val width: Value[Width]

object DFType:
  trait TC[T]:
    type Type <: DFType
    def apply(t: T): Type
  type Aux[T, Type0 <: DFType] = TC[T] { type Type = Type0 }
  transparent inline given ofDFType[T <: DFType]: TC[T] =
    new TC[T]:
      type Type = T
      def apply(t: T): Type = t

  extension [T, Type <: DFType](t: T)(using tc: Aux[T, Type])
    protected def getDFType: Type = tc(t)

final case class DFBits[W <: Int](width: Value[W]) extends DFType:
  type Width = W

val w: Value[8] = DFBits(Value[8](8)).getDFType.width 

Output

[error]    |  val w: Value[8] = DFBits(Value[8](8)).getDFType.width
[error]    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |                    value getDFType is not a member of DFBits[(8 : Int)].
[error]    |                    An extension method was tried, but could not be fully constructed:
[error]    |
[error]    |                        DFType.getDFType(DFiant.core.Minimized.DFBits.apply[(8 : Int)](new Value[8.type](8)))

Expectation

The message "An extension method was tried, but could not be fully constructed" is confusing. The message should clearly indicate that the failure is due to the protected modifier.

@soronpo soronpo changed the title Dependent type path extension method fail Protected extension method fail with wrong message May 23, 2021
@bishabosha bishabosha changed the title Protected extension method fail with wrong message extension method error should account for access modifier May 25, 2021
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
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.

2 participants