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

SI-7464 allows FieldMirror.set to update vals #2504

Merged
merged 1 commit into from
May 17, 2013

Conversation

xeno-by
Copy link
Member

@xeno-by xeno-by commented May 8, 2013

There's no reason to leave such sentinels in place inside a facility
designed to circumvent usual restrictions of static types / visibility.

@xeno-by
Copy link
Member Author

xeno-by commented May 8, 2013

review @retronym

@gkossakowski
Copy link
Member

PLS REBUILD/pr-checkin-per-commit@788d42a

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 17756701)
🐱 Roger! Rebuilding pr-checkin-per-commit for 788d42a5. 🚨

@xeno-by
Copy link
Member Author

xeno-by commented May 12, 2013

@adriaanm what's up with the kitty?

@adriaanm
Copy link
Contributor

PLS REBUILD ALL

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 17913094)
🐱 Roger! Rebuilding pr-rangepos-per-commit, pr-checkin-per-commit for 788d42a5. 🚨

There's no reason to leave such sentinels in place inside a facility
designed to circumvent usual restrictions of static types / visibility.
@xeno-by
Copy link
Member Author

xeno-by commented May 17, 2013

@retronym That probably will be a very easy review if you have some more time for reviews today.

@xeno-by
Copy link
Member Author

xeno-by commented May 17, 2013

I'd also like to mention that this patch brings us to consistency with Java reflection. They also allow updating final fields (though only after calling setAccessible, which we always call implicitly).

@retronym
Copy link
Member

LGTM.

I was wondering whether we should (eventually) guard the use of the Scala reflection API with a set of permissions (for sandboxed environments.) But I'm not sure if that really makes sense.

retronym added a commit that referenced this pull request May 17, 2013
SI-7464 allows FieldMirror.set to update vals
@retronym retronym merged commit 4f8c306 into scala:2.10.x May 17, 2013
@retronym
Copy link
Member

Sorry for the merging with the broken tests, the fix is now merged in #2550.

eed3si9n pushed a commit to eed3si9n/scala that referenced this pull request May 14, 2019
Add a pending test that shows a problem with instability of representing
self variables. This test covers the bug described in scala#2504.

In order to test API representation of a class declared either in source
file or unpickled from a class file, ScalaCompilerForUnitTesting has been
extended to extract APIs from multiple compiler instances sharing a
classpath.
eed3si9n pushed a commit to eed3si9n/scala that referenced this pull request May 14, 2019
The reason for instability is a bit tricky so let's unpack what the
previous code checking if there's self type declared was doing. It would
check if `thisSym` of a class is equal to a symbol representing the class.
If that's true, we know that there's no self type. If it's false, then
`thisSym` represents either a self type or a self variable. The second
(type test) was supposed to check whether the type of `thisSym` is
different from a type of the class. However, it would always yield false
because TypeRef of `thisSym` was compared to ClassInfoType of a class.
So if you had a self variable the logic would see a self type (and that's
what API representation would give you).

Now the tricky bit: `thisSym` is not pickled when it's representing just
a self variable because self variable doesn't affect other classes
referring to a class. If you looked at a type after unpickling, the
symbol equality test would yield true and we would not see self type when
just a self variable was declared.

The fix is to check equality of type refs on both side of the type equality
check. This makes the pending test passing.

Also, I added another test that checks if self types are represented in
various combinations of declaring a self variable or/and self type.

Fixes scala#2504.
lrytz pushed a commit to lrytz/scala that referenced this pull request Nov 5, 2019
Add a pending test that shows a problem with instability of representing
self variables. This test covers the bug described in scala#2504.

In order to test API representation of a class declared either in source
file or unpickled from a class file, ScalaCompilerForUnitTesting has been
extended to extract APIs from multiple compiler instances sharing a
classpath.

Rewritten from sbt/zinc@3f26571
lrytz pushed a commit to lrytz/scala that referenced this pull request Nov 5, 2019
The reason for instability is a bit tricky so let's unpack what the
previous code checking if there's self type declared was doing. It would
check if `thisSym` of a class is equal to a symbol representing the class.
If that's true, we know that there's no self type. If it's false, then
`thisSym` represents either a self type or a self variable. The second
(type test) was supposed to check whether the type of `thisSym` is
different from a type of the class. However, it would always yield false
because TypeRef of `thisSym` was compared to ClassInfoType of a class.
So if you had a self variable the logic would see a self type (and that's
what API representation would give you).

Now the tricky bit: `thisSym` is not pickled when it's representing just
a self variable because self variable doesn't affect other classes
referring to a class. If you looked at a type after unpickling, the
symbol equality test would yield true and we would not see self type when
just a self variable was declared.

The fix is to check equality of type refs on both side of the type equality
check. This makes the pending test passing.

Also, I added another test that checks if self types are represented in
various combinations of declaring a self variable or/and self type.

Fixes scala#2504.

Rewritten from sbt/zinc@81cbabf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants