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

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

Closed
scabug opened this issue Jan 7, 2014 · 6 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Jan 7, 2014

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 )
@scabug
Copy link
Author

@scabug scabug commented Jan 7, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8120?orig=1
Reporter: Chris Martin (chris-martin)
Affected Versions: 2.10.0, 2.10.1, 2.10.2, 2.10.3, 2.11.0-M7
Attachments:

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 7, 2014

Chris Martin (chris-martin) said:
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.

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 7, 2014

@retronym said (edited on Jan 7, 2014 9:38:03 AM UTC):
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 #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

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 7, 2014

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 7, 2014

@som-snytt said:
I did check it against the #8111 patch last night, but only got as far as noticing that changing the operator name from - works around it.

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 7, 2014

@retronym said:
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.

Loading

@scabug scabug closed this Jan 8, 2014
@scabug scabug added this to the 2.11.0-M8 milestone Apr 7, 2017
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