Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8207229

Trees.getScope crashes for broken lambda

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 12
    • Fix Version/s: 12
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b03
    • Verification:
      Verified

      Description

      Consider this code:
      ---
      class Test {
          void test() {
              cand((var s, t) -> \"\");
          }
          void cand(I i) { }
          interface I { public String test(String s); }
      }
      ---

      Using Trees.getScope to get a Scope for the lambda body leads to:
      ---
      java.lang.NullPointerException
      at jdk.compiler/com.sun.tools.javac.code.Types.subst(Types.java:3269)
      at jdk.compiler/com.sun.tools.javac.comp.InferenceContext.asUndetVar(InferenceContext.java:207)
      at jdk.compiler/com.sun.tools.javac.comp.InferenceContext.asUndetVars(InferenceContext.java:213)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkLambdaCompatible(Attr.java:2892)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2629)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:667)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:501)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:484)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:372)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:338)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:324)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$RecoveryDeferredTypeMap.recover(DeferredAttr.java:1084)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$RecoveryDeferredTypeMap.typeOf(DeferredAttr.java:1055)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$ResolveDeferredRecoveryMap.typeOf(Resolve.java:2564)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$ResolveDeferredRecoveryMap.typeOf(Resolve.java:2556)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredTypeMap.visitType(DeferredAttr.java:1022)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$RecoveryDeferredTypeMap.visitType(DeferredAttr.java:1045)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredTypeMap.visitType(DeferredAttr.java:1008)
      at jdk.compiler/com.sun.tools.javac.code.Type.accept(Type.java:214)
      at jdk.compiler/com.sun.tools.javac.code.Types$MapVisitor.visit(Types.java:4951)
      at jdk.compiler/com.sun.tools.javac.code.Types$TypeMapping.apply(Types.java:4962)
      at jdk.compiler/com.sun.tools.javac.code.Types$TypeMapping.apply(Types.java:4960)
      at jdk.compiler/com.sun.tools.javac.util.List.map(List.java:425)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$8.getArgumentTypes(Resolve.java:2552)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.accessInternal(Resolve.java:2473)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.accessMethod(Resolve.java:2493)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.access(Resolve.java:3307)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3548)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3528)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:2618)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3504)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2243)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:667)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2022)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:667)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:718)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1789)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:667)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:740)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:759)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1310)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:667)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:740)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStatToTree(Attr.java:426)
      at jdk.compiler/com.sun.tools.javac.api.JavacTrees.attribStatToTree(JavacTrees.java:937)
      at jdk.compiler/com.sun.tools.javac.api.JavacTrees.getAttrContext(JavacTrees.java:911)
      at jdk.compiler/com.sun.tools.javac.api.JavacTrees.getScope(JavacTrees.java:785)
      at jdk.compiler/com.sun.tools.javac.api.JavacTrees.getScope(JavacTrees.java:165)
      ---

        Attachments

          Activity

            People

            • Assignee:
              jlahoda Jan Lahoda
              Reporter:
              jlahoda Jan Lahoda
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: