Skip to content

SI-6623 Avoid $iw wrappers in REPL#5220

Closed
som-snytt wants to merge 3 commits intoscala:2.12.xfrom
som-snytt:issue/6623-iw
Closed

SI-6623 Avoid $iw wrappers in REPL#5220
som-snytt wants to merge 3 commits intoscala:2.12.xfrom
som-snytt:issue/6623-iw

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Jun 9, 2016

Use a conventional import to bump context depth in REPL templates.

Code is still ordinarily wrapped in a $read object.

This is a step toward 6623-like transparency.

retronym takes the blame for this innovation.
adriaanm collaborated in its commission.
somsnytt batted clean-up.

Notice how the handles line up.

@scala-jenkins scala-jenkins added this to the 2.12.0-RC1 milestone Jun 9, 2016
@som-snytt som-snytt mentioned this pull request Jun 9, 2016
//
// `foo` will bind to `baz.foo` in this example:
//
// { import bar.foo; import interpreseter.$iw; import baz.foo; foo }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad: s/interpreseter/interpreter/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crosstalk from presentation compiler completer.

@som-snytt
Copy link
Contributor Author

som-snytt commented Jun 10, 2016

valueOfTerm broke again, in run/imain.scala.

scala.ScalaReflectionException: expected a member of object $read, you provided value $line2.$read.x1
        at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$abort(JavaMirrors.scala:115)
        at scala.reflect.runtime.JavaMirrors$JavaMirror.ErrorNotMember(JavaMirrors.scala:121)
        at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$$anonfun$12(JavaMirrors.scala:214)
        at scala.reflect.runtime.JavaMirrors$JavaMirror.ensuringNotFree(JavaMirrors.scala:204)
        at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$checkMemberOf(JavaMirrors.scala:214)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaInstanceMirror.reflectField(JavaMirrors.scala:236)
        at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaInstanceMirror.reflectField(JavaMirrors.scala:233)
        at scala.tools.nsc.interpreter.IMain.value$2(IMain.scala:1022)
        at scala.tools.nsc.interpreter.IMain.scala$tools$nsc$interpreter$IMain$$$anonfun$99(IMain.scala:1028)
        at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235)
        at scala.reflect.internal.SymbolTable.exitingPhase(SymbolTable.scala:256)
        at scala.tools.nsc.Global.exitingTyper(Global.scala:958)
        at scala.tools.nsc.interpreter.IMain.valueOfTerm(IMain.scala:1016)

Also, this was not the expected message.

> partest --show-log test/files/run/imain.scala
[error] Expected non-whitespace character
[error] partest --show-log test/files/run/imain.scala
[error]                   ^

@retronym
Copy link
Member

@som-snytt I looked at the valueOfTerm problem a bit but didn't find enlightenment. Could be a bug in the way it uses reflection, or a bug in reflection itself. I would suggest deleting that method for now.

@som-snytt
Copy link
Contributor Author

@retronym I had an old fix for valueOfTerm at https://github.com/scala/scala/pull/4311/commits which seems to work. More LOC.

But it has broken at SI-4899 and SI-5854 and SI-8935, which should tell us something.

paulp:

Impressed at the amount of ticket traffic for an unadvertised internal
method. All the more reason to work toward that support repl API.
Don't worry, it'll come.

Which should also tell us something.

@som-snytt som-snytt force-pushed the issue/6623-iw branch 2 times, most recently from 6b365c8 to 754dfc4 Compare June 18, 2016 06:53
@som-snytt
Copy link
Contributor Author

Jenkins, old boy, I must say, I appreciate your company on these dark late nights. Perhaps I don't say it enough. But you're quite the chap.

@som-snytt som-snytt force-pushed the issue/6623-iw branch 2 times, most recently from abae8d2 to 7b998cc Compare June 18, 2016 19:07
@som-snytt
Copy link
Contributor Author

A few failures still. This is a problem:

scala> k // show
object $read extends scala.AnyRef {
  def <init>() = {
    super.<init>;
    ()
  };
  import _root_.scala.tools.nsc.interpreter.$u007B$u007B;
  import _root_.scala.tools.nsc.interpreter.$u007B$u007B;
  import $line5.$read.c;
  import _root_.scala.tools.nsc.interpreter.$u007B$u007B;
  import c.k;
  import _root_.scala.tools.nsc.interpreter.$u007B$u007B;
  import $line11.$read.k;
  val res2 = k
}
<console>:17: error: reference to k is ambiguous;
it is imported twice in the same scope by
import k
and import c.k
       k // show
       ^

val INSTANCE = new $read.<init>
}
res3: List[Product with Serializable] = List(BippyBups(), PuppyPups(), Bingo())
res3: List[Serializable with Product] = List(BippyBups(), PuppyPups(), Bingo())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious update.

@adriaanm adriaanm modified the milestones: 2.12.0-RC1, 2.12.1 Jul 26, 2016
@som-snytt som-snytt closed this Nov 7, 2016
@SethTisue SethTisue removed this from the 2.12.1 milestone Nov 29, 2016
Now `valueOfTerm` drills down reflectively using
the `fullName` of the desired symbol.

It respects a prefix of static modules, but switches
to instance mirrors as required.

The target is an accessor on the last enclosing instance.

cherrypicked from scala#4311

Conflicts:

	src/repl/scala/tools/nsc/interpreter/IMain.scala
Synchronize the live test with the spec update,
which is trivial.

Also add a neg test showing that an imported name
remains ambiguous even if it resolves to the
definition in scope with which it is ambiguous.
Use a conventional import to bump context depth in REPL templates.

Code is still ordinarily wrapped in a `$read` object.

This is a step toward 6623-like transparency.

`retronym` takes the blame for this innovation.
`adriaanm` collaborated in its commission.
`somsnytt` batted clean-up.
@som-snytt som-snytt reopened this Jan 31, 2017
@scala-jenkins scala-jenkins added this to the 2.12.2 milestone Jan 31, 2017
@som-snytt
Copy link
Contributor Author

som-snytt commented Jan 31, 2017

Still WIP, but:

[warn] Unable to reparse org.scala-lang#scala-library;2.12.2-6d8c565-SNAPSHOT from private-repo, using Tue Jan 31 20:14:57 UTC 2017
[warn] Unable to reparse org.scala-lang#scala-compiler;2.12.2-6d8c565-SNAPSHOT from private-repo, using Tue Jan 31 20:21:12 UTC 2017
[warn] Unable to reparse org.scala-lang#scala-reflect;2.12.2-6d8c565-SNAPSHOT from private-repo, using Tue Jan 31 20:16:56 UTC 2017
[info] Compiling 582 Scala sources and 120 Java sources to /home/jenkins/workspace/scala-2.12.x-validate-test@2/build/quick/classes/library...
[info] 'compiler-interface' not yet compiled for Scala 2.12.2-20170131-120524-6d8c565. Compiling...
[info]   Compilation completed in 10.721 s
[error] /home/jenkins/workspace/scala-2.12.x-validate-test@2/src/library/scala/Predef.scala:11: object language is not a member of package scala
[error] Note: class language exists, but it has no companion object.
[error] import scala.language.implicitConversions
[error]              ^
[error] /home/jenkins/workspace/scala-2.12.x-validate-test@2/src/library/scala/Predef.scala:18: object elidable is not a member of package annotation
[error] Note: class elidable exists, but it has no companion object.
[error] import scala.annotation.elidable.ASSERTION
[error]                         ^
[error] two errors found

@adriaanm adriaanm added the WIP label Feb 8, 2017
@adriaanm adriaanm modified the milestones: 2.12.2, WIP Feb 16, 2017
@som-snytt som-snytt closed this Apr 10, 2017
@som-snytt
Copy link
Contributor Author

@adriaanm I don't know if this is useful pre-Adriaanite.

case s => s
}
} else {
lines drop header.lines.size
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh hey, this is where you cleaned up that code a little bit.

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

Successfully merging this pull request may close these issues.

6 participants