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

substSym call in matchesQuantified could be avoided #551

Open
2 tasks
retronym opened this issue Aug 30, 2018 · 1 comment
Open
2 tasks

substSym call in matchesQuantified could be avoided #551

retronym opened this issue Aug 30, 2018 · 1 comment

Comments

@retronym
Copy link
Member

I think we could avoid this by first checking MethodType.isTrivial (which is cached) to avoid this call. We might also be able avoid it under phase.erasedTypes.

  • Add an assertion to check that the substSym is an identity when each of those conditions hold, run the test suite and boostrap to test this out
  • Check those conditions before calling it.
@diesalbla
Copy link

diesalbla commented Jan 13, 2019

@retronym I have tried changing the code of matchesQuantified in the line you suggested of using isTrivial, by changing the following line:

     def matchesQuantified(tparams1: List[Symbol], tparams2: List[Symbol], res1: Type, res2: Type): Boolean = (
       sameLength(tparams1, tparams2) &&
-      matchesType(res1, res2.substSym(tparams2, tparams1), alwaysMatchSimple)
+      matchesType(res1, if (res2.isTrivial) res2 else res2.substSym(tparams2, tparams1), alwaysMatchSimple)
     )

And I have run partest with the modified code, but it fails at some tests. In particular, at the test/run/t6135, which compiles in the current version 2.13.x, it rejects the program with the following error:

!! 1 - run/t6135.scala                           [compilation failed with 1 errors]
##### Log file '/Users/diesalbla/floss/scalac/test/files/run/t6135-run.log' from failed test #####

t6135.scala:8: error: object creation impossible, since method foo in class B of type (t: String, a: Test.A)(v: a.V)Unit is not defined
(Note that a.V does not match a.V: their prefixes (i.e., enclosing instances) differ)
  val b1 = new B[String] {
               ^
one error found

This example relates to path-dependent types.

@dwijnand dwijnand added this to the Backlog milestone Nov 5, 2020
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

3 participants