Scala Programming Language
  1. Scala Programming Language
  2. SI-8120

corrupt symbol structure for pattern matching anoymous function in argument to application that falls back to a view on the function

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0, Scala 2.10.1, Scala 2.10.2, Scala 2.10.3, Scala 2.11.0-M7
    • Fix Version/s: Scala 2.11.0-M8
    • Component/s: Type Checker
    • Labels:
      None

      Description

      object A {
        class B {
          def +(i: Int): B = this
        }
        implicit class C(i: Int) {
          def -(f: B): Int = 0
        }
        4 - Nil.foldLeft(new B) { case (x, y) => x }
      }
      

      Output from scalac 2.10.3 is attached (tried to post it here in the description, but JIRA mangled it).

      Exception in thread "main" java.lang.IllegalArgumentException: Could not find proxy for val x2: Tuple2 in List(value x2, method apply, <$anon: Function1>, value <local A>, object A, package <empty>, package <root>) (currentOwner= value x )
      

        Activity

        Hide
        Chris Martin added a comment -

        Sorry I can't be more specific with my description than "compiler error", but I don't understand the problem well enough to elaborate any further.

        Show
        Chris Martin added a comment - Sorry I can't be more specific with my description than "compiler error", but I don't understand the problem well enough to elaborate any further.
        Hide
        Jason Zaugg added a comment - - edited

        Minimized a bit further:

        object A {
          class C {
            def m(a: Nothing): Int = 0
          }
          implicit class RichAny(a: Any) {
            def m(a: Any): Int = 0
          }
          (new C).m({ case (x, y) => x } : Any => Any)
        }
        
        

        This smells rather similar to SI-8111, but it isn't the same bug.

        qbin/scalac -Ycheck:typer ../scala/sandbox/test.scala
        [Now checking: typer]
        [check: typer] ../scala/sandbox/test.scala:8:
         currentOwner chain: value $anonfun -> value <local A> -> object A
               symbol chain: value x -> value $anonfun -> value <local A> -> object A -> package <empty> -> package <root>scala.reflect.internal.Trees$Bind / (x @ _)
        [check: typer] ../scala/sandbox/test.scala:8:
         currentOwner chain: value $anonfun -> value <local A> -> object A
               symbol chain: value y -> value $anonfun -> value <local A> -> object A -> package <empty> -> package <root>scala.reflect.internal.Trees$Bind / (y @ _)
        warning: TreeCheckers detected non-compliant trees in test.scala
        
        Show
        Jason Zaugg added a comment - - edited Minimized a bit further: object A { class C { def m(a: Nothing): Int = 0 } implicit class RichAny(a: Any) { def m(a: Any): Int = 0 } (new C).m({ case (x, y) => x } : Any => Any) } This smells rather similar to SI-8111 , but it isn't the same bug. qbin/scalac -Ycheck:typer ../scala/sandbox/test.scala [Now checking: typer] [check: typer] ../scala/sandbox/test.scala:8: currentOwner chain: value $anonfun -> value <local A> -> object A symbol chain: value x -> value $anonfun -> value <local A> -> object A -> package <empty> -> package <root>scala.reflect.internal.Trees$Bind / (x @ _) [check: typer] ../scala/sandbox/test.scala:8: currentOwner chain: value $anonfun -> value <local A> -> object A symbol chain: value y -> value $anonfun -> value <local A> -> object A -> package <empty> -> package <root>scala.reflect.internal.Trees$Bind / (y @ _) warning: TreeCheckers detected non-compliant trees in test.scala
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/3331
        Hide
        A. P. Marki added a comment -

        I did check it against the SI-8111 patch last night, but only got as far as noticing that changing the operator name from `-` works around it.

        Show
        A. P. Marki added a comment - I did check it against the SI-8111 patch last night, but only got as far as noticing that changing the operator name from `-` works around it.
        Hide
        Jason Zaugg added a comment -

        As @xeno-by said, the symbols appear to be open revolt this year.

        As you've probably gleaned now, the name of the operator is only relevant in that it must be one that exists on the original function, before the implicit view is tried.

        Show
        Jason Zaugg added a comment - As @xeno-by said, the symbols appear to be open revolt this year. As you've probably gleaned now, the name of the operator is only relevant in that it must be one that exists on the original function, before the implicit view is tried.

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Chris Martin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development