Skip to content

Crash when a .java file selects an inner class on a raw type #3807

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
smarter opened this issue Jan 11, 2018 · 0 comments
Closed

Crash when a .java file selects an inner class on a raw type #3807

smarter opened this issue Jan 11, 2018 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented Jan 11, 2018

This is valid Java code (minimized from https://github.com/lampepfl/dotty/tree/master/tests/pending/pos/java-interop/t1263):

public class Test {
  public Outer.Inner foo() {
    return null;
  }
}

class Outer<A> {
  class Inner {}
}

But it crashes Dotty:

assertion failure for Outer <:< ?{ Inner: ? }, frozen = false
exception occurred while typechecking tests/pos-java-interop/t1263/Test.java
exception occurred while compiling tests/pos-java-interop/t1263/Test.java
Exception in thread "main" java.lang.AssertionError: assertion failed: invalid prefix HKTypeLambda(List(A), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class Outer),List(TypeParamRef(A))))
        at scala.Predef$.assert(Predef.scala:219)
        at dotty.tools.dotc.core.Types$NamedType.<init>(Types.scala:1535)
        at dotty.tools.dotc.core.Types$TypeRef.<init>(Types.scala:2055)
        at dotty.tools.dotc.core.Types$CachedTypeRef.<init>(Types.scala:2071)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.newType$1(Uniques.scala:61)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.enterIfNew(Uniques.scala:65)
        at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:2110)
        at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:2116)
        at dotty.tools.dotc.core.Types$NamedType$.apply(Types.scala:2090)
        at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.qualifies$1(ProtoTypes.scala:104)
        at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.isMatchedBy(ProtoTypes.scala:108)
        at dotty.tools.dotc.core.TypeComparer.isMatchedByProto(TypeComparer.scala:1055)
        at dotty.tools.dotc.core.TypeComparer.firstTry(TypeComparer.scala:213)
        at dotty.tools.dotc.core.TypeComparer.$anonfun$isSubType$2(TypeComparer.scala:118)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:32)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:109)
        at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:103)
        at dotty.tools.dotc.core.Types$Type.$anonfun$$less$colon$less$1(Types.scala:769)
        at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.core.Types$Type.$less$colon$less(Types.scala:769)
        at dotty.tools.dotc.typer.Typer.adaptType$1(Typer.scala:2374)
        at dotty.tools.dotc.typer.Typer.adaptInterpolated(Typer.scala:2425)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$3(Typer.scala:1952)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:1945)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:1945)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1780)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1776)
        at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:1839)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedSelect$1(Typer.scala:432)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:408)
        at dotty.tools.dotc.typer.Typer.typeSelectOnType$1(Typer.scala:420)
        at dotty.tools.dotc.typer.Typer.tryJavaSelectOnType$1(Typer.scala:424)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedSelect$4(Typer.scala:438)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1845)
        at dotty.tools.dotc.typer.Typer.$anonfun$tryAlternatively$1(Typer.scala:1859)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1847)
        at dotty.tools.dotc.typer.Typer.tryAlternatively(Typer.scala:1858)
        at dotty.tools.dotc.typer.Typer.selectWithFallback$1(Typer.scala:429)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedSelect$1(Typer.scala:438)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:408)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1694)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1762)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1780)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1776)
        at dotty.tools.dotc.typer.Namer.$anonfun$typedAheadType$1(Namer.scala:942)
        at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:935)
        at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:942)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1120)
        at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1167)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:736)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:783)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:761)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:246)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:209)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:211)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:352)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1666)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1691)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1762)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1780)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1776)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1802)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1825)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1485)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1415)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1704)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1762)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1780)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1776)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1802)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1825)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1599)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1586)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1744)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1763)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1780)
        at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1776)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1837)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:66)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:34)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:64)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$7(FrontEnd.scala:95)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$7$adapted(FrontEnd.scala:95)
        at scala.collection.immutable.List.foreach(List.scala:389)
        at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:95)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:125)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:47)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:123)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:121)
        at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
        at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:121)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:141)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:107)
        at dotty.tools.dotc.Run.compileSources(Run.scala:94)
        at dotty.tools.dotc.Run.compile(Run.scala:78)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:29)
        at dotty.tools.dotc.Driver.process(Driver.scala:127)
        at dotty.tools.dotc.Driver.process(Driver.scala:96)
        at dotty.tools.dotc.Driver.process(Driver.scala:108)
        at dotty.tools.dotc.Driver.main(Driver.scala:135)
        at dotty.tools.dotc.Main.main(Main.scala)

The crash doesn't happen if Outer.Inner is replaced by Outer<Integer>.Inner.

smarter added a commit that referenced this issue Jan 12, 2018
Fix #3807: Handle selection on raw Java type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant