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

Incorrect ambiguous import error (probably a regression since M4)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0-M5
    • Fix Version/s: Scala 2.10.0-M5
    • Component/s: None
    • Labels:
    • Environment:

      2.10.0-M5

      Description

      package test
      
      trait ImportMe {
        def foo(i: Int) = 1
        def foo(s: String) = 2
      }
      
      class Test(val importMe: ImportMe) {
        import importMe._
        import importMe._
      
        // A.scala:12: error: reference to foo is ambiguous;
        // it is imported twice in the same scope by
        // import importMe._
        // and import importMe._
        //   println(foo(1))
        //           ^
        println(foo(1))
      }
      

      Note: if there's only one def foo in ImportMe, there's no problem.

        Issue Links

          Activity

          Hide
          Eugene Burmako added a comment -

          This is an excerpt from the Ensime codebase, which compiles fine with 2.9.2 and 2.10.0-M4. We've raised the priority to "Critical" because it seems to be a regression.

          Show
          Eugene Burmako added a comment - This is an excerpt from the Ensime codebase, which compiles fine with 2.9.2 and 2.10.0-M4. We've raised the priority to "Critical" because it seems to be a regression.
          Show
          Paul Phillips added a comment - https://github.com/scala/scala/pull/966
          Hide
          Vlad Ureche added a comment -

          Thank you!

          Show
          Vlad Ureche added a comment - Thank you!
          Hide
          Paul Phillips added a comment -

          "This is an excerpt from the Ensime codebase, which compiles fine with 2.9.2 and 2.10.0-M4."

          Please be extremely careful with claims like this; when you are wrong, it is very misleading about where the problem was introduced.

          % m4scalac /scala/trunk/test/files/pos/t6117.scala 
          /scala/trunk/test/files/pos/t6117.scala:18: error: reference to foo is ambiguous;
          it is imported twice in the same scope by
          import importMe._
          and import importMe._
            println(foo(1))
                    ^
          one error found
          % m3scalac /scala/trunk/test/files/pos/t6117.scala 
          %
          
          Show
          Paul Phillips added a comment - "This is an excerpt from the Ensime codebase, which compiles fine with 2.9.2 and 2.10.0-M4." Please be extremely careful with claims like this; when you are wrong, it is very misleading about where the problem was introduced. % m4scalac /scala/trunk/test/files/pos/t6117.scala /scala/trunk/test/files/pos/t6117.scala:18: error: reference to foo is ambiguous; it is imported twice in the same scope by import importMe._ and import importMe._ println(foo(1)) ^ one error found % m3scalac /scala/trunk/test/files/pos/t6117.scala %
          Hide
          Eugene Burmako added a comment -

          Sorry I misinterpreted the results. Ensime indeed compiled finely with 2.10.0-M4 and didn't compile with today's nightly. However I should've run M4 on the distilled snippet before jumping into the discussion.

          Show
          Eugene Burmako added a comment - Sorry I misinterpreted the results. Ensime indeed compiled finely with 2.10.0-M4 and didn't compile with today's nightly. However I should've run M4 on the distilled snippet before jumping into the discussion.
          Hide
          Paul Phillips added a comment -

          It's a completely understandable error, especially if ensime compiled and the snippet doesn't - I'm just drawing attention to it because the more reliable the speaker is in general, the longer it is before one questions the input data. It's not a fair universe if being reliable imposes a greater obligation to be reliable, but indeed it is not a fair universe.

          Show
          Paul Phillips added a comment - It's a completely understandable error, especially if ensime compiled and the snippet doesn't - I'm just drawing attention to it because the more reliable the speaker is in general, the longer it is before one questions the input data. It's not a fair universe if being reliable imposes a greater obligation to be reliable, but indeed it is not a fair universe.
          Hide
          Jason Zaugg added a comment -

          Regression introduced (by me) in the fix for SI-4831

          Show
          Jason Zaugg added a comment - Regression introduced (by me) in the fix for SI-4831
          Show
          Adriaan Moors added a comment - https://github.com/scala/scala/pull/966

            People

            • Assignee:
              Paul Phillips
              Reporter:
              Vlad Ureche
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development