Skip to content

Fix #2234: Dealias before type erasing #2236

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

Merged
merged 3 commits into from
Apr 18, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 12, 2017

... and likewise for taking a signature. The previous case worked
in all cases except when faced with an alias like type Id[T] = T.
In that case, it would disregard the argument and erase to Object.

Fixes #2234.

@odersky
Copy link
Contributor Author

odersky commented Apr 12, 2017

We get persistent timeouts with the CI, that's why the tests fail.

@felixmulder
Copy link
Contributor

felixmulder commented Apr 12, 2017

@odersky - indeed! This is the thread dump from the only active thread in the workpool:

"ForkJoinPool-3-worker-4" #48 daemon prio=5 os_prio=31 tid=0x00007f9d5c931000 nid=0x1407 runnable [0x0000700004382000]
   java.lang.Thread.State: RUNNABLE
	at dotty.tools.dotc.core.Types$Type.widenSingleton(Types.scala:841)
	at dotty.tools.dotc.core.Types$Type.widen(Types.scala:833)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$apply(TypeErasure.scala:373)
	at dotty.tools.dotc.core.TypeErasure.eraseResult(TypeErasure.scala:469)
	at dotty.tools.dotc.core.TypeErasure.eraseInfo(TypeErasure.scala:439)
	at dotty.tools.dotc.core.TypeErasure$.transformInfo(TypeErasure.scala:185)
	at dotty.tools.dotc.transform.Erasure.transform(Erasure.scala:70)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:793)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:815)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:405)
	at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:615)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$paramAccessors$1.apply(SymDenotations.scala:1791)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$paramAccessors$1.apply(SymDenotations.scala:1791)
	at dotty.tools.dotc.core.Scopes$Scope.filter(Scopes.scala:96)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.paramAccessors(SymDenotations.scala:1791)
	at dotty.tools.dotc.core.Contexts$Context.superCallContext(Contexts.scala:337)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1273)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1271)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1271)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1517)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1571)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:96)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1590)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1588)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:136)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1588)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1612)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1632)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:597)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1432)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1419)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1419)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1556)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1572)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:96)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1590)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1588)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:136)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1588)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1644)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:91)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:283)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:281)
	at scala.collection.immutable.List.map(List.scala:273)
	at dotty.tools.dotc.core.Phases$Phase$class.runOn(Phases.scala:281)
	at dotty.tools.dotc.transform.Erasure.runOn(Erasure.scala:32)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:76)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:73)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:73)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
	at dotty.tools.dotc.Run.compileSources(Run.scala:64)
	at dotty.tools.dotc.Run.compile(Run.scala:48)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at dotty.tools.dotc.Driver.process(Driver.scala:93)
	at dotty.tools.vulpix.ParallelTesting$Test.compile(ParallelTesting.scala:380)
	at dotty.tools.vulpix.ParallelTesting$PosTest$$anon$3$$anonfun$checkTestSource$1.apply$mcV$sp(ParallelTesting.scala:441)
	at dotty.tools.vulpix.ParallelTesting$Test.tryCompile(ParallelTesting.scala:314)
	at dotty.tools.vulpix.ParallelTesting$PosTest$$anon$3.checkTestSource(ParallelTesting.scala:438)
	at dotty.tools.vulpix.ParallelTesting$Test$LoggedRunnable$class.run(ParallelTesting.scala:214)
	at dotty.tools.vulpix.ParallelTesting$PosTest$$anon$3.run(ParallelTesting.scala:437)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Dumping it a few moments later yields:

"ForkJoinPool-3-worker-4" #48 daemon prio=5 os_prio=31 tid=0x00007f9d5c931000 nid=0x1407 runnable [0x0000700004382000]
   java.lang.Thread.State: RUNNABLE
	at dotty.tools.dotc.core.Types$NamedType.info(Types.scala:1629)
	at dotty.tools.dotc.core.Types$Type.dealias(Types.scala:885)
	at dotty.tools.dotc.core.Types$Type.dealias(Types.scala:916)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$apply(TypeErasure.scala:358)
	at dotty.tools.dotc.core.TypeErasure.eraseResult(TypeErasure.scala:469)
	at dotty.tools.dotc.core.TypeErasure.eraseInfo(TypeErasure.scala:439)
	at dotty.tools.dotc.core.TypeErasure$.transformInfo(TypeErasure.scala:185)
	at dotty.tools.dotc.transform.Erasure.transform(Erasure.scala:70)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:793)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:815)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:405)
	at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:615)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$paramAccessors$1.apply(SymDenotations.scala:1791)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$paramAccessors$1.apply(SymDenotations.scala:1791)
	at dotty.tools.dotc.core.Scopes$Scope.filter(Scopes.scala:96)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.paramAccessors(SymDenotations.scala:1791)
	at dotty.tools.dotc.core.Contexts$Context.superCallContext(Contexts.scala:337)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1273)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1271)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1271)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1517)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1571)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:96)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1590)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1588)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:136)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1588)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1612)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1632)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:597)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1432)
	at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1419)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1419)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1556)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1572)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:96)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1590)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1588)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:136)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1588)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1644)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:91)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:283)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:281)
	at scala.collection.immutable.List.map(List.scala:273)
	at dotty.tools.dotc.core.Phases$Phase$class.runOn(Phases.scala:281)
	at dotty.tools.dotc.transform.Erasure.runOn(Erasure.scala:32)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:76)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:73)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:73)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
	at dotty.tools.dotc.Run.compileSources(Run.scala:64)
	at dotty.tools.dotc.Run.compile(Run.scala:48)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at dotty.tools.dotc.Driver.process(Driver.scala:93)
	at dotty.tools.vulpix.ParallelTesting$Test.compile(ParallelTesting.scala:380)
	at dotty.tools.vulpix.ParallelTesting$PosTest$$anon$3$$anonfun$checkTestSource$1.apply$mcV$sp(ParallelTesting.scala:441)
	at dotty.tools.vulpix.ParallelTesting$Test.tryCompile(ParallelTesting.scala:314)
	at dotty.tools.vulpix.ParallelTesting$PosTest$$anon$3.checkTestSource(ParallelTesting.scala:438)
	at dotty.tools.vulpix.ParallelTesting$Test$LoggedRunnable$class.run(ParallelTesting.scala:214)
	at dotty.tools.vulpix.ParallelTesting$PosTest$$anon$3.run(ParallelTesting.scala:437)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Locked ownable synchronizers:
- None



I'm not sure how, or why it is doing this. It fails locally for me now too.

@felixmulder
Copy link
Contributor

Been monitoring the running thread for a while and it seems to be stuck in erasure. Not sure what's causing this. Do we have something that's shared state all of a sudden?

@odersky
Copy link
Contributor Author

odersky commented Apr 12, 2017

Ah, I take it back. That's something I did to fix the bug. No good deed goes unpunished, as they say...

@smarter
Copy link
Member

smarter commented Apr 12, 2017

Test case seems to be missing

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM. One spurious test failure with java.lang.NullPointerException.

@felixmulder
Copy link
Contributor

The spurious test failure is due to lazy vals in dotty vs scalac. I fixed it in #2248

@DarkDimius
Copy link
Contributor

DarkDimius commented Apr 13, 2017

@felixmulder, could you please elaborate?
I don't see any lazy-val changes in https://github.com/lampepfl/dotty/pull/2248/files diff or commit messages.

@felixmulder
Copy link
Contributor

Ah sorry, it was not fixed in #2248 - it was fixed in #2238

odersky added 3 commits April 18, 2017 16:55
... and likewise for taking a signature. The previous case worked
in all cases except when faced with an alias like `type Id[T] = T`.
In that case, it would disregard the argument and erase to Object.
Special case HKApply only. This is simpler and potentially
more efficient.
@felixmulder felixmulder merged commit 6a0c581 into scala:master Apr 18, 2017
@allanrenucci allanrenucci deleted the fix-#2234 branch December 14, 2017 19:18
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