Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-9390

Nested methods capture outer instance when lifted

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.11.7
    • Fix Version/s: Scala 2.12.0-M5
    • Component/s: Optimizer
    • Labels:
      None

      Description

      In this unit test, methodLift fails, while asFunction passes.

      @Test
      def methodLift {
          def isPrime(c: Int) = BigInt(c).isProbablePrime(1)
        assertNoOuter(isPrime)
      }
      @Test
      def asFunction {
        val isPrime = (c: Int) => BigInt(c).isProbablePrime(1)
        assertNoOuter(isPrime)
      }
      private def assertNoOuter(f: Int => Boolean) {
        assertFalse(f.getClass.getDeclaredFields.exists(_.getType == this.getClass))
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rytz Lukas Rytz
                Reporter:
                nilskp Nils Kilden-Pedersen
              • Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: