-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #239 - handling of package objects #282
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
Fix #239 - handling of package objects #282
Conversation
Note that -Ycheck caught the problem with the included test file before the fix was made. |
References to `.package` are now also inserted if the accessed member comes from a class inherited by a package object.
58e370b
to
9bc3bb2
Compare
@@ -124,7 +124,7 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi | |||
normalizeType { | |||
val qual = tree.qualifier | |||
qual.symbol.moduleClass.denot match { | |||
case pkg: PackageClassDenotation if tree.symbol.maybeOwner.isPackageObject => | |||
case pkg: PackageClassDenotation if !tree.symbol.maybeOwner.is(Package) => | |||
cpy.Select(tree)(qual select pkg.packageObj.symbol, tree.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this assign a position to Select(qual, TermName("package"))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Mon, Dec 15, 2014 at 12:43 AM, Jason Zaugg [email protected]
wrote:
In src/dotty/tools/dotc/transform/FirstTransform.scala
#282 (diff):@@ -124,7 +124,7 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
normalizeType {
val qual = tree.qualifier
qual.symbol.moduleClass.denot match {
case pkg: PackageClassDenotation if tree.symbol.maybeOwner.isPackageObject =>
case pkg: PackageClassDenotation if !tree.symbol.maybeOwner.is(Package) => cpy.Select(tree)(qual select pkg.packageObj.symbol, tree.name)
Does this assign a position to Select(qual, TermName("package"))?
Yes, it's the position of
qual
.
- Martin
—
Reply to this email directly or view it on GitHub
https://github.com/lampepfl/dotty/pull/282/files#r21800912.
Martin Odersky
EPFL
There are some gaps with inherited implicit members:
I tested this with dotty (as at this PR) and scalac. Dotty fails with:
Scalac compiles successfully. |
Like TypeAssigner, asSeenFrom needs to insert a package object if the prefix is a package but the class enclosing the type is not.
Good catch. I added a patch that fixes this. |
LGTM. Patching ASF seems to address the problem in a more centralized way than we managed in scalac. You might like to try a few more test cases from scala/scala#4001. Sorry that I forgot to point out this one yesterday. Perhaps the most esoteric one was related to insertion of an |
Fix #239 - handling of package objects
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` tranaparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. It also lets us remove the fix for SI-6225. [1] scala/scala3#282
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` tranaparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. It also lets us remove the fix for SI-6225. [1] scala/scala3#282
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` transparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. This subsumes the former fix for SI-6225, which is removed here. [1] scala/scala3#282
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` transparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. This subsumes the former fix for SI-6225, which is removed here. [1] scala/scala3#282
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` transparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. This subsumes the former fix for SI-6225, which is removed here. [1] scala/scala3#282
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` transparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. This subsumes the former fix for SI-6225, which is removed here. [1] scala/scala3#282
Takes a leaf out of dotty's book [1] and makes `asSeenFrom` transparently change the prefix from the package class to the package object when needed. This fixes generic subsitution during overload resolution, as reported in SI-9074. This subsumes the former fix for SI-6225, which is removed here. [1] scala/scala3#282
Backport "Make sure Block does not incorrectly match a TypeBlock" to 3.3 LTS
References to
.package
are now also inserted if theaccessed member comes from a class inherited by a package
object.
Closes #239
Review by @retronym