Skip to content

Extension method on aliased path dependent type is not found #17972

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
ftucky opened this issue Jun 14, 2023 · 1 comment
Closed

Extension method on aliased path dependent type is not found #17972

ftucky opened this issue Jun 14, 2023 · 1 comment

Comments

@ftucky
Copy link

ftucky commented Jun 14, 2023

Compiler version

3.3.1-RC1

Minimized code

trait A:
	type X = Int
	extension (x:X) def foo : String = "foo"

def bar(a:A)(x:a.X) = x.foo // <-- ERROR : value foo is not a member of a.X

Output

Does not compile :

value foo is not a member of a.X

Expectation

Should compile

observations:

Following flavors behave as expected:

trait A:
	type X 
trait A:
	type X >: Int <: Int // Strictly Bounded
@ftucky ftucky added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 14, 2023
@mbovel mbovel added area:extension-methods and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 19, 2023
@smarter
Copy link
Member

smarter commented Jun 26, 2023

I believe this is intentional, extension methods are found using the same mechanism as implicit search which will look for members in the anchors of the types as defined in https://dotty.epfl.ch/docs/reference/changed-features/implicit-resolution.html, this explicitly excludes non-opaque type aliases. The reason for doing so is that type aliases are easily lost (in particular via type inference) and it'd be confusing for implicit search to give different results when that happens. It's maybe something we could revisit if we tried harder to keep type aliases (as proposed in #14586), but it would be a language change.

@smarter smarter closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2023
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