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

-Xsource:2.10 coverage #8402

Closed
scabug opened this issue Mar 12, 2014 · 14 comments
Closed

-Xsource:2.10 coverage #8402

scabug opened this issue Mar 12, 2014 · 14 comments

Comments

@scabug
Copy link

scabug commented Mar 12, 2014

It's hard to know how many more places -Xsource 2.10 might need to be respected for what I want to work, because compilation tends to halt before one has a clear picture. But there are at least the two shown here. First:

class Foo[+CC[X]] { type Coll = CC[_] }

That compiles in 2.10 but not in 2.11.

"What I want to work" is to be able to compile the 2.10 sources with 2.11. For y'all to push through the errors seems like an easy way to find some of the holes in -Xsource.

The other place, which arises first:

/l/trunk1/src/compiler/scala/tools/nsc/backend/icode/Printers.scala:19: error: reference to Linearizer is ambiguous;
it is both defined in trait Linearizers and imported subsequently by
import global.icodes._
  class TextPrinter(writer: PrintWriter, lin: Linearizer) {
                                              ^
one error found
onExit 1

It only became possible to even try this after 0fbd4422b2 which fixed "scala.reflect.internal.FatalError: class Universe does not have a member Quasiquote", thanks for that.

In case you want to pursue this I made a script to embody what I think should work, which might even serve as the basis of a test.

#!/usr/bin/env bash
#
# Run one version of scala compiling against a different one.
#
# Sample usage:
# find /path/to/scala-2.10/src/{asm,library,reflect,compiler} -name '*.scala' -o -name '*.java' | egrep -v '/ant/') | \
#   runner.sh -verbose

runlib=/scala/trunk/build/pack/lib
otherlib=/scala/inst/210/lib

java -Xmx2g \
  -cp "$runlib"/'*' scala.tools.nsc.Main \
  -cp "$otherlib"/'*' \
  -Xsource:2.10 \
  "$@"
@scabug
Copy link
Author

scabug commented Mar 12, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8402?orig=1
Reporter: @paulp
See #8403, #8265

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
I did notice some issues have already been flushed out, e.g. this doesn't compile without the -Xsource:2.10 because of the implicit conversion of Null.

% pscalac -Xsource:2.10 /l/trunk1/src/library/scala/Option.scala

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
For reference the variance soundness fix was in a419799f87 . Also I noticed retronym considering maybe it's not so bad to fix scalaz re: scala/scala#3178 re that subsequent variance soundness fix. I'm going to assume everyone agrees it's worlds better for migration if people can compile their 2.10 sources as-is with -Xsource:2.10. I think that github comment thread predates the realization that -Xsource:2.10 was a really good idea.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@retronym said:
I think the first part of the request dups #8265.

BTW, [~garillot] has a jenkins job that typechecks a few projects with -Xsource:2.10. https://jenkins.scala-ide.org:8496/jenkins/view/Scala%20Xsource%20flag%20nightlies/

We know that we don't have the resources to be completely bug-compatible with 2.10 under this flag, so we are relying on the data from these builds to figure out where we get the most bang for our buck.

The primary use case for this flag is to use the 2.11 IDE for 2.10 code bases.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@retronym said:
See also scala/scala#3359, which backported the variance compliance to 2.10.x.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
Yes I figured some of this would exist in other tickets. Well if it helps rest assured that #8265 will hit many projects. The convenience of invisible unsoundness has an accidental allure like few others.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
Using the 2.11 IDE on 2.10 code bases is the same use case as mine, except that maybe it gives up more quickly.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
I'll wrap the variance check if I can talk you into the ambiguity check (I don't even know what is the origin of that.)

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said (edited on Mar 12, 2014 5:21:09 PM UTC):
After I patch past the variance issue there is only one more issue before compilation succeeds. To me that says it's easily worth making this work and testing it.

The last problem is a change in the scala.runtime support java classes, introduced in 265fc6b230 . Now it generates calls to "create" which doesn't exist in the 2.10 sources.

error: scala.reflect.internal.FatalError: object VolatileFloatRef does not have a member create
	at scala.reflect.internal.Definitions$DefinitionsClass.scala$reflect$internal$Definitions$DefinitionsClass$$fatalMissingSymbol(Definitions.scala:1165)
	at scala.reflect.internal.Definitions$DefinitionsClass$$anonfun$getMember$1.apply(Definitions.scala:1188)
	at scala.reflect.internal.Definitions$DefinitionsClass$$anonfun$getMember$1.apply(Definitions.scala:1183)
	at scala.reflect.internal.Symbols$Symbol.orElse(Symbols.scala:2433)
	at scala.reflect.internal.Definitions$DefinitionsClass.getMember(Definitions.scala:1182)
	at scala.reflect.internal.Definitions$DefinitionsClass.getMemberMethod(Definitions.scala:1217)

It's relatively easy to work around by substituting the 2.11 scala/runtime/*.java classes for the 2.10 ones.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@retronym said (edited on Mar 12, 2014 5:27:38 PM UTC):
Yeah, the interaction with ScalaRuntime is why this is only really supported until typer phase. Name based patmat has a bunch of new calls there, for example.

I'm happy to accept a patch for the variance loosening for RC2 (scheduled on Friday, I think).

I'll see if I can pin down the ambiguity change.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
Maybe I can reorient this ticket toward the future. How about requiring that scala continue to be able to compile the 2.11 release under -Xsource:2.11 ? I'm sure it would be welcome come 2.12.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@retronym said:
I've lodged the ambiguity error as #8403. Looks like its a regression after my refactoring of Contexts.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@paulp said:
scala/scala#3623

@huitseeker
Copy link

Should be fixed by scala/scala#3623

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants