Skip to content
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

Recursive Java generics crash the compiler #942

Closed
scabug opened this issue May 20, 2008 · 3 comments
Closed

Recursive Java generics crash the compiler #942

scabug opened this issue May 20, 2008 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented May 20, 2008

A Java generic class that refers to its own type crashes the classfile parser.

Java:

interface Field<A> {
}

public class Amount<Q> extends Object 
    implements Field<Amount<?>> {
}

Scala:

abstract class Foo {
  val x: Amount[Foo]
}

The classfile parser will try to resolve the Amount class type while parsing Amount, resulting in a busy assertion:

Exception in thread "main" java.lang.AssertionError: assertion failed: internal error: illegal class file dependency in classes/Amount.class
        at scala.Predef$$.assert(Predef.scala:92)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.parse(ClassfileParser.scala:60)
        at scala.tools.nsc.symtab.SymbolLoaders$$ClassfileLoader$$$$anonfun$$doComplete$$3.apply(SymbolLoaders.scala:287)
        at scala.tools.nsc.symtab.SymbolLoaders$$ClassfileLoader$$$$anonfun$$doComplete$$3.apply(SymbolLoaders.scala:287)
        at scala.tools.nsc.symtab.SymbolLoaders.completeClassfile(SymbolLoaders.scala:278)
        at scala.tools.nsc.symtab.SymbolLoaders$$ClassfileLoader.doComplete(SymbolLoaders.scala:286)
        at scala.tools.nsc.symtab.SymbolLoaders$$SymbolLoader.complete(SymbolLoaders.scala:80)
        at scala.tools.nsc.symtab.SymbolLoaders$$SymbolLoader.load(SymbolLoaders.scala:100)
        at scala.tools.nsc.symtab.Symbols$$Symbol.typeParams(Symbols.scala:655)
        at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2262)
        at scala.tools.nsc.symtab.Types$$ForEachTypeTraverser.traverse(Types.scala:2997)
        at scala.tools.nsc.symtab.Types$$Type.foreach(Types.scala:470)
        at scala.tools.nsc.symtab.Types$$class.existentialAbstraction(Types.scala:2083)
        at scala.tools.nsc.symtab.SymbolTable.existentialAbstraction(SymbolTable.scala:12)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.processClassType$$1(ClassfileParser.scala:509)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$$1(ClassfileParser.scala:524)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.processClassType$$1(ClassfileParser.scala:503)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$$1(ClassfileParser.scala:524)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.scala$$tools$$nsc$$symtab$$classfile$$ClassfileParser$$$$sigToType(ClassfileParser.scala:583)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttribute$$1(ClassfileParser.scala:606)
        at scala.tools.nsc.symtab.classfile.ClassfileParser$$$$anonfun$$parseAttributes$$1.apply(ClassfileParser.scala:770)
        at scala.tools.nsc.symtab.classfile.ClassfileParser$$$$anonfun$$parseAttributes$$1.apply(ClassfileParser.scala:770)
        at scala.Iterator$$class.foreach(Iterator.scala:395)
        at scala.RandomAccessSeq$$$$anon$$12.foreach(RandomAccessSeq.scala:138)
        at scala.Iterable$$class.foreach(Iterable.scala:256)
        at scala.Range.foreach(Range.scala:30)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttributes(ClassfileParser.scala:770)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.parseClass(ClassfileParser.scala:357)
        at scala.tools.nsc.symtab.classfile.ClassfileParser.parse(ClassfileParser.scala:84)
        at scala.tools.nsc.symtab.SymbolLoaders$$ClassfileLoader$$$$anonfun$$doComplete$$3.apply(SymbolLoaders.scala:287)
        at scala.tools.nsc.symtab.SymbolLoaders$$ClassfileLoader$$$$anonfun$$doComplete$$3.apply(SymbolLoaders.scala:287)
        at scala.tools.nsc.symtab.SymbolLoaders.completeClassfile(SymbolLoaders.scala:278)
        at scala.tools.nsc.symtab.SymbolLoaders$$ClassfileLoader.doComplete(SymbolLoaders.scala:286)
        at scala.tools.nsc.symtab.SymbolLoaders$$SymbolLoader.complete(SymbolLoaders.scala:80)
        at scala.tools.nsc.symtab.SymbolLoaders$$SymbolLoader.load(SymbolLoaders.scala:100)
        at scala.tools.nsc.symtab.Symbols$$Symbol.exists(Symbols.scala:386)
        at scala.tools.nsc.typechecker.Typers$$Typer.qualifies$$1(Typers.scala:2782)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:2797)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3172)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedAppliedTypeTree$$1(Typers.scala:2915)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3195)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3243)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedType(Typers.scala:3312)
        at scala.tools.nsc.typechecker.Namers$$Namer.typeSig(Namers.scala:851)
        at scala.tools.nsc.typechecker.Namers$$Namer$$$$anonfun$$getterTypeCompleter$$1.apply(Namers.scala:436)
        at scala.tools.nsc.typechecker.Namers$$Namer$$$$anonfun$$getterTypeCompleter$$1.apply(Namers.scala:434)
        at scala.tools.nsc.typechecker.Namers$$$$anon$$1.complete(Namers.scala:1009)
        at scala.tools.nsc.symtab.Symbols$$Symbol.info(Symbols.scala:508)
        at scala.tools.nsc.symtab.Symbols$$Symbol.initialize(Symbols.scala:622)
        at scala.tools.nsc.typechecker.Typers$$Typer.addGetterSetter(Typers.scala:1088)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$10.apply(Typers.scala:1163)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$10.apply(Typers.scala:1163)
        at scala.List.flatMap(List.scala:1120)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedTemplate(Typers.scala:1163)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedClassDef(Typers.scala:1039)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2972)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3243)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3280)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
        at scala.List$$.loop$$1(List.scala:293)
        at scala.List$$.mapConserve(List.scala:310)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2968)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3243)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3280)
        at scala.tools.nsc.typechecker.Analyzer$$typerFactory$$$$anon$$2.apply(Analyzer.scala:40)
        at scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:257)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
        at scala.Iterator$$class.foreach(Iterator.scala:395)
        at scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:266)
        at scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:243)
        at scala.tools.nsc.Global$$Run.compileSources(Global.scala:556)
        at scala.tools.nsc.Global$$Run.compile(Global.scala:641)
        at scala.tools.nsc.Main$$.process(Main.scala:84)
        at scala.tools.nsc.Main$$.main(Main.scala:98)
        at scala.tools.nsc.Main.main(Main.scala)
@scabug
Copy link
Author

@scabug scabug commented May 20, 2008

@scabug
Copy link
Author

@scabug scabug commented May 21, 2008

@odersky said:
fixed in r15139

@scabug
Copy link
Author

@scabug scabug commented Jan 14, 2009

@odersky said:
Milestone next_bugfix deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants