Skip to content

NPE on sealed trait in locally #9572

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

Closed
harpocrates opened this issue Aug 16, 2020 · 4 comments · Fixed by #10912
Closed

NPE on sealed trait in locally #9572

harpocrates opened this issue Aug 16, 2020 · 4 comments · Fixed by #10912

Comments

@harpocrates
Copy link
Contributor

Minimized code

Minimized from sbt ++0.26.0-RC1 json-schemaJVM/compile on endpoints4s.

trait JsonSchemas {
  locally {
    sealed trait Status
    case object Active extends Status
  }
}

Output (click arrow to expand)

Dotty stack trace.

java.lang.NullPointerException
	at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:113)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:106)
	at dotty.tools.dotc.core.Symbols$Symbol.isType(Symbols.scala:154)
	at dotty.tools.dotc.core.Types$NamedType$.isType(Types.scala:2513)
	at dotty.tools.dotc.core.Types$NamedType$.apply(Types.scala:2517)
	at dotty.tools.dotc.core.Types$Type.select(Types.scala:1410)
	at dotty.tools.dotc.core.Substituters$.substSym(Substituters.scala:81)
	at dotty.tools.dotc.core.Substituters$SubstSymMap.apply(Substituters.scala:177)
	at dotty.tools.dotc.core.Types$TypeMap.op$4(Types.scala:4948)
	at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4948)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4956)
	at dotty.tools.dotc.core.Substituters$.substSym(Substituters.scala:101)
	at dotty.tools.dotc.core.Types$Type.substSym(Types.scala:1585)
	at dotty.tools.dotc.ast.TreeTypeMap.mapType(TreeTypeMap.scala:63)
	at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:90)
	at dotty.tools.dotc.ast.TreeTypeMap.apply(TreeTypeMap.scala:149)
	at dotty.tools.dotc.ast.TreeTypeMap.apply(TreeTypeMap.scala:151)
	at dotty.tools.dotc.core.Symbols$$anon$2.complete$$anonfun$1(Symbols.scala:867)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.core.Symbols$$anon$2.complete(Symbols.scala:867)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:166)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:352)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.registeredCompanion(SymDenotations.scala:2128)
	at dotty.tools.dotc.core.Symbols$.mapSymbols$$anonfun$2(Symbols.scala:879)
	at dotty.runtime.function.JProcedure2.apply(JProcedure2.java:15)
	at dotty.runtime.function.JProcedure2.apply(JProcedure2.java:10)
	at scala.collection.LazyZip2.foreach(LazyZipOps.scala:112)
	at dotty.tools.dotc.core.Symbols$.mapSymbols(Symbols.scala:879)
	at dotty.tools.dotc.ast.TreeTypeMap.withMappedSyms(TreeTypeMap.scala:180)
	at dotty.tools.dotc.ast.TreeTypeMap.transformDefs(TreeTypeMap.scala:136)
	at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:107)
	at dotty.tools.dotc.ast.TreeTypeMap.apply(TreeTypeMap.scala:149)
	at dotty.tools.dotc.ast.tpd$TreeOps$.loop$1(tpd.scala:804)
	at dotty.tools.dotc.ast.tpd$TreeOps$.changeOwner$extension(tpd.scala:805)
	at dotty.tools.dotc.typer.Inliner.integrate(Inliner.scala:612)
	at dotty.tools.dotc.typer.Inliner$reducer$InlineableArg$.unapply(Inliner.scala:886)
	at dotty.tools.dotc.typer.Inliner$reducer$.tryInline(Inliner.scala:901)
	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedIdent(Inliner.scala:1195)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2392)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2483)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2550)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
	at dotty.tools.dotc.typer.Typer.typedInlined(Typer.scala:1594)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2444)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2484)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2550)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
	at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:60)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2428)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2484)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:122)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2550)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
	at dotty.tools.dotc.typer.Inliner.op$1(Inliner.scala:738)
	at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:754)
	at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:127)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$4(Typer.scala:3221)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3328)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3552)
	at dotty.tools.dotc.typer.Typer.op$3(Typer.scala:2883)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2884)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2605)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2627)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2081)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2411)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2415)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2483)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2579)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2627)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2207)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2455)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2484)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2671)
	at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:78)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:83)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:84)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:119)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:119)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:181)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:191)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:199)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:206)
	at dotty.tools.dotc.Run.compileSources(Run.scala:143)
	at dotty.tools.dotc.Run.compile(Run.scala:125)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Main.process(Main.scala)
	at xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
	at xsbt.CompilerInterface.run(CompilerInterface.java:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
	at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
	at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
	at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
	at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
	at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
	at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
	at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
	at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
	at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
	at sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
	at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
	at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
	at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
	at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
	at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
	at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1765)
	at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1738)
	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
	at sbt.std.Transform$$anon$4.work(Transform.scala:67)
	at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
	at sbt.Execute.work(Execute.scala:290)
	at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
@nicolasstucki
Copy link
Contributor

Self-contained example:

inline def foo[T](inline body: T): T = body

def test = foo {
  sealed trait Status
  object Active extends Status
}

@hmemcpy
Copy link

hmemcpy commented Nov 28, 2020

Sorry for the bump, I just ran into a similar issue (#10542), but in my case the body is a by-name parameter, and it doesn't have an inline keyword on it. Any workaround would be appreciated, also please feel free to close my issue as duplicate.

@griggt
Copy link
Contributor

griggt commented Nov 28, 2020

Also, the original issue reported here (using locally) no longer applies since #10302 was merged and locally comes from Predef now.

@smarter
Copy link
Member

smarter commented Dec 21, 2020

Closing this as a duplicate of #10542 since it has more discussion on the root cause.

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

Successfully merging a pull request may close this issue.

6 participants