Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented May 12, 2018

Complete the reporting refactor to use internal.Reporter.

The partest blocker was fixed in v1.0.14. sbt and IDE
are not validated, so reporters.Reporter is not removed.

Edit: Global takes reporting.Reporter so clients of Global are safe, including sbt's cancel and scaladoc's comment, and including macroAnnot.

internal.Reporter is adapted in reporting.Reporter companion.

AbstractReporter and ConsoleReporter innards are refactored to handy traits, which are used in the new paradigm.

Follow-up to scala/scala-partest#56

@scala-jenkins scala-jenkins added this to the 2.13.0-M5 milestone May 12, 2018
@som-snytt som-snytt force-pushed the topic/nail-reporter branch from 936804b to 97b9eb8 Compare May 12, 2018 20:38
@som-snytt
Copy link
Contributor Author

This oughta be fun:

[test] [error] 1 of 12 test tasks failed:
[test] [error] - macroAnnot/test
[test] [error]   - macroAnnot/compile:compileIncremental failed: java.lang.NoSuchMethodError: scala.tools.nsc.Global.<init>(Lscala/tools/nsc/Settings;Lscala/tools/nsc/reporters/Reporter;)V
[test] java.lang.RuntimeException
[test] 	at $33f7ec16b05f4d72fd8b$$anonfun$root$26.apply(build.sbt:919)
[test] 	at $33f7ec16b05f4d72fd8b$$anonfun$root$26.apply(build.sbt:858)
[test] 	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[test] 	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
[test] 	at sbt.std.Transform$$anon$4.work(System.scala:63)
[test] 	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
[test] 	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
[test] 	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
[test] 	at sbt.Execute.work(Execute.scala:237)
[test] 	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
[test] 	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
[test] 	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
[test] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
[test] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[test] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[test] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[test] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[test] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[test] 	at java.lang.Thread.run(Thread.java:748)
[test] [error] (root/*:testAll) java.lang.RuntimeException
[test] [error] Total time: 1430 s, completed May 12, 2018 9:08:52 PM

@som-snytt
Copy link
Contributor Author

som-snytt commented May 12, 2018

Unrelatedly, I wanted to benchmark for refactor AbstractReporter to a filter, but managed to get jmh to fail with a VerifyError. I don't know if this is a usual interaction? When I'm more comfortable with jmh I'll update.

java.lang.VerifyError: Inconsistent stackmap frames at branch target 81
Exception Details:
  Location:
    scala/tools/nsc/reporters/ReportingBenchmark.init()V @81: aload_1
  Reason:
    Type 'scala/tools/nsc/reporters/ReportingBenchmark$$anon$1' (current frame, locals[1]) is not assignable to 'scala/reflect/internal/Reporter' (stack map, locals[1])

I guess it happens sometimes.

@som-snytt som-snytt force-pushed the topic/nail-reporter branch 2 times, most recently from 30a5fb7 to 2da1f8c Compare May 15, 2018 15:48
@som-snytt
Copy link
Contributor Author

I did a quickie to restore the previous Global ctor, but now:

[test] [error] - macroAnnot/compile:compileIncremental failed: java.lang.NoSuchMethodError: xsbt.CachedCompiler0$Compiler.reporter_$eq(Lscala/tools/nsc/reporters/Reporter;)V

I guess I'll cross that bridge, too, now that I've come to it.

@som-snytt som-snytt force-pushed the topic/nail-reporter branch from 2da1f8c to 8e628c9 Compare May 15, 2018 16:41
@som-snytt
Copy link
Contributor Author

I guess that was it. Not sure exactly what is different for sbt about macro-annot, or what a migration path would be; but maybe just leave it as-is.

@som-snytt
Copy link
Contributor Author

@adriaanm re: scala/bug#10869 (comment)

This takes internal.Reporter so that you get error, warn, and echo. The built-in controls are -Xmaxerrs, -Xmaxwarns, and -nowarn, and -Xfatal-warnings.

A custom reporter could filter echo on some criterion if it wants to. Or maybe I already added reporters.VerboseReporter.

The compiler (after previous refactor) tests -verbose before echoing, rather than the reporter checking verbosity.

I think the simplicity will benefit any solution for "warning suppression", in avoiding the "where is my output?" moments you get with logging systems.

@adriaanm
Copy link
Contributor

Regarding macroAnnot, Lukas diagnosed it as a limitation with the sbt compiler interface. The macro annot project uses the quick compiler for its scala instance, but the rest of the project uses starr. The macroAnnot tests should be ported to partest, and the quick scalaInstance dropped.

@som-snytt
Copy link
Contributor Author

@adriaanm thx for the xplanation. Also, my previous pun, "cross that bridge [method]", was a good one. Maybe an old one.

@lrytz
Copy link
Member

lrytz commented May 30, 2018

I'm not sure what to think of this PR. Maybe I misunderstand it / its goals.

The PR adds casts and type tests, and IMO doesn't make the code easier to understand, while nsc.reporters.Reporter is still there. It also duplicates some functionality (eg from ConsoleReporter into DisplayReporter). I fear that the resulting code we end up having is even more confusing than the current state, and it doesn't really bring us closer to removing nsc.reporters.Reporter, since sbt continues to use it (https://github.com/sbt/sbt/blob/1.x/main-actions/src/main/scala/sbt/compiler/Eval.scala#L15). I think it would be better work on the other end first (remove usages of reporters.Reporter, think what to do for def comment, var cancelled), and clean up the hierarchy when we actually can.

@som-snytt
Copy link
Contributor Author

@lrytz I see there are two commits, one to address the TODO about fixing internal.Reporter when partest is fixed (which is possible now); the second refactors the AbstractReporter/ConsoleReporter.

The comments about sbt/ide/partest now just say sbt/ide. If you can't do anything because sbt, then I'd give up.

I could let Global still take reporters.Reporter natively and adapt internal.Reporter; that would avoid the downcasting for cancel and comment.

@lrytz
Copy link
Member

lrytz commented May 30, 2018

That sounds better. Let's do the actual cleanups, but not anticipate future ones by adding more code.

@som-snytt som-snytt force-pushed the topic/nail-reporter branch 3 times, most recently from 4c84848 to fa805ee Compare May 31, 2018 18:55
@som-snytt som-snytt added the WIP label May 31, 2018
@som-snytt som-snytt force-pushed the topic/nail-reporter branch 3 times, most recently from 833a906 to 20e895b Compare June 1, 2018 16:42
@som-snytt som-snytt removed the WIP label Jun 1, 2018
@som-snytt
Copy link
Contributor Author

My broom broke.

Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@lrytz
Copy link
Member

lrytz commented Jun 6, 2018

Ah, merge conflict.. Also maybe @adriaanm wants to take a quick scan of the change (maybe not).

Complete the reporting refactor to use internal.Reporter.

The partest blocker was fixed in v1.0.14. sbt and IDE
are not validated, so reporters.Reporter is not removed.

There are internal dependencies on cancel and comment
functionality, which is resolved here by typecasing.
Both features need to be implemented otherwise.

ConsoleReporter is still a reporter.Reporter.
som-snytt added 5 commits June 6, 2018 09:13
Let legacy Reporter handle adaptations.

Reporter knows how to adapt new API and enforce maxerrs.
The onus of supporting legacy reporter is on legacy reporter.

Keep new reporters simple enough.

Old reporters remain legacy reporters.
Some tests expect to downcast to the reporter
they assigned to `global.reporter`. Also avoid
delegating to `NoReporter`.
The extended explanation attached to the first feature
warning would fool the reporter if the feature is reported
again at the same position.

Use a conventional leading `"----"` to demarcate the
explanation, and use only the prefix to see if the error
has already been issued at a position.
@som-snytt som-snytt force-pushed the topic/nail-reporter branch from 1604aa7 to 7ca0a7f Compare June 6, 2018 16:19
@som-snytt
Copy link
Contributor Author

Rebased, accommodated recent change to avoid System.exit.

@adriaanm
Copy link
Contributor

adriaanm commented Jun 6, 2018

Interesting failure in https://scala-ci.typesafe.com/job/scala-2.13.x-validate-main/2311/testReport/junit/scala.collection/FloatFormatTest/toOption/

Could this be due to recent changes to LazyList?

@adriaanm
Copy link
Contributor

adriaanm commented Jun 6, 2018

/cc @szeiger could you take a look?

@som-snytt
Copy link
Contributor Author

som-snytt commented Jun 6, 2018

I think it's just a bug in #6726

/cc @martijnhoekstra

#6746

@som-snytt
Copy link
Contributor Author

/rebuild

@lrytz lrytz merged commit 235e69d into scala:2.13.x Jun 8, 2018
@som-snytt
Copy link
Contributor Author

Noting that this PR did not change the default for -Xreporter, since it would require adapting for Global.

@som-snytt som-snytt deleted the topic/nail-reporter branch June 8, 2018 14:05
@retronym
Copy link
Member

I noticed that in the 2.13.x branch, the benchmark harness which sets settings.nowarn = true no longer manages to suppress warnings. I guessing that it is related to this PR, but haven't figured out the details.

@som-snytt
Copy link
Contributor Author

@retronym I'll take a look. I also neglected to update ReplReporter, which I'm doing now.

@som-snytt
Copy link
Contributor Author

@retronym Don't be mad, but apparently it was intentional to provide a minimal reporter for displaying errors before the compiler is built. Normally the real reporter is created with Global, and then Driver.process adopts global.reporter, replacing the temporary. In this case, Global is created with the current, minimal reporter; the benchmark global wouldn't respect -Xreporter if it were set, for instance.

I'll do the obvious thing and revert to creating a full-featured reporter for that start-up sequence. Not sure if there's a reason not to use Global.reporter (on the companion) right away.

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.

5 participants