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-5330, SI-6014 deal with existential self-type #1074
Conversation
This has been broken since scala@b7b81ca2#L0L567. The existential rash is treated in a similar manner as in fc24db4. Conceptually, the fix would be `def selfTypeSkolemized = widen.skolemizeExistential.narrow`, but simply widening before narrowing achieves the same thing. Since we're in existential voodoo territory, let's go for the minimal fix: replacing `this.narrow` by `widen.narrow`.
/cc @retronym |
Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/101/ |
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/804/ |
jenkins job pr-rangepos: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/101/ |
jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/804/ |
This looks fishy and will be disastrous from a performance standpoint. Narrow is expensive unless the type is already a singleton type. Widen makes sure it isn't. |
In fact, I think it would be OK to outlaw existential self types. |
What could be outlawed in this case? |
A couple ideas for performance:
I repeat @paulp's comments from /** Equivalent to allOverriddenSymbols.nonEmpty, but more efficient. */
// !!! When if ever will this answer differ from .isOverride?
// How/where is the OVERRIDE flag managed, as compared to how checks
// based on type membership will evaluate?
def isOverridingSymbol = owner.isClass && (
owner.ancestors exists (cls => matchingSymbol(cls, owner.thisType) != NoSymbol)
) |
This has been broken since scala@b7b81ca2#L0L567. The existential rash is treated in a similar manner as in fc24db4. Conceptually, the fix would be `def selfTypeSkolemized = widen.skolemizeExistential.narrow`, but simply widening before narrowing achieves the same thing. Since we're in existential voodoo territory, let's go for the minimal fix: replacing `this.narrow` by `widen.narrow`. -- Original patch by @retronym in scala#1074, refined by @paulp to only perform widen.narrow incantation if there are existentials present in the widened type, as narrowing is expensive when the type is not a singleton. The result is that compiling the entirety of quick, that code path is hit only 143 times. All the other calls hit .narrow directly as before. It looks like the definition of negligible in the diff of -Ystatistics when compiling src/library/scala/collection: < #symbols : 306315 --- > #symbols : 306320 12c13 < #unique types : 293859 --- > #unique types : 293865 I'm assuming based on the 2/1000ths of a percent increase in symbol and type creation that wall clock is manageable, but I didn't measure it.
This has been broken since scala@b7b81ca2#L0L567. The existential rash is treated in a similar manner as in fc24db4. Conceptually, the fix would be `def selfTypeSkolemized = widen.skolemizeExistential.narrow`, but simply widening before narrowing achieves the same thing. Since we're in existential voodoo territory, let's go for the minimal fix: replacing `this.narrow` by `widen.narrow`. -- Original patch by @retronym in scala#1074, refined by @paulp to only perform widen.narrow incantation if there are existentials present in the widened type, as narrowing is expensive when the type is not a singleton. The result is that compiling the entirety of quick, that code path is hit only 143 times. All the other calls hit .narrow directly as before. It looks like the definition of negligible in the diff of -Ystatistics when compiling src/library/scala/collection: < #symbols : 306315 --- > #symbols : 306320 12c13 < #unique types : 293859 --- > #unique types : 293865 I'm assuming based on the 2/1000ths of a percent increase in symbol and type creation that wall clock is manageable, but I didn't measure it.
This has been broken since b7b81ca2#L0L567.
The existential rash is treated in a similar manner as in fc24db4.
Conceptually, the fix would be
def selfTypeSkolemized = widen.skolemizeExistential.narrow
,but simply widening before narrowing achieves the same thing. Since we're in existential voodoo territory,
let's go for the minimal fix: replacing
this.narrow
bywiden.narrow
.review by @odersky