Skip to content

Dealias chain all the things when looking for Any#8538

Merged
lrytz merged 1 commit intoscala:2.13.xfrom
som-snytt:issue/11798-infer-any
Nov 19, 2019
Merged

Dealias chain all the things when looking for Any#8538
lrytz merged 1 commit intoscala:2.13.xfrom
som-snytt:issue/11798-infer-any

Conversation

@som-snytt
Copy link
Contributor

When examining trees for explicit top types,
look at all aliases.

Fixes scala/bug#11798

@scala-jenkins scala-jenkins added this to the 2.13.2 milestone Nov 12, 2019
@hrhino
Copy link
Contributor

hrhino commented Nov 12, 2019

Your secret identity is showing.

@som-snytt
Copy link
Contributor Author

I must be committing from my smart phone.

When examining trees for explicit top types,
look at all aliases.
@som-snytt som-snytt force-pushed the issue/11798-infer-any branch from be5941c to b901802 Compare November 12, 2019 20:46
@som-snytt
Copy link
Contributor Author

I, too, broke the new type-tag-leak test.

@som-snytt
Copy link
Contributor Author

som-snytt commented Nov 14, 2019

I wonder if @hrhino the sharp-eyed one is willing to visually verify this quick fix. Ignoring the spurious travis failure, of course.

Every Scala 2 change is either too big to push through, or too trivial to be worth a PR. And my lunch breaks are finitely bounded.

@som-snytt som-snytt requested a review from hrhino November 14, 2019 17:14
@lrytz lrytz merged commit 9af26f8 into scala:2.13.x Nov 19, 2019
@adamgfraser
Copy link

Fantastic! Thank you so much!

@som-snytt som-snytt deleted the issue/11798-infer-any branch November 19, 2019 12:55
@SethTisue
Copy link
Member

SethTisue commented Nov 22, 2019

Cleanup in aisle #nogooddeedgoesunpunished

This caused a regression in the 2.13 community build, compiling Akka. I identified the culprit PR using git bisect. ("Culprit", such a harsh word. Perhaps "our next contestant"?)

https://scala-ci.typesafe.com/job/scala-2.13.x-integrate-community-build/2819/artifact/logs/akka-stream-build.log

[error] java.lang.StackOverflowError
[error] 	at scala.tools.nsc.typechecker.Infer$Inferencer$$anon$1.super$apply(Infer.scala:591)
[error] 	at scala.tools.nsc.typechecker.Infer$Inferencer$$anon$1.$anonfun$apply$1(Infer.scala:591)
[error] 	at scala.tools.nsc.typechecker.Infer$Inferencer$$anon$1.apply(Infer.scala:591)
[error] 	at scala.reflect.internal.Types$TypeRef.foldOver(Types.scala:2373)
[error] 	at scala.reflect.internal.tpe.TypeMaps$ExistsTypeRefCollector.apply(TypeMaps.scala:1043)
[error] 	at scala.tools.nsc.typechecker.Infer$Inferencer$$anon$1.super$apply(Infer.scala:591)
[error] 	at scala.tools.nsc.typechecker.Infer$Inferencer$$anon$1.$anonfun$apply$1(Infer.scala:591)
...

the problem is reproducible on the 2.13.x branch of scala/community-build with ./narrow akka-stream followed by ./run.sh

it's also reproducible outside of dbuild with:

hub clone akka/akka
cd akka
git checkout release-2.5

then:

diff --git project/AkkaDisciplinePlugin.scala project/AkkaDisciplinePlugin.scala
index 84d4db8ff4..3146b40427 100644
--- project/AkkaDisciplinePlugin.scala
+++ project/AkkaDisciplinePlugin.scala
@@ -43,11 +43,11 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
     })
 
   lazy val silencerSettings = {
-    val silencerVersion = "1.4.1"
+    val silencerVersion = "1.4.4"
     Seq(
       libraryDependencies ++= Seq(
-          compilerPlugin("com.github.ghik" %% "silencer-plugin" % silencerVersion),
-          "com.github.ghik" %% "silencer-lib" % silencerVersion % Provided))
+          compilerPlugin("com.github.ghik" % "silencer-plugin_2.13.1" % silencerVersion),
+          "com.github.ghik" % "silencer-lib_2.13.1" % silencerVersion % Provided))
   }

and:

sbt
++2.13.2-bin-9af26f8!
akka-stream/compile

@som-snytt
Copy link
Contributor Author

I was just saying how nice it is when people complain you broke something, because it means what you do really matters.

Noting here that Lukas asked for a performance check; and previously Jason has asked that all this type tracking or double-checking be rewritten.

I'll add this to my post-it note. Let me know if you'd like a quick reversion, or wait a bit to see if anything shakes out. I'm wondering if the check can be deferred until the end of typers via that deferred work queue.

@SethTisue
Copy link
Member

SethTisue commented Nov 22, 2019

2.13.2 isn't imminent, and 150 projects remain green in the community build, so I don't think a quick reversion is necessary.

@som-snytt
Copy link
Contributor Author

som-snytt commented Nov 23, 2019

Instead, I got:

[info] Out of 1 candidates we found for org.scala-lang#scala-compiler;2.13.2-bin-767bd9f-SNAPSHOT in local, we are choosing local.
[info] Done updating.
[info] Formatting 22 Java sources ProjectRef(uri("file:/home/amarki/projects/akka/"), "akka-actor")(compile) ...
[info] Generating 'Functions.scala'
[info] Generating 'Tuples.scala'
[error] java.util.NoSuchElementException: key not found: 8
[error]         at scala.collection.immutable.Map$EmptyMap$.apply(Map.scala:98)
[error]         at scala.collection.immutable.Map$EmptyMap$.apply(Map.scala:96)
[error]         at akka.AkkaBuild$.$anonfun$defaultSettings$6(AkkaBuild.scala:146)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:278)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]         at java.base/java.lang.Thread.run(Thread.java:834)

Trying just root compile now. Actually that eventually fails.

@SethTisue
Copy link
Member

that eventually fails

eventually fails with SOE, so you're good to proceed?
or eventually fails with NSE, and you need help testing a prospective fix?

@som-snytt
Copy link
Contributor Author

I wasn't able to build independently to diagnose the failure. I hadn't entirely given up yet, akka happens to be cloned on my other machine.

@SethTisue
Copy link
Member

SethTisue commented Dec 2, 2019

above I said hub clone akka/akka; cd akka; git checkout release-2.5 but that branch has moved on a bit. the above instructions still apply except that the build patch is a bit different:

--- project/AkkaDisciplinePlugin.scala
+++ project/AkkaDisciplinePlugin.scala
@@ -46,8 +46,8 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
     val silencerVersion = "1.4.4"
     Seq(
       libraryDependencies ++= Seq(
-          compilerPlugin(("com.github.ghik" %% "silencer-plugin" % silencerVersion).cross(CrossVersion.patch)),
-          ("com.github.ghik" %% "silencer-lib" % silencerVersion % Provided).cross(CrossVersion.patch)))
+          compilerPlugin(("com.github.ghik" % "silencer-plugin_2.13.1" % silencerVersion)),
+          ("com.github.ghik" % "silencer-lib_2.13.1" % silencerVersion % Provided)))

this is at dfedb66e24ff196888e987a6183c514857a83078, so you might git checkout dfedb66e24ff1968 instead of git checkout release-2.5

in the 2.13 community build, I temporarily reverted to an older Scala SHA until we can get this sorted out. let me know if I can be of any other assistance (up to and including "I don't have time for this at present, can someone at Lightbend take it over?")

@som-snytt
Copy link
Contributor Author

I was able to reproduce under Ubuntu instead of Ubuntu under windoze.

akka.stream.impl.SetupStage has a refinement type which causes the loopy recursion when folding over it. Just skipping refinement types avoids that, so I'll PR that. My first attempt to minimize the test didn't reproduce it.

@SethTisue
Copy link
Member

fixed in #8577

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.

Spurious Warning for Type Being Inferred As Any

6 participants