Manuel Schmidt Manuel Schmidt - 24 days ago 5
Scala Question

Guava BloomFilter - Error in Scala compiler: trying to do lub/glb of typevar ?T

Using scala 2.11.8, guava 20.0 and sbt 0.13.13,
the following snippet causes the compile to crash:

import com.google.common.hash.BloomFilter
object Test {
def test() {
BloomFilter.create(null, 1, 1)
}
}


with the error:


Error in Scala compiler: trying to do lub/glb of typevar ?T

SBT builder crashed while compiling. The error message is 'trying to do lub/glb of typevar ?T'
Unknown Scala Problem


Any idea what causes this problem?

The full log:


[error] trying to do lub/glb of typevar ?T
scala.reflect.internal.FatalError: trying to do lub/glb of typevar ?T
at scala.reflect.internal.Reporting$class.abort(Reporting.scala:59)
at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:16) at
scala.reflect.internal.tpe.GlbLubs$class.stripType$1(GlbLubs.scala:224)
at
scala.reflect.internal.tpe.GlbLubs$$anonfun$18.apply(GlbLubs.scala:227)
at
scala.reflect.internal.tpe.GlbLubs$$anonfun$18.apply(GlbLubs.scala:227)
at scala.collection.immutable.List.loop$1(List.scala:173) at
scala.collection.immutable.List.mapConserve(List.scala:189) at
scala.reflect.internal.tpe.GlbLubs$class.stripExistentialsAndTypeVars(GlbLubs.scala:227)
at scala.reflect.internal.tpe.GlbLubs$class.lub1$1(GlbLubs.scala:328)
at scala.reflect.internal.tpe.GlbLubs$class.lub0$1(GlbLubs.scala:322)
at scala.reflect.internal.tpe.GlbLubs$class.lub(GlbLubs.scala:419)
at scala.reflect.internal.SymbolTable.lub(SymbolTable.scala:16) at
scala.reflect.internal.tpe.GlbLubs$class.lub(GlbLubs.scala:279) at
scala.reflect.internal.SymbolTable.lub(SymbolTable.scala:16) at
scala.reflect.internal.tpe.TypeConstraints$class.solveOne$1(TypeConstraints.scala:248)
at
scala.reflect.internal.tpe.TypeConstraints$$anonfun$solve$1.apply(TypeConstraints.scala:260)
at
scala.reflect.internal.tpe.TypeConstraints$$anonfun$solve$1.apply(TypeConstraints.scala:260)
at
scala.reflect.internal.util.Collections$class.foreach3(Collections.scala:231)
at scala.reflect.internal.SymbolTable.foreach3(SymbolTable.scala:16)
at
scala.reflect.internal.tpe.TypeConstraints$class.solve(TypeConstraints.scala:260)
at scala.reflect.internal.SymbolTable.solve(SymbolTable.scala:16) at
scala.reflect.internal.Types$ExistentialType.withTypeVars(Types.scala:2699)
at
scala.reflect.internal.tpe.TypeComparers$class.thirdTry$1(TypeComparers.scala:483)
at
scala.reflect.internal.tpe.TypeComparers$class.secondTry$1(TypeComparers.scala:450)
at
scala.reflect.internal.tpe.TypeComparers$class.firstTry$1(TypeComparers.scala:426)
at
scala.reflect.internal.tpe.TypeComparers$class.isSubType2(TypeComparers.scala:552)
at
scala.reflect.internal.tpe.TypeComparers$class.isSubType1(TypeComparers.scala:320)
at
scala.reflect.internal.tpe.TypeComparers$class.isSubType(TypeComparers.scala:278)
at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:16)
at
scala.reflect.internal.tpe.TypeComparers$class.secondTry$1(TypeComparers.scala:445)
at
scala.reflect.internal.tpe.TypeComparers$class.firstTry$1(TypeComparers.scala:426)
at
scala.reflect.internal.tpe.TypeComparers$class.isSubType2(TypeComparers.scala:552)
at
scala.reflect.internal.tpe.TypeComparers$class.isSubType1(TypeComparers.scala:320)
at
scala.reflect.internal.tpe.TypeComparers$class.isSubType(TypeComparers.scala:278)
at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:16)
at
scala.reflect.internal.tpe.TypeComparers$class.isWeakSubType(TypeComparers.scala:575)
at
scala.reflect.internal.SymbolTable.isWeakSubType(SymbolTable.scala:16)
at
scala.reflect.internal.Types$Type.weak_$less$colon$less(Types.scala:825)
at
scala.tools.nsc.typechecker.Infer$Inferencer.scala$tools$nsc$typechecker$Infer$Inferencer$$isCompatible(Infer.scala:305)
at
scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$methTypeArgs$2.apply(Infer.scala:545)
at
scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$methTypeArgs$2.apply(Infer.scala:539)
at
scala.reflect.internal.util.Collections$class.map2(Collections.scala:79)
at scala.reflect.internal.SymbolTable.map2(SymbolTable.scala:16) at
scala.tools.nsc.typechecker.Infer$Inferencer.methTypeArgs(Infer.scala:539)
at
scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$tryInstantiating$1$1.apply$mcZ$sp(Infer.scala:736)
at
scala.tools.nsc.typechecker.Infer$class.falseIfNoInstance(Infer.scala:114)
at scala.tools.nsc.Global$$anon$1.falseIfNoInstance(Global.scala:462)
at
scala.tools.nsc.typechecker.Infer$Inferencer.tryInstantiating$1(Infer.scala:734)
at
scala.tools.nsc.typechecker.Infer$Inferencer.typesCompatible$1(Infer.scala:746)
at
scala.tools.nsc.typechecker.Infer$Inferencer.isApplicableToMethod(Infer.scala:757)
at
scala.tools.nsc.typechecker.Infer$Inferencer.scala$tools$nsc$typechecker$Infer$Inferencer$$isApplicable(Infer.scala:776)
at
scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$scala$tools$nsc$typechecker$Infer$Inferencer$$isApplicable$2.apply(Infer.scala:778)
at
scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$scala$tools$nsc$typechecker$Infer$Inferencer$$isApplicable$2.apply(Infer.scala:778)
at
scala.reflect.internal.Symbols$class.createFromClonedSymbols(Symbols.scala:3662)
at
scala.reflect.internal.SymbolTable.createFromClonedSymbols(SymbolTable.scala:16)
at
scala.tools.nsc.typechecker.Infer$Inferencer.scala$tools$nsc$typechecker$Infer$Inferencer$$isApplicable(Infer.scala:778)
at
scala.tools.nsc.typechecker.Infer$Inferencer.checkIsApplicable$1(Infer.scala:807)
at
scala.tools.nsc.typechecker.Infer$Inferencer.isAsSpecific(Infer.scala:827)
at
scala.tools.nsc.typechecker.Infer$Inferencer.isStrictlyMoreSpecific(Infer.scala:865)
at
scala.tools.nsc.typechecker.Infer$Inferencer$InferMethodAlternativeTwice$1.scala$tools$nsc$typechecker$Infer$Inferencer$InferMethodAlternativeTwice$$rankAlternatives(Infer.scala:1401)
at
scala.tools.nsc.typechecker.Infer$Inferencer$InferMethodAlternativeTwice$1$$anonfun$36.apply(Infer.scala:1404)
at
scala.tools.nsc.typechecker.Infer$Inferencer$InferMethodAlternativeTwice$1$$anonfun$36.apply(Infer.scala:1404)
at scala.tools.nsc.typechecker.Infer$class.improves$1(Infer.scala:62)
at scala.tools.nsc.typechecker.Infer$$anonfun$4.apply(Infer.scala:65)
at scala.tools.nsc.typechecker.Infer$$anonfun$4.apply(Infer.scala:65)
at scala.math.Ordering$$anon$9.compare(Ordering.scala:200) at
java.util.TimSort.countRunAndMakeAscending(Unknown Source) at
java.util.TimSort.sort(Unknown Source) at
java.util.Arrays.sort(Unknown Source) at
scala.collection.SeqLike$class.sorted(SeqLike.scala:648) at
scala.collection.AbstractSeq.sorted(Seq.scala:41) at
scala.collection.SeqLike$class.sortWith(SeqLike.scala:601) at
scala.collection.AbstractSeq.sortWith(Seq.scala:41) at
scala.tools.nsc.typechecker.Infer$class.scala$tools$nsc$typechecker$Infer$$bestAlternatives(Infer.scala:65)
at
scala.tools.nsc.typechecker.Infer$Inferencer$InferMethodAlternativeTwice$1.bestForExpectedType(Infer.scala:1404)
at
scala.tools.nsc.typechecker.Infer$Inferencer$InferMethodAlternativeTwice$1.tryOnce(Infer.scala:1416)
at
scala.tools.nsc.typechecker.Contexts$Context$TryTwice.apply(Contexts.scala:357)
at
scala.tools.nsc.typechecker.Infer$Inferencer.inferMethodAlternative(Infer.scala:1420)
at
scala.tools.nsc.typechecker.Typers$Typer.handleOverloaded$1(Typers.scala:3297)
at
scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3301)
at
scala.tools.nsc.typechecker.Typers$Typer$$anonfun$98.apply(Typers.scala:4496)
at
scala.tools.nsc.typechecker.Typers$Typer$$anonfun$98.apply(Typers.scala:4496)
at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
at
scala.tools.nsc.typechecker.Typers$Typer.tryTypedApply$1(Typers.scala:4496)
at
scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4544)
at
scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4580)
at
scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
at
scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at
scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at
scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5605)
at
scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2208)
at
scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5308)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
at
scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at
scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at
scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
at
scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
at
scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
at
scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
at scala.collection.immutable.List.loop$1(List.scala:173) at
scala.collection.immutable.List.mapConserve(List.scala:189) at
scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3151)
at
scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1921)
at
scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1808)
at
scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5310)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
at
scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at
scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at
scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
at
scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
at
scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
at
scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
at scala.collection.immutable.List.loop$1(List.scala:173) at
scala.collection.immutable.List.mapConserve(List.scala:189) at
scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3151)
at
scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5015)
at
scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5312)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
at
scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at
scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5448)
at
scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102)
at
scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:440)
at
scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:431)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:440)
at
scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:94)
at
scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:93)
at scala.collection.Iterator$class.foreach(Iterator.scala:893) at
scala.collection.AbstractIterator.foreach(Iterator.scala:1336) at
scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1501)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1486) at
scala.tools.nsc.Global$Run.compileSources(Global.scala:1481) at
scala.tools.nsc.Global$Run.compile(Global.scala:1582) at
xsbt.CachedCompiler0.run(CompilerInterface.scala:116) at
xsbt.CachedCompiler0.run(CompilerInterface.scala:95) at
xsbt.CompilerInterface.run(CompilerInterface.scala:26) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:107) at
sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:53) at
sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47) at
sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply$mcV$sp(MixedAnalyzingCompiler.scala:50)
at
sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
at
sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
at
sbt.compiler.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:74)
at
sbt.compiler.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:49)
at
sbt.compiler.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:64)
at
sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
at
sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
at
sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:66)
at
sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:64)
at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:32) at
sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:72) at
sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:71) at
sbt.inc.Incremental$.manageClassfiles(Incremental.scala:99) at
sbt.inc.Incremental$.compile(Incremental.scala:71) at
sbt.inc.IncrementalCompile$.apply(Compile.scala:54) at
sbt.compiler.IC$.compileInternal(IncrementalCompiler.scala:160) at
sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138) at
sbt.Compiler$.compile(Compiler.scala:155) at
sbt.Compiler$.compile(Compiler.scala:141) at
sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:879)
at
sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:870)
at
sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:868)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) at
sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40) at
sbt.std.Transform$$anon$4.work(System.scala:63) at
sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at
sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17) at
sbt.Execute.work(Execute.scala:237) at
sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228) at
sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228) at
sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28) at
java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
java.lang.Thread.run(Unknown Source) [error] (test:compileIncremental)
scala.reflect.internal.FatalError: trying to do lub/glb of typevar ?T
[error] Total time: 3 s, completed Nov 14, 2016 10:05:52 AM

Answer

The create method has got a generic type T and the scala compiler is failing to infer it from the null value you give as a first argument. If you help it a little, it compiles fine:

import com.google.common.hash.BloomFilter

object Test {

  def test(): Unit = {
    BloomFilter.create[Nothing](null, 1, 1)
  }

}