Skip to content

Presentation compiler crash on Java annotations #4713

@scabug

Description

@scabug

The presentation compiler crashes in the type checker on the second run.

First compile the following Java file:

// JavaAnnots.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.List;

public abstract class JavaAnnots {
  @Retention(RetentionPolicy.RUNTIME)
  @Target(ElementType.FIELD)
  public @interface Book {
  }

  public static final List<String> Book = null;
}

Then fire up the interactive repl ('scala scala.tools.nsc.interactive.REPL') and pass the following file twice:

// Problem.scala
object Problem {
  def d() {
    val v: java.util.List[String] = JavaAnnots.Book
  }
}

Here's what happens:


> reload annot-prob.scala
==> ()
> reload annot-prob.scala
==> ()
> java.lang.Error: no-symbol does not have owner
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:31)
	at scala.reflect.internal.Symbols$NoSymbol$.owner(Symbols.scala:2238)
	at scala.reflect.internal.Types$Type.memberInfo(Types.scala:562)
	at scala.reflect.internal.Types$TypeRef.relativeInfo(Types.scala:1741)
	at scala.reflect.internal.Types$TypeRef.baseType(Types.scala:1889)
	at scala.reflect.internal.Types$class.firstTry$1(Types.scala:4589)
	at scala.reflect.internal.Types$class.scala$reflect$internal$Types$$isSubType2(Types.scala:4745)
	at scala.reflect.internal.Types$$anonfun$isSubType$1.apply$mcZ$sp(Types.scala:4461)
	at scala.reflect.internal.Types$undoLog$.undoUnless(Types.scala:139)
	at scala.reflect.internal.Types$class.isSubType(Types.scala:4448)
	at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:11)
	at scala.reflect.internal.Types$class.isSubType(Types.scala:4443)
	at scala.reflect.internal.SymbolTable.isSubType(SymbolTable.scala:11)
	at scala.reflect.internal.Types$class.isWeakSubType(Types.scala:5158)
	at scala.reflect.internal.SymbolTable.isWeakSubType(SymbolTable.scala:11)
	at scala.reflect.internal.Types$Type.weak_$less$colon$less(Types.scala:683)
	at scala.tools.nsc.typechecker.Infer$Inferencer.isCompatible(Infer.scala:389)
	at scala.tools.nsc.typechecker.Infer$Inferencer.isWeaklyCompatible(Infer.scala:396)
	at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$inferExprAlternative$1$$anonfun$36.apply(Infer.scala:1531)
	at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$inferExprAlternative$1$$anonfun$36.apply(Infer.scala:1531)
	at scala.collection.TraversableLike$$anonfun$filter$1.apply(TraversableLike.scala:213)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:45)
	at scala.collection.TraversableLike$class.filter(TraversableLike.scala:212)
	at scala.collection.immutable.List.filter(List.scala:45)
	at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$inferExprAlternative$1.apply$mcV$sp(Infer.scala:1531)
	at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$inferExprAlternative$1.apply(Infer.scala:1530)
	at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$inferExprAlternative$1.apply(Infer.scala:1530)
	at scala.tools.nsc.typechecker.Contexts$Context.withImplicitsDisabled(Contexts.scala:153)
	at scala.tools.nsc.typechecker.Infer$Inferencer.tryTwice(Infer.scala:1669)
	at scala.tools.nsc.typechecker.Infer$Inferencer.inferExprAlternative(Infer.scala:1530)
	at scala.tools.nsc.typechecker.Typers$Typer.stabilize(Typers.scala:552)
	at scala.tools.nsc.typechecker.Typers$Typer.typedSelect$1(Typers.scala:3591)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4128)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4234)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:4391)
	at scala.tools.nsc.typechecker.Typers$Typer.typedValDef(Typers.scala:1561)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3879)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4234)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2094)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2178)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2178)
	at scala.collection.immutable.List.loop$1(List.scala:117)
	at scala.collection.immutable.List.mapConserve(List.scala:133)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2178)
	at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:1913)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3914)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4234)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:4391)
	at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1754)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3882)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4234)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2094)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2178)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2178)
	at scala.collection.immutable.List.loop$1(List.scala:117)
	at scala.collection.immutable.List.mapConserve(List.scala:133)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2178)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1506)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1314)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3876)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4234)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2094)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2178)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2178)
	at scala.collection.immutable.List.loop$1(List.scala:117)
	at scala.collection.immutable.List.mapConserve(List.scala:133)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2178)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3869)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4234)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4294)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:94)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:341)
	at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:945)
	at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:945)
	at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:945)
	at scala.reflect.internal.SymbolTable.atPhase(SymbolTable.scala:91)
	at scala.tools.nsc.interactive.Global$TyperRun.applyPhase(Global.scala:945)
	at scala.tools.nsc.interactive.Global$TyperRun.typeCheck(Global.scala:938)
	at scala.tools.nsc.interactive.Global.scala$tools$nsc$interactive$Global$$typeCheck(Global.scala:489)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$4$$anonfun$apply$6.apply(Global.scala:428)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$4$$anonfun$apply$6.apply(Global.scala:427)
	at scala.Option.foreach(Option.scala:200)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$4.apply(Global.scala:427)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$4.apply(Global.scala:427)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:45)
	at scala.tools.nsc.interactive.Global.backgroundCompile(Global.scala:427)
	at scala.tools.nsc.interactive.PresentationCompilerThread.run(PresentationCompilerThread.scala:25)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions