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

Overridden methods with wider access don't have it applied in specialized versions #10211

Closed
scabug opened this issue Feb 27, 2017 · 4 comments
Closed

Comments

@scabug
Copy link

scabug commented Feb 27, 2017

Given a protected[this] method and a subtype overriding its declaration to make access public, the widening of access isn't applied to the specialized declarations.

trait QuitePrivate[@specialized(Int) +K] {
	protected[this] def hasK(k :K) :Boolean
}

trait MoreOpen extends QuitePrivate[Int] {
	override def hasK(k :Int) :Boolean
}


object Playground extends App {
	def check(guy :MoreOpen) = guy.hasK(42)
}
Error:(13, 33) method hasK$mcI$sp in trait MoreOpen cannot be accessed in MoreOpen
 Access to protected method hasK$mcI$sp not permitted because
 enclosing object Playground is not a subclass of 
 trait MoreOpen where target is defined
	def check(guy :MoreOpen) = guy.hasK(42)

BTW - I know the specialization is an experimental and not fullly integrated feature of the language. Should I keep reporting bugs I find in this area, or is it just burdening you with stuff that's likely to go out of the window and be rewritten completely?

@scabug
Copy link
Author

scabug commented Feb 27, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10211?orig=1
Reporter: Marcin Mościcki (mmoscicki)
Affected Versions: 2.11.8

@scabug
Copy link
Author

scabug commented Mar 16, 2017

@SethTisue said:
The bug reports are valuable as documentation for future wanderers in the hallways of JIRA. But yeah, I'm going to tag this as "community" which means unless a volunteer appears, it's unlikely to get fixed.

@scabug
Copy link
Author

scabug commented Mar 16, 2017

Marcin Mościcki (mmoscicki) said:
Ok, thx.
Never worked on a compiler before, but if you suspect it's something really easy and could point me in the right direction, and there is some general intro for contributors, maybe I could give it a try?

@jxnu-liguobin
Copy link
Member

    abstract trait MoreOpen extends Object with sandbox.Test#QuitePrivate$mcI$sp {
      override def hasK(k: Int): Boolean;
      <specialized> protected[this] def hasK$mcI$sp(k: Int): Boolean = MoreOpen.this.hasK(k)
    };

The main problem seems to be that the hasK$mcI$sp method should also as public?

@som-snytt som-snytt changed the title Overriden methods with wider access don't have it applied in specialized versions Overridden methods with wider access don't have it applied in specialized versions Nov 7, 2021
@lrytz lrytz modified the milestones: Backlog, 2.13.11 Feb 21, 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

4 participants